diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C index d0e73d77eb..27477c3c05 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C @@ -32,6 +32,7 @@ Description #include "fvCFD.H" #include "meshToMesh.H" +#include "cellVolumeWeightMethod.H" #include "processorPolyPatch.H" #include "MapMeshes.H" @@ -41,7 +42,7 @@ void mapConsistentMesh ( const fvMesh& meshSource, const fvMesh& meshTarget, - const meshToMesh::interpolationMethod& mapMethod, + const word& mapMethod, const bool subtract, const HashSet& selectedFields, const bool noLagrangian @@ -79,7 +80,7 @@ void mapSubMesh const fvMesh& meshTarget, const HashTable& patchMap, const wordList& cuttingPatches, - const meshToMesh::interpolationMethod& mapMethod, + const word& mapMethod, const bool subtract, const HashSet& selectedFields, const bool noLagrangian @@ -231,16 +232,15 @@ int main(int argc, char *argv[]) const bool consistent = args.optionFound("consistent"); - meshToMesh::interpolationMethod mapMethod = - meshToMesh::imCellVolumeWeight; - - if (args.optionFound("mapMethod")) - { - mapMethod = meshToMesh::interpolationMethodNames_[args["mapMethod"]]; - - Info<< "Mapping method: " - << meshToMesh::interpolationMethodNames_[mapMethod] << endl; - } + const word mapMethod + ( + args.optionLookupOrDefault + ( + "mapMethod", + cellVolumeWeightMethod::typeName + ) + ); + Info<< "Mapping method: " << mapMethod << endl; const bool subtract = args.optionFound("subtract"); if (subtract) diff --git a/src/fvModels/interRegion/interRegionModel/interRegionModel.C b/src/fvModels/interRegion/interRegionModel/interRegionModel.C index 12eef984d1..ce3fb643e6 100644 --- a/src/fvModels/interRegion/interRegionModel/interRegionModel.C +++ b/src/fvModels/interRegion/interRegionModel/interRegionModel.C @@ -25,6 +25,7 @@ License #include "interRegionModel.H" #include "fvModels.H" +#include "directMethod.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -50,11 +51,7 @@ void Foam::fv::interRegionModel::readCoeffs() "nbrRegionName" }); - interpolationMethod_ = - meshToMesh::interpolationMethodNames_.read - ( - coeffs().lookup("interpolationMethod") - ); + coeffs().lookup("interpolationMethod") >> interpolationMethod_; } @@ -143,7 +140,7 @@ Foam::fv::interRegionModel::interRegionModel fvModel(name, modelType, dict, mesh), master_(false), nbrRegionName_(word::null), - interpolationMethod_(meshToMesh::imDirect), + interpolationMethod_(directMethod::typeName), meshInterpPtr_() { readCoeffs(); diff --git a/src/fvModels/interRegion/interRegionModel/interRegionModel.H b/src/fvModels/interRegion/interRegionModel/interRegionModel.H index 152f8555ef..f24941c12b 100644 --- a/src/fvModels/interRegion/interRegionModel/interRegionModel.H +++ b/src/fvModels/interRegion/interRegionModel/interRegionModel.H @@ -62,7 +62,7 @@ class interRegionModel word nbrRegionName_; //- Interpolation method - meshToMesh::interpolationMethod interpolationMethod_; + word interpolationMethod_; //- Mesh to mesh interpolation object mutable autoPtr meshInterpPtr_; diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index cfc2890cc8..137005c1e5 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -39,103 +39,6 @@ namespace Foam // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -Foam::word Foam::AMIInterpolation::interpolationMethodToWord -( - const interpolationMethod& im -) -{ - word method = "unknown-interpolationMethod"; - - switch (im) - { - case imDirect: - { - method = "directAMI"; - break; - } - case imMapNearest: - { - method = "mapNearestAMI"; - break; - } - case imFaceAreaWeight: - { - method = "faceAreaWeightAMI"; - break; - } - case imPartialFaceAreaWeight: - { - method = "partialFaceAreaWeightAMI"; - break; - } - case imSweptFaceAreaWeight: - { - method = "sweptFaceAreaWeightAMI"; - break; - } - default: - { - FatalErrorInFunction - << "Unhandled interpolationMethod enumeration " << method - << abort(FatalError); - } - } - - return method; -} - - -typename Foam::AMIInterpolation::interpolationMethod -Foam::AMIInterpolation::wordTointerpolationMethod(const word& im) -{ - interpolationMethod method = imDirect; - - wordList methods - ( - IStringStream - ( - "(" - "directAMI " - "mapNearestAMI " - "faceAreaWeightAMI " - "partialFaceAreaWeightAMI " - "sweptFaceAreaWeightAMI" - ")" - )() - ); - - if (im == "directAMI") - { - method = imDirect; - } - else if (im == "mapNearestAMI") - { - method = imMapNearest; - } - else if (im == "faceAreaWeightAMI") - { - method = imFaceAreaWeight; - } - else if (im == "partialFaceAreaWeightAMI") - { - method = imPartialFaceAreaWeight; - } - else if (im == "sweptFaceAreaWeightAMI") - { - method = imSweptFaceAreaWeight; - } - else - { - FatalErrorInFunction - << "Invalid interpolationMethod " << im - << ". Valid methods are:" << methods - << exit(FatalError); - } - - return method; -} - - Foam::tmp Foam::AMIInterpolation::patchMagSf ( const primitivePatch& patch, @@ -652,37 +555,6 @@ void Foam::AMIInterpolation::constructFromSurface // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::AMIInterpolation::AMIInterpolation -( - const primitivePatch& srcPatch, - const primitivePatch& tgtPatch, - const faceAreaIntersect::triangulationMode& triMode, - const bool requireMatch, - const interpolationMethod& method, - const scalar lowWeightCorrection, - const bool reverseTarget, - const bool report -) -: - methodName_(interpolationMethodToWord(method)), - reverseTarget_(reverseTarget), - requireMatch_(requireMatch), - singlePatchProc_(-999), - lowWeightCorrection_(lowWeightCorrection), - srcAddress_(), - srcWeights_(), - srcWeightsSum_(), - tgtAddress_(), - tgtWeights_(), - tgtWeightsSum_(), - triMode_(triMode), - srcMapPtr_(nullptr), - tgtMapPtr_(nullptr) -{ - update(srcPatch, tgtPatch, report); -} - - Foam::AMIInterpolation::AMIInterpolation ( const primitivePatch& srcPatch, @@ -714,38 +586,6 @@ Foam::AMIInterpolation::AMIInterpolation } -Foam::AMIInterpolation::AMIInterpolation -( - const primitivePatch& srcPatch, - const primitivePatch& tgtPatch, - const autoPtr& surfPtr, - const faceAreaIntersect::triangulationMode& triMode, - const bool requireMatch, - const interpolationMethod& method, - const scalar lowWeightCorrection, - const bool reverseTarget, - const bool report -) -: - methodName_(interpolationMethodToWord(method)), - reverseTarget_(reverseTarget), - requireMatch_(requireMatch), - singlePatchProc_(-999), - lowWeightCorrection_(lowWeightCorrection), - srcAddress_(), - srcWeights_(), - srcWeightsSum_(), - tgtAddress_(), - tgtWeights_(), - tgtWeightsSum_(), - triMode_(triMode), - srcMapPtr_(nullptr), - tgtMapPtr_(nullptr) -{ - constructFromSurface(srcPatch, tgtPatch, surfPtr, report); -} - - Foam::AMIInterpolation::AMIInterpolation ( const primitivePatch& srcPatch, diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index 4d58f6a078..c5331ecb46 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,6 +55,7 @@ SourceFiles #include "boolList.H" #include "primitivePatch.H" #include "faceAreaIntersect.H" +#include "faceAreaWeightAMI.H" #include "globalIndex.H" #include "ops.H" @@ -69,42 +70,6 @@ namespace Foam class AMIInterpolation { -public: - - // Public data types - - //- Enumeration specifying interpolation method - enum interpolationMethod - { - imDirect, - imMapNearest, - imFaceAreaWeight, - imPartialFaceAreaWeight, - imSweptFaceAreaWeight - }; - - //- Convert interpolationMethod to word representation - static word interpolationMethodToWord - ( - const interpolationMethod& method - ); - - //- Convert word to interpolationMethod - static interpolationMethod wordTointerpolationMethod - ( - const word& method - ); - - //- Calculate the patch face magnitudes for the given tri-mode - static tmp patchMagSf - ( - const primitivePatch& patch, - const faceAreaIntersect::triangulationMode triMode - ); - - -private: - // Private Data //- Interpolation method @@ -304,21 +269,7 @@ public: const primitivePatch& tgtPatch, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch = true, - const interpolationMethod& method = imFaceAreaWeight, - const scalar lowWeightCorrection = -1, - const bool reverseTarget = false, - const bool report = true - ); - - //- Construct from components - AMIInterpolation - ( - const primitivePatch& srcPatch, - const primitivePatch& tgtPatch, - const faceAreaIntersect::triangulationMode& triMode, - const bool requireMatch = true, - const word& methodName = - interpolationMethodToWord(imFaceAreaWeight), + const word& methodName = faceAreaWeightAMI::typeName, const scalar lowWeightCorrection = -1, const bool reverseTarget = false, const bool report = true @@ -332,22 +283,7 @@ public: const autoPtr& surf, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch = true, - const interpolationMethod& method = imFaceAreaWeight, - const scalar lowWeightCorrection = -1, - const bool reverseTarget = false, - const bool report = true - ); - - //- Construct from components, with projection surface - AMIInterpolation - ( - const primitivePatch& srcPatch, - const primitivePatch& tgtPatch, - const autoPtr& surf, - const faceAreaIntersect::triangulationMode& triMode, - const bool requireMatch = true, - const word& methodName = - interpolationMethodToWord(imFaceAreaWeight), + const word& methodName = faceAreaWeightAMI::typeName, const scalar lowWeightCorrection = -1, const bool reverseTarget = false, const bool report = true @@ -591,6 +527,13 @@ public: ) const; + //- Calculate the patch face magnitudes for the given tri-mode + static tmp patchMagSf + ( + const primitivePatch& patch, + const faceAreaIntersect::triangulationMode triMode + ); + // Checks diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C index 3f93ebda52..6a5f11348f 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "cyclicACMIPolyPatch.H" +#include "partialFaceAreaWeightAMI.H" #include "SubField.H" #include "Time.H" #include "addToRunTimeSelectionTable.H" @@ -240,7 +241,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch bm, patchType, false, - AMIInterpolation::imPartialFaceAreaWeight + partialFaceAreaWeightAMI::typeName ), nonOverlapPatchName_(word::null), nonOverlapPatchID_(-1), @@ -270,7 +271,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch bm, patchType, false, - AMIInterpolation::imPartialFaceAreaWeight + partialFaceAreaWeightAMI::typeName ), nonOverlapPatchName_(dict.lookup("nonOverlapPatch")), nonOverlapPatchID_(-1), diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C index 46f8e10142..523a57ab7f 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.C @@ -245,7 +245,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch const polyBoundaryMesh& bm, const word& patchType, const bool AMIRequireMatch, - const AMIInterpolation::interpolationMethod AMIMethod + const word& AMIMethod ) : coupledPolyPatch(name, size, start, index, bm, patchType), @@ -274,7 +274,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch const polyBoundaryMesh& bm, const word& patchType, const bool AMIRequireMatch, - const AMIInterpolation::interpolationMethod AMIMethod + const word& AMIMethod ) : coupledPolyPatch(name, dict, index, bm, patchType), @@ -287,15 +287,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch AMIReverse_(dict.lookupOrDefault("flipNormals", false)), AMIRequireMatch_(AMIRequireMatch), AMILowWeightCorrection_(dict.lookupOrDefault("lowWeightCorrection", -1.0)), - AMIMethod_ - ( - dict.found("method") - ? AMIInterpolation::wordTointerpolationMethod - ( - dict.lookup("method") - ) - : AMIMethod - ), + AMIMethod_(dict.lookupOrDefault("method", AMIMethod)), surfPtr_(nullptr), surfDict_(dict.subOrEmptyDict("surface")) { @@ -742,7 +734,7 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const ( os, "method", - AMIInterpolation::interpolationMethodToWord(AMIMethod_) + AMIMethod_ ); if (!surfDict_.empty()) diff --git a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H index aafa24228d..8d04642af0 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H +++ b/src/meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H @@ -38,6 +38,7 @@ SourceFiles #include "coupledPolyPatch.H" #include "cyclicTransform.H" #include "AMIInterpolation.H" +#include "faceAreaWeightAMI.H" #include "polyBoundaryMesh.H" #include "coupleGroupIdentifier.H" @@ -84,7 +85,7 @@ protected: const scalar AMILowWeightCorrection_; //- AMI Method - const AMIInterpolation::interpolationMethod AMIMethod_; + const word AMIMethod_; //- Projection surface mutable autoPtr surfPtr_; @@ -144,8 +145,7 @@ public: const polyBoundaryMesh& bm, const word& patchType, const bool AMIRequireMatch = true, - const AMIInterpolation::interpolationMethod AMIMethod = - AMIInterpolation::imFaceAreaWeight + const word& AMIMethod = faceAreaWeightAMI::typeName ); //- Construct from dictionary @@ -157,8 +157,7 @@ public: const polyBoundaryMesh& bm, const word& patchType, const bool AMIRequireMatch = true, - const AMIInterpolation::interpolationMethod AMIMethod = - AMIInterpolation::imFaceAreaWeight + const word& AMIMethod = faceAreaWeightAMI::typeName ); //- Construct as copy, resetting the boundary mesh diff --git a/src/meshTools/AMIInterpolation/patches/cyclicRepeatAMI/cyclicRepeatAMIPolyPatch/cyclicRepeatAMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicRepeatAMI/cyclicRepeatAMIPolyPatch/cyclicRepeatAMIPolyPatch.C index ee9fd6b37b..e285311d42 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicRepeatAMI/cyclicRepeatAMIPolyPatch/cyclicRepeatAMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicRepeatAMI/cyclicRepeatAMIPolyPatch/cyclicRepeatAMIPolyPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "cyclicRepeatAMIPolyPatch.H" +#include "partialFaceAreaWeightAMI.H" #include "SubField.H" #include "Time.H" #include "addToRunTimeSelectionTable.H" @@ -214,7 +215,7 @@ void Foam::cyclicRepeatAMIPolyPatch::resetAMI() const nbrPatch, faceAreaIntersect::tmMesh, false, - AMIInterpolation::imPartialFaceAreaWeight, + partialFaceAreaWeightAMI::typeName, AMILowWeightCorrection_, AMIReverse_, false @@ -234,7 +235,7 @@ void Foam::cyclicRepeatAMIPolyPatch::resetAMI() const nbrPatch, faceAreaIntersect::tmMesh, false, - AMIInterpolation::imPartialFaceAreaWeight, + partialFaceAreaWeightAMI::typeName, AMILowWeightCorrection_, AMIReverse_, false @@ -254,7 +255,7 @@ void Foam::cyclicRepeatAMIPolyPatch::resetAMI() const nbrPatch, faceAreaIntersect::tmMesh, false, - AMIInterpolation::imPartialFaceAreaWeight, + partialFaceAreaWeightAMI::typeName, AMILowWeightCorrection_, AMIReverse_, false @@ -321,7 +322,7 @@ Foam::cyclicRepeatAMIPolyPatch::cyclicRepeatAMIPolyPatch bm, patchType, false, - AMIInterpolation::imFaceAreaWeight + faceAreaWeightAMI::typeName ), transformPatchName_(word::null), transformPatchID_(-1) @@ -348,7 +349,7 @@ Foam::cyclicRepeatAMIPolyPatch::cyclicRepeatAMIPolyPatch bm, patchType, false, - AMIInterpolation::imFaceAreaWeight + faceAreaWeightAMI::typeName ), transformPatchName_(dict.lookup("transformPatch")), transformPatchID_(-1) diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 3248ab35a4..40bd6aa715 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -853,7 +853,7 @@ void Foam::mappedPatchBase::calcAMI() const surfPtr(), faceAreaIntersect::tmMesh, true, - AMIInterpolation::imFaceAreaWeight, + faceAreaWeightAMI::typeName, -1, AMIReverse_ ) diff --git a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C index c185dc35b4..8a542b2316 100644 --- a/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C +++ b/src/meshTools/regionCoupled/patches/regionCoupledPolyPatch/regionCoupledBase.C @@ -92,7 +92,7 @@ void Foam::regionCoupledBase::resetAMI() const surfPtr(), faceAreaIntersect::tmMesh, true, - AMIInterpolation::imFaceAreaWeight, + faceAreaWeightAMI::typeName, -1, AMIReverse_ ) diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C index 49ed34560d..9d64864655 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.C +++ b/src/regionModels/regionModel/regionModel/regionModel.C @@ -203,7 +203,7 @@ Foam::regionModels::regionModel::interRegionAMI nbrP, faceAreaIntersect::tmMesh, true, - AMIInterpolation::imFaceAreaWeight, + faceAreaWeightAMI::typeName, -1, flip ) @@ -246,7 +246,7 @@ Foam::regionModels::regionModel::interRegionAMI nbrP, faceAreaIntersect::tmMesh, true, - AMIInterpolation::imFaceAreaWeight, + faceAreaWeightAMI::typeName, -1, flip ) diff --git a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C index 20842e51da..bc222e3d2e 100644 --- a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C +++ b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "cellVolumeWeightMethod.H" +#include "faceAreaWeightAMI.H" #include "indexedOctree.H" #include "treeDataCell.H" #include "addToRunTimeSelectionTable.H" @@ -313,6 +314,12 @@ Foam::cellVolumeWeightMethod::~cellVolumeWeightMethod() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +const Foam::word& Foam::cellVolumeWeightMethod::AMImethod() const +{ + return faceAreaWeightAMI::typeName; +} + + void Foam::cellVolumeWeightMethod::calculate ( labelListList& srcToTgtAddr, diff --git a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H index 438b3b2960..1b9f9a5314 100644 --- a/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H +++ b/src/sampling/meshToMesh/calcMethod/cellVolumeWeight/cellVolumeWeightMethod.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -114,6 +114,9 @@ public: // Member Functions + //- Return the corresponding AMI method for patch interpolation + virtual const word& AMImethod() const; + // Evaluate //- Calculate addressing and weights diff --git a/src/sampling/meshToMesh/calcMethod/direct/directMethod.C b/src/sampling/meshToMesh/calcMethod/direct/directMethod.C index a56af3ce18..a5bc2d1cb4 100644 --- a/src/sampling/meshToMesh/calcMethod/direct/directMethod.C +++ b/src/sampling/meshToMesh/calcMethod/direct/directMethod.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "directMethod.H" +#include "directAMI.H" #include "indexedOctree.H" #include "treeDataCell.H" #include "addToRunTimeSelectionTable.H" @@ -237,6 +238,12 @@ Foam::directMethod::~directMethod() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +const Foam::word& Foam::directMethod::AMImethod() const +{ + return directAMI::typeName; +} + + void Foam::directMethod::calculate ( labelListList& srcToTgtAddr, diff --git a/src/sampling/meshToMesh/calcMethod/direct/directMethod.H b/src/sampling/meshToMesh/calcMethod/direct/directMethod.H index 2a06d37450..4d6e1afa28 100644 --- a/src/sampling/meshToMesh/calcMethod/direct/directMethod.H +++ b/src/sampling/meshToMesh/calcMethod/direct/directMethod.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -119,6 +119,9 @@ public: // Member Functions + //- Return the corresponding AMI method for patch interpolation + virtual const word& AMImethod() const; + // Evaluate //- Calculate addressing and weights diff --git a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C index 4daef3f002..cb97cfa12a 100644 --- a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C +++ b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "mapNearestMethod.H" +#include "mapNearestAMI.H" #include "pointIndexHit.H" #include "indexedOctree.H" #include "treeDataCell.H" @@ -345,6 +346,12 @@ Foam::mapNearestMethod::~mapNearestMethod() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +const Foam::word& Foam::mapNearestMethod::AMImethod() const +{ + return mapNearestAMI::typeName; +} + + void Foam::mapNearestMethod::calculate ( labelListList& srcToTgtAddr, diff --git a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.H b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.H index 3c15045dfb..c97aa4f164 100644 --- a/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.H +++ b/src/sampling/meshToMesh/calcMethod/mapNearest/mapNearestMethod.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -132,6 +132,9 @@ public: // Member Functions + //- Return the corresponding AMI method for patch interpolation + virtual const word& AMImethod() const; + // Evaluate //- Calculate addressing and weights diff --git a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H index abc2e521a6..72d83e6b81 100644 --- a/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H +++ b/src/sampling/meshToMesh/calcMethod/meshToMeshMethod/meshToMeshMethod.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -145,6 +145,9 @@ public: // Member Functions + //- Return the corresponding AMI method for patch interpolation + virtual const word& AMImethod() const = 0; + // Evaluate //- Calculate addressing and weights diff --git a/src/sampling/meshToMesh/meshToMesh.C b/src/sampling/meshToMesh/meshToMesh.C index 934a910bb6..6e8821291f 100644 --- a/src/sampling/meshToMesh/meshToMesh.C +++ b/src/sampling/meshToMesh/meshToMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,21 +33,6 @@ License namespace Foam { defineTypeNameAndDebug(meshToMesh, 0); - - template<> - const char* Foam::NamedEnum - < - Foam::meshToMesh::interpolationMethod, - 3 - >::names[] = - { - "direct", - "mapNearest", - "cellVolumeWeight" - }; - - const NamedEnum - meshToMesh::interpolationMethodNames_; } @@ -227,7 +212,7 @@ void Foam::meshToMesh::normaliseWeights } -void Foam::meshToMesh::calcAddressing +Foam::word Foam::meshToMesh::calcAddressing ( const word& methodName, const polyMesh& src, @@ -258,10 +243,12 @@ void Foam::meshToMesh::calcAddressing { methodPtr->writeConnectivity(src, tgt, srcToTgtCellAddr_); } + + return methodPtr->AMImethod(); } -void Foam::meshToMesh::calculate(const word& methodName) +Foam::word Foam::meshToMesh::calculate(const word& methodName) { Info<< "Creating mesh-to-mesh addressing for " << srcRegion_.name() << " and " << tgtRegion_.name() << " regions using " @@ -269,6 +256,8 @@ void Foam::meshToMesh::calculate(const word& methodName) singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_); + word amiMethod; + if (singleMeshProc_ == -1) { // create global indexing for src and tgt meshes @@ -352,7 +341,7 @@ void Foam::meshToMesh::calculate(const word& methodName) } } - calcAddressing(methodName, srcRegion_, newTgt); + amiMethod = calcAddressing(methodName, srcRegion_, newTgt); // per source cell the target cell address in newTgt mesh forAll(srcToTgtCellAddr_, i) @@ -437,7 +426,7 @@ void Foam::meshToMesh::calculate(const word& methodName) } else { - calcAddressing(methodName, srcRegion_, tgtRegion_); + amiMethod = calcAddressing(methodName, srcRegion_, tgtRegion_); normaliseWeights ( @@ -455,38 +444,8 @@ void Foam::meshToMesh::calculate(const word& methodName) } Info<< " Overlap volume: " << V_ << endl; -} - -Foam::AMIInterpolation::interpolationMethod -Foam::meshToMesh::interpolationMethodAMI(const interpolationMethod method) -{ - switch (method) - { - case imDirect: - { - return AMIInterpolation::imDirect; - break; - } - case imMapNearest: - { - return AMIInterpolation::imMapNearest; - break; - } - case imCellVolumeWeight: - { - return AMIInterpolation::imFaceAreaWeight; - break; - } - default: - { - FatalErrorInFunction - << "Unhandled enumeration " << method - << abort(FatalError); - } - } - - return AMIInterpolation::imDirect; + return amiMethod; } @@ -539,7 +498,6 @@ void Foam::meshToMesh::calculatePatchAMIs(const word& AMIMethodName) void Foam::meshToMesh::constructNoCuttingPatches ( const word& methodName, - const word& AMIMethodName, const bool interpAllPatches ) { @@ -583,17 +541,16 @@ void Foam::meshToMesh::constructNoCuttingPatches } // calculate volume addressing and weights - calculate(methodName); + const word amiMethod = calculate(methodName); // calculate patch addressing and weights - calculatePatchAMIs(AMIMethodName); + calculatePatchAMIs(amiMethod); } void Foam::meshToMesh::constructFromCuttingPatches ( const word& methodName, - const word& AMIMethodName, const HashTable& patchMap, const wordList& cuttingPatches ) @@ -616,10 +573,10 @@ void Foam::meshToMesh::constructFromCuttingPatches } // calculate volume addressing and weights - calculate(methodName); + const word amiMethod = calculate(methodName); // calculate patch addressing and weights - calculatePatchAMIs(AMIMethodName); + calculatePatchAMIs(amiMethod); // set IDs of cutting patches on target mesh cuttingPatches_.setSize(cuttingPatches.size()); @@ -637,7 +594,7 @@ Foam::meshToMesh::meshToMesh ( const polyMesh& src, const polyMesh& tgt, - const interpolationMethod& method, + const word& methodName, bool interpAllPatches ) : @@ -656,15 +613,7 @@ Foam::meshToMesh::meshToMesh srcMapPtr_(nullptr), tgtMapPtr_(nullptr) { - constructNoCuttingPatches - ( - interpolationMethodNames_[method], - AMIInterpolation::interpolationMethodToWord - ( - interpolationMethodAMI(method) - ), - interpAllPatches - ); + constructNoCuttingPatches(methodName, interpAllPatches); } @@ -673,72 +622,6 @@ Foam::meshToMesh::meshToMesh const polyMesh& src, const polyMesh& tgt, const word& methodName, - const word& AMIMethodName, - bool interpAllPatches -) -: - srcRegion_(src), - tgtRegion_(tgt), - srcPatchID_(), - tgtPatchID_(), - patchAMIs_(), - cuttingPatches_(), - srcToTgtCellAddr_(), - tgtToSrcCellAddr_(), - srcToTgtCellWght_(), - tgtToSrcCellWght_(), - V_(0.0), - singleMeshProc_(-1), - srcMapPtr_(nullptr), - tgtMapPtr_(nullptr) -{ - constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches); -} - - -Foam::meshToMesh::meshToMesh -( - const polyMesh& src, - const polyMesh& tgt, - const interpolationMethod& method, - const HashTable& patchMap, - const wordList& cuttingPatches -) -: - srcRegion_(src), - tgtRegion_(tgt), - srcPatchID_(), - tgtPatchID_(), - patchAMIs_(), - cuttingPatches_(), - srcToTgtCellAddr_(), - tgtToSrcCellAddr_(), - srcToTgtCellWght_(), - tgtToSrcCellWght_(), - V_(0.0), - singleMeshProc_(-1), - srcMapPtr_(nullptr), - tgtMapPtr_(nullptr) -{ - constructFromCuttingPatches - ( - interpolationMethodNames_[method], - AMIInterpolation::interpolationMethodToWord - ( - interpolationMethodAMI(method) - ), - patchMap, - cuttingPatches - ); -} - - -Foam::meshToMesh::meshToMesh -( - const polyMesh& src, - const polyMesh& tgt, - const word& methodName, // internal mapping - const word& AMIMethodName, // boundary mapping const HashTable& patchMap, const wordList& cuttingPatches ) @@ -761,7 +644,6 @@ Foam::meshToMesh::meshToMesh constructFromCuttingPatches ( methodName, - AMIMethodName, patchMap, cuttingPatches ); diff --git a/src/sampling/meshToMesh/meshToMesh.H b/src/sampling/meshToMesh/meshToMesh.H index c6dfea2935..0aada6e4ac 100644 --- a/src/sampling/meshToMesh/meshToMesh.H +++ b/src/sampling/meshToMesh/meshToMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -60,23 +60,6 @@ namespace Foam class meshToMesh { -public: - - // Public data types - - //- Enumeration specifying interpolation method - enum interpolationMethod - { - imDirect, - imMapNearest, - imCellVolumeWeight - }; - - static const NamedEnum - interpolationMethodNames_; - -private: - // Private Data //- Reference to the source mesh @@ -164,7 +147,7 @@ private: //- Calculate the addressing between overlapping regions of src and tgt // meshes - void calcAddressing + word calcAddressing ( const word& methodName, const polyMesh& src, @@ -172,7 +155,8 @@ private: ); //- Calculate - main driver function - void calculate(const word& methodName); + // Returns the corresponding AMImethod + word calculate(const word& methodName); //- Calculate patch overlap void calculatePatchAMIs(const word& amiMethodName); @@ -181,7 +165,6 @@ private: void constructNoCuttingPatches ( const word& methodName, - const word& AMIMethodName, const bool interpAllPatches ); @@ -189,7 +172,6 @@ private: void constructFromCuttingPatches ( const word& methodName, - const word& AMIMethodName, const HashTable& patchMap, const wordList& cuttingPatches ); @@ -260,12 +242,12 @@ public: // Constructors - //- Construct from source and target meshes + //- Construct from source and target meshes, generic mapping methods meshToMesh ( const polyMesh& src, const polyMesh& tgt, - const interpolationMethod& method, + const word& methodName, const bool interpAllPatches = true ); @@ -274,28 +256,7 @@ public: ( const polyMesh& src, const polyMesh& tgt, - const word& methodName, // internal mapping - const word& AMIMethodName, // boundary mapping - const bool interpAllPatches = true - ); - - //- Construct from source and target meshes - meshToMesh - ( - const polyMesh& src, - const polyMesh& tgt, - const interpolationMethod& method, - const HashTable& patchMap, - const wordList& cuttingPatches - ); - - //- Construct from source and target meshes, generic mapping methods - meshToMesh - ( - const polyMesh& src, - const polyMesh& tgt, - const word& methodName, // internal mapping - const word& AMIMethodName, // boundary mapping + const word& methodName, const HashTable& patchMap, const wordList& cuttingPatches ); @@ -333,10 +294,6 @@ public: //- Return const access to the overlap volume inline scalar V() const; - //- Conversion between mesh and patch interpolation methods - static AMIInterpolation::interpolationMethod - interpolationMethodAMI(const interpolationMethod method); - // Evaluation diff --git a/src/sampling/meshToMesh/weightedFvPatchFieldMapper.H b/src/sampling/meshToMesh/weightedFvPatchFieldMapper.H deleted file mode 100644 index b1887f7718..0000000000 --- a/src/sampling/meshToMesh/weightedFvPatchFieldMapper.H +++ /dev/null @@ -1,121 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2015-2019 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::weightedFvPatchFieldMapper - -Description - FieldMapper with weighted mapping. - -\*---------------------------------------------------------------------------*/ - -#ifndef weightedFvPatchFieldMapper_H -#define weightedFvPatchFieldMapper_H - -#include "fvPatchFieldMapper.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class weightedFvPatchFieldMapper Declaration -\*---------------------------------------------------------------------------*/ - -class weightedFvPatchFieldMapper -: - public generalFvPatchFieldMapper -{ - // Private Data - - const labelListList& addressing_; - - const scalarListList& weights_; - - bool hasUnmapped_; - - -public: - - // Constructors - - //- Construct given addressing - weightedFvPatchFieldMapper - ( - const labelListList& addressing, - const scalarListList& weights - ) - : - addressing_(addressing), - weights_(weights), - hasUnmapped_(false) - { - forAll(addressing_, i) - { - if (addressing_[i].size() == 0) - { - hasUnmapped_ = true; - } - } - } - - - //- Destructor - virtual ~weightedFvPatchFieldMapper() - {} - - - // Member Functions - - virtual bool direct() const - { - return false; - } - - virtual bool hasUnmapped() const - { - return hasUnmapped_; - } - - virtual const labelListList& addressing() const - { - return addressing_; - } - - virtual const scalarListList& weights() const - { - return weights_; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* //