AMIMethod, mapNearestMethod: Removed unnecessary and inconsistent name enumerations

Both AMIMethod and mapNearestMethod are run-time selectable using the standard
OpenFOAM constructor tables, they do not need a separate enumeration-based
selection method which requires duplicate constructors and a lot of other
clutter.
This commit is contained in:
Henry Weller
2021-09-03 16:27:39 +01:00
parent c180395e0c
commit 531904ebae
22 changed files with 113 additions and 589 deletions

View File

@ -32,6 +32,7 @@ Description
#include "fvCFD.H" #include "fvCFD.H"
#include "meshToMesh.H" #include "meshToMesh.H"
#include "cellVolumeWeightMethod.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "MapMeshes.H" #include "MapMeshes.H"
@ -41,7 +42,7 @@ void mapConsistentMesh
( (
const fvMesh& meshSource, const fvMesh& meshSource,
const fvMesh& meshTarget, const fvMesh& meshTarget,
const meshToMesh::interpolationMethod& mapMethod, const word& mapMethod,
const bool subtract, const bool subtract,
const HashSet<word>& selectedFields, const HashSet<word>& selectedFields,
const bool noLagrangian const bool noLagrangian
@ -79,7 +80,7 @@ void mapSubMesh
const fvMesh& meshTarget, const fvMesh& meshTarget,
const HashTable<word>& patchMap, const HashTable<word>& patchMap,
const wordList& cuttingPatches, const wordList& cuttingPatches,
const meshToMesh::interpolationMethod& mapMethod, const word& mapMethod,
const bool subtract, const bool subtract,
const HashSet<word>& selectedFields, const HashSet<word>& selectedFields,
const bool noLagrangian const bool noLagrangian
@ -231,16 +232,15 @@ int main(int argc, char *argv[])
const bool consistent = args.optionFound("consistent"); const bool consistent = args.optionFound("consistent");
meshToMesh::interpolationMethod mapMethod = const word mapMethod
meshToMesh::imCellVolumeWeight; (
args.optionLookupOrDefault<word>
if (args.optionFound("mapMethod")) (
{ "mapMethod",
mapMethod = meshToMesh::interpolationMethodNames_[args["mapMethod"]]; cellVolumeWeightMethod::typeName
)
Info<< "Mapping method: " );
<< meshToMesh::interpolationMethodNames_[mapMethod] << endl; Info<< "Mapping method: " << mapMethod << endl;
}
const bool subtract = args.optionFound("subtract"); const bool subtract = args.optionFound("subtract");
if (subtract) if (subtract)

View File

@ -25,6 +25,7 @@ License
#include "interRegionModel.H" #include "interRegionModel.H"
#include "fvModels.H" #include "fvModels.H"
#include "directMethod.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,11 +51,7 @@ void Foam::fv::interRegionModel::readCoeffs()
"nbrRegionName" "nbrRegionName"
}); });
interpolationMethod_ = coeffs().lookup("interpolationMethod") >> interpolationMethod_;
meshToMesh::interpolationMethodNames_.read
(
coeffs().lookup("interpolationMethod")
);
} }
@ -143,7 +140,7 @@ Foam::fv::interRegionModel::interRegionModel
fvModel(name, modelType, dict, mesh), fvModel(name, modelType, dict, mesh),
master_(false), master_(false),
nbrRegionName_(word::null), nbrRegionName_(word::null),
interpolationMethod_(meshToMesh::imDirect), interpolationMethod_(directMethod::typeName),
meshInterpPtr_() meshInterpPtr_()
{ {
readCoeffs(); readCoeffs();

View File

@ -62,7 +62,7 @@ class interRegionModel
word nbrRegionName_; word nbrRegionName_;
//- Interpolation method //- Interpolation method
meshToMesh::interpolationMethod interpolationMethod_; word interpolationMethod_;
//- Mesh to mesh interpolation object //- Mesh to mesh interpolation object
mutable autoPtr<meshToMesh> meshInterpPtr_; mutable autoPtr<meshToMesh> meshInterpPtr_;

View File

@ -39,103 +39,6 @@ namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * 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::scalarField> Foam::AMIInterpolation::patchMagSf Foam::tmp<Foam::scalarField> Foam::AMIInterpolation::patchMagSf
( (
const primitivePatch& patch, const primitivePatch& patch,
@ -652,37 +555,6 @@ void Foam::AMIInterpolation::constructFromSurface
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * 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 Foam::AMIInterpolation::AMIInterpolation
( (
const primitivePatch& srcPatch, const primitivePatch& srcPatch,
@ -714,38 +586,6 @@ Foam::AMIInterpolation::AMIInterpolation
} }
Foam::AMIInterpolation::AMIInterpolation
(
const primitivePatch& srcPatch,
const primitivePatch& tgtPatch,
const autoPtr<searchableSurface>& 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 Foam::AMIInterpolation::AMIInterpolation
( (
const primitivePatch& srcPatch, const primitivePatch& srcPatch,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,6 +55,7 @@ SourceFiles
#include "boolList.H" #include "boolList.H"
#include "primitivePatch.H" #include "primitivePatch.H"
#include "faceAreaIntersect.H" #include "faceAreaIntersect.H"
#include "faceAreaWeightAMI.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "ops.H" #include "ops.H"
@ -69,42 +70,6 @@ namespace Foam
class AMIInterpolation 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<scalarField> patchMagSf
(
const primitivePatch& patch,
const faceAreaIntersect::triangulationMode triMode
);
private:
// Private Data // Private Data
//- Interpolation method //- Interpolation method
@ -304,21 +269,7 @@ public:
const primitivePatch& tgtPatch, const primitivePatch& tgtPatch,
const faceAreaIntersect::triangulationMode& triMode, const faceAreaIntersect::triangulationMode& triMode,
const bool requireMatch = true, const bool requireMatch = true,
const interpolationMethod& method = imFaceAreaWeight, const word& methodName = faceAreaWeightAMI::typeName,
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 scalar lowWeightCorrection = -1, const scalar lowWeightCorrection = -1,
const bool reverseTarget = false, const bool reverseTarget = false,
const bool report = true const bool report = true
@ -332,22 +283,7 @@ public:
const autoPtr<searchableSurface>& surf, const autoPtr<searchableSurface>& surf,
const faceAreaIntersect::triangulationMode& triMode, const faceAreaIntersect::triangulationMode& triMode,
const bool requireMatch = true, const bool requireMatch = true,
const interpolationMethod& method = imFaceAreaWeight, const word& methodName = faceAreaWeightAMI::typeName,
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<searchableSurface>& surf,
const faceAreaIntersect::triangulationMode& triMode,
const bool requireMatch = true,
const word& methodName =
interpolationMethodToWord(imFaceAreaWeight),
const scalar lowWeightCorrection = -1, const scalar lowWeightCorrection = -1,
const bool reverseTarget = false, const bool reverseTarget = false,
const bool report = true const bool report = true
@ -591,6 +527,13 @@ public:
) )
const; const;
//- Calculate the patch face magnitudes for the given tri-mode
static tmp<scalarField> patchMagSf
(
const primitivePatch& patch,
const faceAreaIntersect::triangulationMode triMode
);
// Checks // Checks

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cyclicACMIPolyPatch.H" #include "cyclicACMIPolyPatch.H"
#include "partialFaceAreaWeightAMI.H"
#include "SubField.H" #include "SubField.H"
#include "Time.H" #include "Time.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -240,7 +241,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
bm, bm,
patchType, patchType,
false, false,
AMIInterpolation::imPartialFaceAreaWeight partialFaceAreaWeightAMI::typeName
), ),
nonOverlapPatchName_(word::null), nonOverlapPatchName_(word::null),
nonOverlapPatchID_(-1), nonOverlapPatchID_(-1),
@ -270,7 +271,7 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
bm, bm,
patchType, patchType,
false, false,
AMIInterpolation::imPartialFaceAreaWeight partialFaceAreaWeightAMI::typeName
), ),
nonOverlapPatchName_(dict.lookup("nonOverlapPatch")), nonOverlapPatchName_(dict.lookup("nonOverlapPatch")),
nonOverlapPatchID_(-1), nonOverlapPatchID_(-1),

View File

@ -245,7 +245,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
const polyBoundaryMesh& bm, const polyBoundaryMesh& bm,
const word& patchType, const word& patchType,
const bool AMIRequireMatch, const bool AMIRequireMatch,
const AMIInterpolation::interpolationMethod AMIMethod const word& AMIMethod
) )
: :
coupledPolyPatch(name, size, start, index, bm, patchType), coupledPolyPatch(name, size, start, index, bm, patchType),
@ -274,7 +274,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
const polyBoundaryMesh& bm, const polyBoundaryMesh& bm,
const word& patchType, const word& patchType,
const bool AMIRequireMatch, const bool AMIRequireMatch,
const AMIInterpolation::interpolationMethod AMIMethod const word& AMIMethod
) )
: :
coupledPolyPatch(name, dict, index, bm, patchType), coupledPolyPatch(name, dict, index, bm, patchType),
@ -287,15 +287,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
AMIReverse_(dict.lookupOrDefault<bool>("flipNormals", false)), AMIReverse_(dict.lookupOrDefault<bool>("flipNormals", false)),
AMIRequireMatch_(AMIRequireMatch), AMIRequireMatch_(AMIRequireMatch),
AMILowWeightCorrection_(dict.lookupOrDefault("lowWeightCorrection", -1.0)), AMILowWeightCorrection_(dict.lookupOrDefault("lowWeightCorrection", -1.0)),
AMIMethod_ AMIMethod_(dict.lookupOrDefault("method", AMIMethod)),
(
dict.found("method")
? AMIInterpolation::wordTointerpolationMethod
(
dict.lookup("method")
)
: AMIMethod
),
surfPtr_(nullptr), surfPtr_(nullptr),
surfDict_(dict.subOrEmptyDict("surface")) surfDict_(dict.subOrEmptyDict("surface"))
{ {
@ -742,7 +734,7 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
( (
os, os,
"method", "method",
AMIInterpolation::interpolationMethodToWord(AMIMethod_) AMIMethod_
); );
if (!surfDict_.empty()) if (!surfDict_.empty())

View File

@ -38,6 +38,7 @@ SourceFiles
#include "coupledPolyPatch.H" #include "coupledPolyPatch.H"
#include "cyclicTransform.H" #include "cyclicTransform.H"
#include "AMIInterpolation.H" #include "AMIInterpolation.H"
#include "faceAreaWeightAMI.H"
#include "polyBoundaryMesh.H" #include "polyBoundaryMesh.H"
#include "coupleGroupIdentifier.H" #include "coupleGroupIdentifier.H"
@ -84,7 +85,7 @@ protected:
const scalar AMILowWeightCorrection_; const scalar AMILowWeightCorrection_;
//- AMI Method //- AMI Method
const AMIInterpolation::interpolationMethod AMIMethod_; const word AMIMethod_;
//- Projection surface //- Projection surface
mutable autoPtr<searchableSurface> surfPtr_; mutable autoPtr<searchableSurface> surfPtr_;
@ -144,8 +145,7 @@ public:
const polyBoundaryMesh& bm, const polyBoundaryMesh& bm,
const word& patchType, const word& patchType,
const bool AMIRequireMatch = true, const bool AMIRequireMatch = true,
const AMIInterpolation::interpolationMethod AMIMethod = const word& AMIMethod = faceAreaWeightAMI::typeName
AMIInterpolation::imFaceAreaWeight
); );
//- Construct from dictionary //- Construct from dictionary
@ -157,8 +157,7 @@ public:
const polyBoundaryMesh& bm, const polyBoundaryMesh& bm,
const word& patchType, const word& patchType,
const bool AMIRequireMatch = true, const bool AMIRequireMatch = true,
const AMIInterpolation::interpolationMethod AMIMethod = const word& AMIMethod = faceAreaWeightAMI::typeName
AMIInterpolation::imFaceAreaWeight
); );
//- Construct as copy, resetting the boundary mesh //- Construct as copy, resetting the boundary mesh

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cyclicRepeatAMIPolyPatch.H" #include "cyclicRepeatAMIPolyPatch.H"
#include "partialFaceAreaWeightAMI.H"
#include "SubField.H" #include "SubField.H"
#include "Time.H" #include "Time.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -214,7 +215,7 @@ void Foam::cyclicRepeatAMIPolyPatch::resetAMI() const
nbrPatch, nbrPatch,
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
false, false,
AMIInterpolation::imPartialFaceAreaWeight, partialFaceAreaWeightAMI::typeName,
AMILowWeightCorrection_, AMILowWeightCorrection_,
AMIReverse_, AMIReverse_,
false false
@ -234,7 +235,7 @@ void Foam::cyclicRepeatAMIPolyPatch::resetAMI() const
nbrPatch, nbrPatch,
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
false, false,
AMIInterpolation::imPartialFaceAreaWeight, partialFaceAreaWeightAMI::typeName,
AMILowWeightCorrection_, AMILowWeightCorrection_,
AMIReverse_, AMIReverse_,
false false
@ -254,7 +255,7 @@ void Foam::cyclicRepeatAMIPolyPatch::resetAMI() const
nbrPatch, nbrPatch,
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
false, false,
AMIInterpolation::imPartialFaceAreaWeight, partialFaceAreaWeightAMI::typeName,
AMILowWeightCorrection_, AMILowWeightCorrection_,
AMIReverse_, AMIReverse_,
false false
@ -321,7 +322,7 @@ Foam::cyclicRepeatAMIPolyPatch::cyclicRepeatAMIPolyPatch
bm, bm,
patchType, patchType,
false, false,
AMIInterpolation::imFaceAreaWeight faceAreaWeightAMI::typeName
), ),
transformPatchName_(word::null), transformPatchName_(word::null),
transformPatchID_(-1) transformPatchID_(-1)
@ -348,7 +349,7 @@ Foam::cyclicRepeatAMIPolyPatch::cyclicRepeatAMIPolyPatch
bm, bm,
patchType, patchType,
false, false,
AMIInterpolation::imFaceAreaWeight faceAreaWeightAMI::typeName
), ),
transformPatchName_(dict.lookup("transformPatch")), transformPatchName_(dict.lookup("transformPatch")),
transformPatchID_(-1) transformPatchID_(-1)

View File

@ -853,7 +853,7 @@ void Foam::mappedPatchBase::calcAMI() const
surfPtr(), surfPtr(),
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
true, true,
AMIInterpolation::imFaceAreaWeight, faceAreaWeightAMI::typeName,
-1, -1,
AMIReverse_ AMIReverse_
) )

View File

@ -92,7 +92,7 @@ void Foam::regionCoupledBase::resetAMI() const
surfPtr(), surfPtr(),
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
true, true,
AMIInterpolation::imFaceAreaWeight, faceAreaWeightAMI::typeName,
-1, -1,
AMIReverse_ AMIReverse_
) )

View File

@ -203,7 +203,7 @@ Foam::regionModels::regionModel::interRegionAMI
nbrP, nbrP,
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
true, true,
AMIInterpolation::imFaceAreaWeight, faceAreaWeightAMI::typeName,
-1, -1,
flip flip
) )
@ -246,7 +246,7 @@ Foam::regionModels::regionModel::interRegionAMI
nbrP, nbrP,
faceAreaIntersect::tmMesh, faceAreaIntersect::tmMesh,
true, true,
AMIInterpolation::imFaceAreaWeight, faceAreaWeightAMI::typeName,
-1, -1,
flip flip
) )

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cellVolumeWeightMethod.H" #include "cellVolumeWeightMethod.H"
#include "faceAreaWeightAMI.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataCell.H" #include "treeDataCell.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -313,6 +314,12 @@ Foam::cellVolumeWeightMethod::~cellVolumeWeightMethod()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::cellVolumeWeightMethod::AMImethod() const
{
return faceAreaWeightAMI::typeName;
}
void Foam::cellVolumeWeightMethod::calculate void Foam::cellVolumeWeightMethod::calculate
( (
labelListList& srcToTgtAddr, labelListList& srcToTgtAddr,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -114,6 +114,9 @@ public:
// Member Functions // Member Functions
//- Return the corresponding AMI method for patch interpolation
virtual const word& AMImethod() const;
// Evaluate // Evaluate
//- Calculate addressing and weights //- Calculate addressing and weights

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "directMethod.H" #include "directMethod.H"
#include "directAMI.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataCell.H" #include "treeDataCell.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -237,6 +238,12 @@ Foam::directMethod::~directMethod()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::directMethod::AMImethod() const
{
return directAMI::typeName;
}
void Foam::directMethod::calculate void Foam::directMethod::calculate
( (
labelListList& srcToTgtAddr, labelListList& srcToTgtAddr,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -119,6 +119,9 @@ public:
// Member Functions // Member Functions
//- Return the corresponding AMI method for patch interpolation
virtual const word& AMImethod() const;
// Evaluate // Evaluate
//- Calculate addressing and weights //- Calculate addressing and weights

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "mapNearestMethod.H" #include "mapNearestMethod.H"
#include "mapNearestAMI.H"
#include "pointIndexHit.H" #include "pointIndexHit.H"
#include "indexedOctree.H" #include "indexedOctree.H"
#include "treeDataCell.H" #include "treeDataCell.H"
@ -345,6 +346,12 @@ Foam::mapNearestMethod::~mapNearestMethod()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::word& Foam::mapNearestMethod::AMImethod() const
{
return mapNearestAMI::typeName;
}
void Foam::mapNearestMethod::calculate void Foam::mapNearestMethod::calculate
( (
labelListList& srcToTgtAddr, labelListList& srcToTgtAddr,

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -132,6 +132,9 @@ public:
// Member Functions // Member Functions
//- Return the corresponding AMI method for patch interpolation
virtual const word& AMImethod() const;
// Evaluate // Evaluate
//- Calculate addressing and weights //- Calculate addressing and weights

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -145,6 +145,9 @@ public:
// Member Functions // Member Functions
//- Return the corresponding AMI method for patch interpolation
virtual const word& AMImethod() const = 0;
// Evaluate // Evaluate
//- Calculate addressing and weights //- Calculate addressing and weights

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,21 +33,6 @@ License
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(meshToMesh, 0); defineTypeNameAndDebug(meshToMesh, 0);
template<>
const char* Foam::NamedEnum
<
Foam::meshToMesh::interpolationMethod,
3
>::names[] =
{
"direct",
"mapNearest",
"cellVolumeWeight"
};
const NamedEnum<meshToMesh::interpolationMethod, 3>
meshToMesh::interpolationMethodNames_;
} }
@ -227,7 +212,7 @@ void Foam::meshToMesh::normaliseWeights
} }
void Foam::meshToMesh::calcAddressing Foam::word Foam::meshToMesh::calcAddressing
( (
const word& methodName, const word& methodName,
const polyMesh& src, const polyMesh& src,
@ -258,10 +243,12 @@ void Foam::meshToMesh::calcAddressing
{ {
methodPtr->writeConnectivity(src, tgt, srcToTgtCellAddr_); 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() Info<< "Creating mesh-to-mesh addressing for " << srcRegion_.name()
<< " and " << tgtRegion_.name() << " regions using " << " and " << tgtRegion_.name() << " regions using "
@ -269,6 +256,8 @@ void Foam::meshToMesh::calculate(const word& methodName)
singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_); singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_);
word amiMethod;
if (singleMeshProc_ == -1) if (singleMeshProc_ == -1)
{ {
// create global indexing for src and tgt meshes // 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 // per source cell the target cell address in newTgt mesh
forAll(srcToTgtCellAddr_, i) forAll(srcToTgtCellAddr_, i)
@ -437,7 +426,7 @@ void Foam::meshToMesh::calculate(const word& methodName)
} }
else else
{ {
calcAddressing(methodName, srcRegion_, tgtRegion_); amiMethod = calcAddressing(methodName, srcRegion_, tgtRegion_);
normaliseWeights normaliseWeights
( (
@ -455,38 +444,8 @@ void Foam::meshToMesh::calculate(const word& methodName)
} }
Info<< " Overlap volume: " << V_ << endl; Info<< " Overlap volume: " << V_ << endl;
}
return amiMethod;
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;
} }
@ -539,7 +498,6 @@ void Foam::meshToMesh::calculatePatchAMIs(const word& AMIMethodName)
void Foam::meshToMesh::constructNoCuttingPatches void Foam::meshToMesh::constructNoCuttingPatches
( (
const word& methodName, const word& methodName,
const word& AMIMethodName,
const bool interpAllPatches const bool interpAllPatches
) )
{ {
@ -583,17 +541,16 @@ void Foam::meshToMesh::constructNoCuttingPatches
} }
// calculate volume addressing and weights // calculate volume addressing and weights
calculate(methodName); const word amiMethod = calculate(methodName);
// calculate patch addressing and weights // calculate patch addressing and weights
calculatePatchAMIs(AMIMethodName); calculatePatchAMIs(amiMethod);
} }
void Foam::meshToMesh::constructFromCuttingPatches void Foam::meshToMesh::constructFromCuttingPatches
( (
const word& methodName, const word& methodName,
const word& AMIMethodName,
const HashTable<word>& patchMap, const HashTable<word>& patchMap,
const wordList& cuttingPatches const wordList& cuttingPatches
) )
@ -616,10 +573,10 @@ void Foam::meshToMesh::constructFromCuttingPatches
} }
// calculate volume addressing and weights // calculate volume addressing and weights
calculate(methodName); const word amiMethod = calculate(methodName);
// calculate patch addressing and weights // calculate patch addressing and weights
calculatePatchAMIs(AMIMethodName); calculatePatchAMIs(amiMethod);
// set IDs of cutting patches on target mesh // set IDs of cutting patches on target mesh
cuttingPatches_.setSize(cuttingPatches.size()); cuttingPatches_.setSize(cuttingPatches.size());
@ -637,7 +594,7 @@ Foam::meshToMesh::meshToMesh
( (
const polyMesh& src, const polyMesh& src,
const polyMesh& tgt, const polyMesh& tgt,
const interpolationMethod& method, const word& methodName,
bool interpAllPatches bool interpAllPatches
) )
: :
@ -656,15 +613,7 @@ Foam::meshToMesh::meshToMesh
srcMapPtr_(nullptr), srcMapPtr_(nullptr),
tgtMapPtr_(nullptr) tgtMapPtr_(nullptr)
{ {
constructNoCuttingPatches constructNoCuttingPatches(methodName, interpAllPatches);
(
interpolationMethodNames_[method],
AMIInterpolation::interpolationMethodToWord
(
interpolationMethodAMI(method)
),
interpAllPatches
);
} }
@ -673,72 +622,6 @@ Foam::meshToMesh::meshToMesh
const polyMesh& src, const polyMesh& src,
const polyMesh& tgt, const polyMesh& tgt,
const word& methodName, 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<word>& 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<word>& patchMap, const HashTable<word>& patchMap,
const wordList& cuttingPatches const wordList& cuttingPatches
) )
@ -761,7 +644,6 @@ Foam::meshToMesh::meshToMesh
constructFromCuttingPatches constructFromCuttingPatches
( (
methodName, methodName,
AMIMethodName,
patchMap, patchMap,
cuttingPatches cuttingPatches
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -60,23 +60,6 @@ namespace Foam
class meshToMesh class meshToMesh
{ {
public:
// Public data types
//- Enumeration specifying interpolation method
enum interpolationMethod
{
imDirect,
imMapNearest,
imCellVolumeWeight
};
static const NamedEnum<interpolationMethod, 3>
interpolationMethodNames_;
private:
// Private Data // Private Data
//- Reference to the source mesh //- Reference to the source mesh
@ -164,7 +147,7 @@ private:
//- Calculate the addressing between overlapping regions of src and tgt //- Calculate the addressing between overlapping regions of src and tgt
// meshes // meshes
void calcAddressing word calcAddressing
( (
const word& methodName, const word& methodName,
const polyMesh& src, const polyMesh& src,
@ -172,7 +155,8 @@ private:
); );
//- Calculate - main driver function //- Calculate - main driver function
void calculate(const word& methodName); // Returns the corresponding AMImethod
word calculate(const word& methodName);
//- Calculate patch overlap //- Calculate patch overlap
void calculatePatchAMIs(const word& amiMethodName); void calculatePatchAMIs(const word& amiMethodName);
@ -181,7 +165,6 @@ private:
void constructNoCuttingPatches void constructNoCuttingPatches
( (
const word& methodName, const word& methodName,
const word& AMIMethodName,
const bool interpAllPatches const bool interpAllPatches
); );
@ -189,7 +172,6 @@ private:
void constructFromCuttingPatches void constructFromCuttingPatches
( (
const word& methodName, const word& methodName,
const word& AMIMethodName,
const HashTable<word>& patchMap, const HashTable<word>& patchMap,
const wordList& cuttingPatches const wordList& cuttingPatches
); );
@ -260,12 +242,12 @@ public:
// Constructors // Constructors
//- Construct from source and target meshes //- Construct from source and target meshes, generic mapping methods
meshToMesh meshToMesh
( (
const polyMesh& src, const polyMesh& src,
const polyMesh& tgt, const polyMesh& tgt,
const interpolationMethod& method, const word& methodName,
const bool interpAllPatches = true const bool interpAllPatches = true
); );
@ -274,28 +256,7 @@ public:
( (
const polyMesh& src, const polyMesh& src,
const polyMesh& tgt, const polyMesh& tgt,
const word& methodName, // internal mapping const word& methodName,
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<word>& 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 HashTable<word>& patchMap, const HashTable<word>& patchMap,
const wordList& cuttingPatches const wordList& cuttingPatches
); );
@ -333,10 +294,6 @@ public:
//- Return const access to the overlap volume //- Return const access to the overlap volume
inline scalar V() const; inline scalar V() const;
//- Conversion between mesh and patch interpolation methods
static AMIInterpolation::interpolationMethod
interpolationMethodAMI(const interpolationMethod method);
// Evaluation // Evaluation

View File

@ -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 <http://www.gnu.org/licenses/>.
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
// ************************************************************************* //