From c11de2384f44961d0c36286ecffcdee51d463ef5 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 7 Oct 2011 10:18:43 +0100 Subject: [PATCH 01/19] ENH: Added templated binary ops to AMI interpolation functions --- .../AMIInterpolation/AMIInterpolation.C | 76 ++++++++++++++++--- .../AMIInterpolation/AMIInterpolation.H | 47 +++++++++++- 2 files changed, 107 insertions(+), 16 deletions(-) diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 535583a9e1..2e6a4b4384 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -1333,11 +1333,12 @@ void Foam::AMIInterpolation::update template -template +template Foam::tmp > Foam::AMIInterpolation::interpolateToSource ( - const Field& fld + const Field& fld, + const BinaryOp& bop ) const { if (fld.size() != tgtAddress_.size()) @@ -1377,7 +1378,7 @@ Foam::AMIInterpolation::interpolateToSource forAll(faces, i) { - result[faceI] += work[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]); } } } @@ -1390,7 +1391,7 @@ Foam::AMIInterpolation::interpolateToSource forAll(faces, i) { - result[faceI] += fld[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]); } } } @@ -1400,24 +1401,26 @@ Foam::AMIInterpolation::interpolateToSource template -template +template Foam::tmp > Foam::AMIInterpolation::interpolateToSource ( - const tmp >& tFld + const tmp >& tFld, + const BinaryOp& bop ) const { - return interpolateToSource(tFld()); + return interpolateToSource(tFld(), bop); } template -template +template Foam::tmp > Foam::AMIInterpolation::interpolateToTarget ( - const Field& fld + const Field& fld, + const BinaryOp& bop ) const { if (fld.size() != srcAddress_.size()) @@ -1457,7 +1460,7 @@ Foam::AMIInterpolation::interpolateToTarget forAll(faces, i) { - result[faceI] += work[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]); } } } @@ -1470,7 +1473,7 @@ Foam::AMIInterpolation::interpolateToTarget forAll(faces, i) { - result[faceI] += fld[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]); } } } @@ -1479,6 +1482,55 @@ Foam::AMIInterpolation::interpolateToTarget } +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToTarget +( + const tmp >& tFld, + const BinaryOp& bop +) const +{ + return interpolateToTarget(tFld(), bop); +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToSource +( + const Field& fld +) const +{ + return interpolateToSource(fld, sumOp()); +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToSource +( + const tmp >& tFld +) const +{ + return interpolateToSource(tFld, sumOp()); +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToTarget +( + const Field& fld +) const +{ + return interpolateToSource(fld, sumOp()); +} + + template template Foam::tmp > @@ -1487,7 +1539,7 @@ Foam::AMIInterpolation::interpolateToTarget const tmp >& tFld ) const { - return interpolateToTarget(tFld()); + return interpolateToSource(tFld, sumOp()); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index b9d73f24ee..8df0d6fb4a 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -53,6 +53,7 @@ SourceFiles #include "treeBoundBox.H" #include "treeBoundBoxList.H" #include "globalIndex.H" +#include "ops.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -345,11 +346,46 @@ public: // Evaluation + //- Interpolate from target to source with supplied op + template + tmp > interpolateToSource + ( + const Field& fld, + const BinaryOp& bop + ) const; + + //- Interpolate from target tmp field to source with supplied op + template + tmp > interpolateToSource + ( + const tmp >& tFld, + const BinaryOp& bop + ) const; + + //- Interpolate from source to target with supplied op + template + tmp > interpolateToTarget + ( + const Field& fld, + const BinaryOp& bop + ) const; + + //- Interpolate from source tmp field to target with supplied op + template + tmp > interpolateToTarget + ( + const tmp >& tFld, + const BinaryOp& bop + ) const; + //- Interpolate from target to source template - tmp > interpolateToSource(const Field& fld) const; + tmp > interpolateToSource + ( + const Field& fld + ) const; - //- Interpolate from target tmp field to source + //- Interpolate from target tmp field template tmp > interpolateToSource ( @@ -358,9 +394,12 @@ public: //- Interpolate from source to target template - tmp > interpolateToTarget(const Field& fld) const; + tmp > interpolateToTarget + ( + const Field& fld + ) const; - //- Interpolate from source tmp field to target + //- Interpolate from source tmp field template tmp > interpolateToTarget ( From 24b949f5492f5dee778fd8ff22f670c0216cd094 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 7 Oct 2011 10:19:41 +0100 Subject: [PATCH 02/19] ENH: Updated mappedPatchBase to include binary op functions for distribute --- .../mappedPolyPatch/mappedPatchBase.H | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H index 68c432e97a..b2f0f4eb92 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H @@ -339,6 +339,39 @@ public: } + //- Wrapper around map/interpolate data distribution with supplied op + template + void distribute(List& lst, const BinaryOp& bop) const + { + switch (mode_) + { + case NEARESTPATCHFACEAMI: + { + lst = AMI().interpolateToSource + ( + Field(lst.xfer()), + bop + ); + break; + } + default: + { + map().distribute + ( + Pstream::defaultCommsType, + map().schedule(), + map().constructSize(), + map().subMap(), + map().constructMap(), + lst, + bop, + pTraits::zero + ); + } + } + } + + //- Wrapper around map/interpolate data distribution template void reverseDistribute(List& lst) const @@ -359,6 +392,40 @@ public: } + //- Wrapper around map/interpolate data distribution with supplied op + template + void reverseDistribute(List& lst, const BinaryOp& bop) const + { + switch (mode_) + { + case NEARESTPATCHFACEAMI: + { + lst = AMI().interpolateToTarget + ( + Field(lst.xfer()), + bop + ); + break; + } + default: + { + label cSize = patch_.size(); + map().distribute + ( + Pstream::defaultCommsType, + map().schedule(), + cSize, + map().constructMap(), + map().subMap(), + lst, + bop, + pTraits::zero + ); + } + } + } + + //- Return reference to the parallel distribution map const mapDistribute& map() const { From 385248c5bf57065bbaa0d19e61a811f3f6273660 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 7 Oct 2011 10:21:02 +0100 Subject: [PATCH 03/19] ENH: Propogated binary op for inter-region comms to region model --- .../regionModel/regionModel/regionModel.H | 18 +++++ .../regionModel/regionModelTemplates.C | 65 +++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/src/regionModels/regionModel/regionModel/regionModel.H b/src/regionModels/regionModel/regionModel/regionModel.H index 2af98421d1..49f708bcd8 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.H +++ b/src/regionModels/regionModel/regionModel/regionModel.H @@ -231,6 +231,24 @@ public: List& primaryFieldField ) const; + //- Convert a local region field to the primary region with op + template + void toPrimary + ( + const label regionPatchI, + List& regionField, + const BinaryOp& bop + ) const; + + //- Convert a primary region field to the local region with op + template + void toRegion + ( + const label regionPatchI, + List& primaryFieldField, + const BinaryOp& bop + ) const; + // Evolution diff --git a/src/regionModels/regionModel/regionModel/regionModelTemplates.C b/src/regionModels/regionModel/regionModel/regionModelTemplates.C index 977da7dd81..ab013ad8e0 100644 --- a/src/regionModels/regionModel/regionModel/regionModelTemplates.C +++ b/src/regionModels/regionModel/regionModel/regionModelTemplates.C @@ -77,4 +77,69 @@ void Foam::regionModels::regionModel::toRegion } +template +void Foam::regionModels::regionModel::toPrimary +( + const label regionPatchI, + List& regionField, + const BinaryOp& bop +) const +{ + forAll(intCoupledPatchIDs_, i) + { + if (intCoupledPatchIDs_[i] == regionPatchI) + { + const mappedPatchBase& mpb = + refCast + ( + regionMesh().boundaryMesh()[regionPatchI] + ); + mpb.reverseDistribute(regionField, bop); + return; + } + } + + FatalErrorIn + ( + "const void toPrimary" + "(" + "const label, " + "List&, " + "const BinaryOp&" + ") const" + ) << "Region patch ID " << regionPatchI << " not found in region mesh" + << abort(FatalError); +} + + +template +void Foam::regionModels::regionModel::toRegion +( + const label regionPatchI, + List& primaryField, + const BinaryOp& bop +) const +{ + forAll(intCoupledPatchIDs_, i) + { + if (intCoupledPatchIDs_[i] == regionPatchI) + { + const mappedPatchBase& mpb = + refCast + ( + regionMesh().boundaryMesh()[regionPatchI] + ); + mpb.distribute(primaryField, bop); + return; + } + } + + FatalErrorIn + ( + "const void toRegion(const label, List&, const BinaryOp&) const" + ) << "Region patch ID " << regionPatchI << " not found in region mesh" + << abort(FatalError); +} + + // ************************************************************************* // From b9e171eb570fc41a95da7e16f028099a7561c8f3 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 7 Oct 2011 10:21:59 +0100 Subject: [PATCH 04/19] ENH: Use new maxOp when collecting new parcel diamaters from film model --- .../SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C index d080a624a2..af83ca1429 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C @@ -239,7 +239,7 @@ void Foam::SurfaceFilmModel::cacheFilmFields diameterParcelPatch_ = filmModel.cloudDiameterTrans().boundaryField()[filmPatchI]; - filmModel.toPrimary(filmPatchI, diameterParcelPatch_); + filmModel.toPrimary(filmPatchI, diameterParcelPatch_, maxOp()); UFilmPatch_ = filmModel.Us().boundaryField()[filmPatchI]; filmModel.toPrimary(filmPatchI, UFilmPatch_); From fdcfe3bda65fd71c455090bc8a17fec0963a7816 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 13 Oct 2011 13:06:11 +0100 Subject: [PATCH 05/19] ENH: Added fieldCoordinateSystemTransform function object - self explanatory --- .../functionObjects/field/Make/files | 3 + .../IOfieldCoordinateSystemTransform.H | 50 ++++++ .../fieldCoordinateSystemTransform.C | 118 +++++++++++++ .../fieldCoordinateSystemTransform.H | 163 ++++++++++++++++++ ...dCoordinateSystemTransformFunctionObject.C | 45 +++++ ...dCoordinateSystemTransformFunctionObject.H | 54 ++++++ .../fieldCoordinateSystemTransformTemplates.C | 158 +++++++++++++++++ .../postProcessingDict | 50 ++++++ 8 files changed, 641 insertions(+) create mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/IOfieldCoordinateSystemTransform.H create mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C create mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H create mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C create mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H create mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C create mode 100644 src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index c1497c5e54..9d465d2663 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -3,6 +3,9 @@ fieldAverage/fieldAverageItem/fieldAverageItem.C fieldAverage/fieldAverageItem/fieldAverageItemIO.C fieldAverage/fieldAverageFunctionObject/fieldAverageFunctionObject.C +fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C + fieldMinMax/fieldMinMax.C fieldMinMax/fieldMinMaxFunctionObject.C diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/IOfieldCoordinateSystemTransform.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/IOfieldCoordinateSystemTransform.H new file mode 100644 index 0000000000..36216f399b --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/IOfieldCoordinateSystemTransform.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Typedef + Foam::IOfieldCoordinateSystemTransform + +Description + Instance of the generic IOOutputFilter for fieldCoordinateSystemTransform. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOfieldCoordinateSystemTransform_H +#define IOfieldCoordinateSystemTransform_H + +#include "fieldCoordinateSystemTransform.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter + IOfieldCoordinateSystemTransform; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C new file mode 100644 index 0000000000..afb592bc78 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "fieldCoordinateSystemTransform.H" +#include "dictionary.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::fieldCoordinateSystemTransform, 0); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + fieldSet_(), + coordSys_(dict, obr) +{ + // Check if the available mesh is an fvMesh otherise deactivate + if (!isA(obr_)) + { + active_ = false; + WarningIn + ( + "fieldCoordinateSystemTransform::fieldCoordinateSystemTransform" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." + << endl; + } + + read(dict); + + Info<< type() << ":" << nl + << " Applying transformation from global Cartesian to local " + << coordSys_ << nl << endl; +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fieldCoordinateSystemTransform::~fieldCoordinateSystemTransform() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::fieldCoordinateSystemTransform::read(const dictionary& dict) +{ + if (active_) + { + dict.lookup("fields") >> fieldSet_; + } +} + + +void Foam::fieldCoordinateSystemTransform::execute() +{ + // Do nothing +} + + +void Foam::fieldCoordinateSystemTransform::end() +{ + // Do nothing +} + + +void Foam::fieldCoordinateSystemTransform::write() +{ + forAll(fieldSet_, fieldI) + { + // If necessary load field + transform(fieldSet_[fieldI]); + transform(fieldSet_[fieldI]); + transform(fieldSet_[fieldI]); + transform(fieldSet_[fieldI]); + transform(fieldSet_[fieldI]); + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H new file mode 100644 index 0000000000..138d2d09d5 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.H @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::fieldCoordinateSystemTransform + +Description + Transforms fields from global cartesian co-ordinates to local co-ordinate + system + +SourceFiles + fieldCoordinateSystemTransform.C + IOfieldCoordinateSystemTransform.H + +\*---------------------------------------------------------------------------*/ + +#ifndef fieldCoordinateSystemTransform_H +#define fieldCoordinateSystemTransform_H + +#include "OFstream.H" +#include "pointFieldFwd.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "coordinateSystem.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class fieldCoordinateSystemTransform Declaration +\*---------------------------------------------------------------------------*/ + +class fieldCoordinateSystemTransform +{ +protected: + + // Protected data + + //- Name + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- Fields to transform + wordList fieldSet_; + + //- Co-ordinate system to transform to + coordinateSystem coordSys_; + + + // Protected Member Functions + + //- Disallow default bitwise copy construct + fieldCoordinateSystemTransform(const fieldCoordinateSystemTransform&); + + //- Disallow default bitwise assignment + void operator=(const fieldCoordinateSystemTransform&); + + template + void transform(const word& fieldName) const; + + template + void transformField(const Type& field) const; + + +public: + + //- Runtime type information + TypeName("fieldCoordinateSystemTransform"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + fieldCoordinateSystemTransform + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~fieldCoordinateSystemTransform(); + + + // Member Functions + + //- Return name of the fieldCoordinateSystemTransform object + virtual const word& name() const + { + return name_; + } + + //- Read the input data + virtual void read(const dictionary&); + + //- Execute, currently does nothing + virtual void execute(); + + //- Execute at the final time-loop, currently does nothing + virtual void end(); + + //- Write + virtual void write(); + + //- Update for changes of mesh + virtual void updateMesh(const mapPolyMesh&) + {} + + //- Update for changes of mesh + virtual void movePoints(const pointField&) + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "fieldCoordinateSystemTransformTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C new file mode 100644 index 0000000000..be3f5624b4 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.C @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "fieldCoordinateSystemTransformFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug + ( + fieldCoordinateSystemTransformFunctionObject, 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + fieldCoordinateSystemTransformFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H new file mode 100644 index 0000000000..20cf0fccbf --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformFunctionObject.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Typedef + Foam::fieldCoordinateSystemTransformFunctionObject + +Description + FunctionObject wrapper around fieldCoordinateSystemTransform to allow + them to be created via the functions entry within controlDict. + +SourceFiles + fieldCoordinateSystemTransformFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fieldCoordinateSystemTransformFunctionObject_H +#define fieldCoordinateSystemTransformFunctionObject_H + +#include "fieldCoordinateSystemTransform.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject + fieldCoordinateSystemTransformFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C new file mode 100644 index 0000000000..c1ecc72707 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "fieldCoordinateSystemTransform.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "Time.H" +#include "transformGeometricField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +void Foam::fieldCoordinateSystemTransform::transformField +( + const Type& field +) const +{ + const word& fieldName = field.name() + "Transformed"; + + dimensionedTensor R("R", field.dimensions(), coordSys_.R()); + + if (obr_.foundObject(fieldName)) + { + Type& transField = + const_cast(obr_.lookupObject(fieldName)); + + transField == field; + + forAll(field, i) + { + Foam::transform(transField, R, transField); + } + + transField.write(); + } + else + { + Type& transField = obr_.store + ( + new Type + ( + IOobject + ( + fieldName, + obr_.time().timeName(), + obr_, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + field + ) + ); + + forAll(field, i) + { + Foam::transform(transField, R, transField); + } + + transField.write(); + } +} + + +template +void Foam::fieldCoordinateSystemTransform::transform +( + const word& fieldName +) const +{ + typedef GeometricField vfType; + typedef GeometricField sfType; + + if (obr_.foundObject(fieldName)) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " already in database" + << endl; + } + + transformField(obr_.lookupObject(fieldName)); + } + else if (obr_.foundObject(fieldName)) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " already in database" + << endl; + } + + transformField(obr_.lookupObject(fieldName)); + } + else + { + IOobject fieldHeader + ( + fieldName, + obr_.time().timeName(), + obr_, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if + ( + fieldHeader.headerOk() + && fieldHeader.headerClassName() == vfType::typeName + ) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " read from file" + << endl; + } + + transformField(obr_.lookupObject(fieldName)); + } + else if + ( + fieldHeader.headerOk() + && fieldHeader.headerClassName() == sfType::typeName + ) + { + if (debug) + { + Info<< type() << ": Field " << fieldName << " read from file" + << endl; + } + + transformField(obr_.lookupObject(fieldName)); + } + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict new file mode 100644 index 0000000000..e0d17f6271 --- /dev/null +++ b/src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/postProcessingDict @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object postProcessingDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +functions +{ + fieldCoordinateSystemTransform1 + { + // Type of functionObject + type fieldCoordinateSystemTransform; + + // Where to load it from (if not already in solver) + functionObjectLibs ("libfieldCoordinateSystemTransform.so"); + + // Function object enabled flag + enabled true; + + // When to output the average fields + outputControl outputTime; + + // Fields to be transformed - runTime modifiable + fields + ( + U + UMean + UPrime2Mean + ); + + coordinateSystem + { + origin (0.001 0 0); + e1 (1 0.15 0); + e3 (0 0 -1); + } + } +} + +// ************************************************************************* // From 6ef1fc7865748c147714e6ac58c29fef687c8ee9 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 17 Oct 2011 18:27:09 +0100 Subject: [PATCH 06/19] ENH: sigStopAt: added checking for same signals --- src/OSspecific/POSIX/signals/sigStopAtWriteNow.C | 15 +++++++++++++++ src/OSspecific/POSIX/signals/sigWriteNow.H | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C index 09d862ca5d..e973bc1bd8 100644 --- a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C +++ b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C @@ -83,6 +83,21 @@ Foam::sigStopAtWriteNow::sigStopAtWriteNow { if (signal_ > 0) { + // Check that the signal is different from the writeNowSignal + if (sigWriteNow::signal_ == signal_) + { + FatalErrorIn + ( + "Foam::sigStopAtWriteNow::sigStopAtWriteNow" + "(const bool, const Time&)" + ) << "stopAtWriteNowSignal : " << signal_ + << " cannot be the same as the writeNowSignal." + << " Please change this in the controlDict (" + << findEtcFile("controlDict", false) << ")." + << exit(FatalError); + } + + // Store runTime runTimePtr_ = &runTime; diff --git a/src/OSspecific/POSIX/signals/sigWriteNow.H b/src/OSspecific/POSIX/signals/sigWriteNow.H index 871b980edd..477bae825f 100644 --- a/src/OSspecific/POSIX/signals/sigWriteNow.H +++ b/src/OSspecific/POSIX/signals/sigWriteNow.H @@ -67,6 +67,8 @@ class sigWriteNow public: + friend class sigStopAtWriteNow; + // Constructors //- Construct null From d25d4d28cea240a7014b5b4d90d8ed5d634591b6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 17 Oct 2011 18:27:47 +0100 Subject: [PATCH 07/19] ENH: checkMesh: zero cell meshes --- .../utilities/mesh/manipulation/checkMesh/checkTopology.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index daf71ac7e9..a6ae8b7681 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -36,7 +36,7 @@ Foam::label Foam::checkTopology label nTotCells = returnReduce(mesh.cells().size(), sumOp