mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: mapFields: expose AMI mapping methods
This commit is contained in:
@ -119,6 +119,7 @@ void Foam::meshToMesh::normaliseWeights
|
||||
|
||||
void Foam::meshToMesh::calcAddressing
|
||||
(
|
||||
const word& methodName,
|
||||
const polyMesh& src,
|
||||
const polyMesh& tgt
|
||||
)
|
||||
@ -127,7 +128,7 @@ void Foam::meshToMesh::calcAddressing
|
||||
(
|
||||
meshToMeshMethod::New
|
||||
(
|
||||
interpolationMethodNames_[method_],
|
||||
methodName,
|
||||
src,
|
||||
tgt
|
||||
)
|
||||
@ -150,11 +151,11 @@ void Foam::meshToMesh::calcAddressing
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshToMesh::calculate()
|
||||
void Foam::meshToMesh::calculate(const word& methodName)
|
||||
{
|
||||
Info<< "Creating mesh-to-mesh addressing for " << srcRegion_.name()
|
||||
<< " and " << tgtRegion_.name() << " regions using "
|
||||
<< interpolationMethodNames_[method_] << endl;
|
||||
<< methodName << endl;
|
||||
|
||||
singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_);
|
||||
|
||||
@ -241,7 +242,7 @@ void Foam::meshToMesh::calculate()
|
||||
}
|
||||
}
|
||||
|
||||
calcAddressing(srcRegion_, newTgt);
|
||||
calcAddressing(methodName, srcRegion_, newTgt);
|
||||
|
||||
// per source cell the target cell address in newTgt mesh
|
||||
forAll(srcToTgtCellAddr_, i)
|
||||
@ -320,7 +321,7 @@ void Foam::meshToMesh::calculate()
|
||||
}
|
||||
else
|
||||
{
|
||||
calcAddressing(srcRegion_, tgtRegion_);
|
||||
calcAddressing(methodName, srcRegion_, tgtRegion_);
|
||||
|
||||
normaliseWeights
|
||||
(
|
||||
@ -342,12 +343,9 @@ void Foam::meshToMesh::calculate()
|
||||
|
||||
|
||||
Foam::AMIPatchToPatchInterpolation::interpolationMethod
|
||||
Foam::meshToMesh::interpolationMethodAMI
|
||||
(
|
||||
const interpolationMethod method
|
||||
) const
|
||||
Foam::meshToMesh::interpolationMethodAMI(const interpolationMethod method)
|
||||
{
|
||||
switch (method_)
|
||||
switch (method)
|
||||
{
|
||||
case imDirect:
|
||||
{
|
||||
@ -374,7 +372,7 @@ Foam::meshToMesh::interpolationMethodAMI
|
||||
"const interpolationMethod method"
|
||||
") const"
|
||||
)
|
||||
<< "Unhandled enumeration " << method_
|
||||
<< "Unhandled enumeration " << method
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -383,90 +381,66 @@ Foam::meshToMesh::interpolationMethodAMI
|
||||
}
|
||||
|
||||
|
||||
const Foam::PtrList<Foam::AMIPatchToPatchInterpolation>&
|
||||
Foam::meshToMesh::patchAMIs() const
|
||||
void Foam::meshToMesh::calculatePatchAMIs(const word& AMIMethodName)
|
||||
{
|
||||
if (patchAMIs_.empty())
|
||||
if (!patchAMIs_.empty())
|
||||
{
|
||||
const word amiMethod =
|
||||
AMIPatchToPatchInterpolation::interpolationMethodToWord
|
||||
(
|
||||
interpolationMethodAMI(method_)
|
||||
);
|
||||
|
||||
patchAMIs_.setSize(srcPatchID_.size());
|
||||
|
||||
forAll(srcPatchID_, i)
|
||||
{
|
||||
label srcPatchI = srcPatchID_[i];
|
||||
label tgtPatchI = tgtPatchID_[i];
|
||||
|
||||
const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchI];
|
||||
const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchI];
|
||||
|
||||
Info<< "Creating AMI between source patch " << srcPP.name()
|
||||
<< " and target patch " << tgtPP.name()
|
||||
<< " using " << amiMethod
|
||||
<< endl;
|
||||
|
||||
Info<< incrIndent;
|
||||
|
||||
patchAMIs_.set
|
||||
(
|
||||
i,
|
||||
new AMIPatchToPatchInterpolation
|
||||
(
|
||||
srcPP,
|
||||
tgtPP,
|
||||
faceAreaIntersect::tmMesh,
|
||||
false,
|
||||
interpolationMethodAMI(method_),
|
||||
-1,
|
||||
true // flip target patch since patch normals are aligned
|
||||
)
|
||||
);
|
||||
|
||||
Info<< decrIndent;
|
||||
}
|
||||
FatalErrorIn("meshToMesh::calculatePatchAMIs()")
|
||||
<< "patch AMI already calculated"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return patchAMIs_;
|
||||
patchAMIs_.setSize(srcPatchID_.size());
|
||||
|
||||
forAll(srcPatchID_, i)
|
||||
{
|
||||
label srcPatchI = srcPatchID_[i];
|
||||
label tgtPatchI = tgtPatchID_[i];
|
||||
|
||||
const polyPatch& srcPP = srcRegion_.boundaryMesh()[srcPatchI];
|
||||
const polyPatch& tgtPP = tgtRegion_.boundaryMesh()[tgtPatchI];
|
||||
|
||||
Info<< "Creating AMI between source patch " << srcPP.name()
|
||||
<< " and target patch " << tgtPP.name()
|
||||
<< " using " << AMIMethodName
|
||||
<< endl;
|
||||
|
||||
Info<< incrIndent;
|
||||
|
||||
patchAMIs_.set
|
||||
(
|
||||
i,
|
||||
new AMIPatchToPatchInterpolation
|
||||
(
|
||||
srcPP,
|
||||
tgtPP,
|
||||
faceAreaIntersect::tmMesh,
|
||||
false,
|
||||
AMIMethodName,
|
||||
-1,
|
||||
true // flip target patch since patch normals are aligned
|
||||
)
|
||||
);
|
||||
|
||||
Info<< decrIndent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::meshToMesh::meshToMesh
|
||||
void Foam::meshToMesh::constructNoCuttingPatches
|
||||
(
|
||||
const polyMesh& src,
|
||||
const polyMesh& tgt,
|
||||
const interpolationMethod& method,
|
||||
bool interpAllPatches
|
||||
const word& methodName,
|
||||
const word& AMIMethodName,
|
||||
const bool interpAllPatches
|
||||
)
|
||||
:
|
||||
srcRegion_(src),
|
||||
tgtRegion_(tgt),
|
||||
srcPatchID_(),
|
||||
tgtPatchID_(),
|
||||
patchAMIs_(),
|
||||
cuttingPatches_(),
|
||||
srcToTgtCellAddr_(),
|
||||
tgtToSrcCellAddr_(),
|
||||
srcToTgtCellWght_(),
|
||||
tgtToSrcCellWght_(),
|
||||
method_(method),
|
||||
V_(0.0),
|
||||
singleMeshProc_(-1),
|
||||
srcMapPtr_(NULL),
|
||||
tgtMapPtr_(NULL)
|
||||
{
|
||||
if (interpAllPatches)
|
||||
{
|
||||
const polyBoundaryMesh& srcBM = src.boundaryMesh();
|
||||
const polyBoundaryMesh& tgtBM = tgt.boundaryMesh();
|
||||
const polyBoundaryMesh& srcBM = srcRegion_.boundaryMesh();
|
||||
const polyBoundaryMesh& tgtBM = tgtRegion_.boundaryMesh();
|
||||
|
||||
DynamicList<label> srcPatchID(src.boundaryMesh().size());
|
||||
DynamicList<label> tgtPatchID(tgt.boundaryMesh().size());
|
||||
DynamicList<label> srcPatchID(srcBM.size());
|
||||
DynamicList<label> tgtPatchID(tgtBM.size());
|
||||
forAll(srcBM, patchI)
|
||||
{
|
||||
const polyPatch& pp = srcBM[patchI];
|
||||
@ -474,7 +448,7 @@ Foam::meshToMesh::meshToMesh
|
||||
{
|
||||
srcPatchID.append(pp.index());
|
||||
|
||||
label tgtPatchI = tgt.boundaryMesh().findPatchID(pp.name());
|
||||
label tgtPatchI = tgtBM.findPatchID(pp.name());
|
||||
|
||||
if (tgtPatchI != -1)
|
||||
{
|
||||
@ -504,10 +478,116 @@ Foam::meshToMesh::meshToMesh
|
||||
}
|
||||
|
||||
// calculate volume addressing and weights
|
||||
calculate();
|
||||
calculate(methodName);
|
||||
|
||||
// calculate patch addressing and weights
|
||||
(void)patchAMIs();
|
||||
calculatePatchAMIs(AMIMethodName);
|
||||
}
|
||||
|
||||
|
||||
void Foam::meshToMesh::constructFromCuttingPatches
|
||||
(
|
||||
const word& methodName,
|
||||
const word& AMIMethodName,
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatches
|
||||
)
|
||||
{
|
||||
srcPatchID_.setSize(patchMap.size());
|
||||
tgtPatchID_.setSize(patchMap.size());
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(HashTable<word>, patchMap, iter)
|
||||
{
|
||||
const word& tgtPatchName = iter.key();
|
||||
const word& srcPatchName = iter();
|
||||
|
||||
const polyPatch& srcPatch = srcRegion_.boundaryMesh()[srcPatchName];
|
||||
const polyPatch& tgtPatch = tgtRegion_.boundaryMesh()[tgtPatchName];
|
||||
|
||||
srcPatchID_[i] = srcPatch.index();
|
||||
tgtPatchID_[i] = tgtPatch.index();
|
||||
i++;
|
||||
}
|
||||
|
||||
// calculate volume addressing and weights
|
||||
calculate(methodName);
|
||||
|
||||
// calculate patch addressing and weights
|
||||
calculatePatchAMIs(AMIMethodName);
|
||||
|
||||
// set IDs of cutting patches on target mesh
|
||||
cuttingPatches_.setSize(cuttingPatches.size());
|
||||
forAll(cuttingPatches_, i)
|
||||
{
|
||||
const word& patchName = cuttingPatches[i];
|
||||
cuttingPatches_[i] = tgtRegion_.boundaryMesh().findPatchID(patchName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::meshToMesh::meshToMesh
|
||||
(
|
||||
const polyMesh& src,
|
||||
const polyMesh& tgt,
|
||||
const interpolationMethod& method,
|
||||
bool interpAllPatches
|
||||
)
|
||||
:
|
||||
srcRegion_(src),
|
||||
tgtRegion_(tgt),
|
||||
srcPatchID_(),
|
||||
tgtPatchID_(),
|
||||
patchAMIs_(),
|
||||
cuttingPatches_(),
|
||||
srcToTgtCellAddr_(),
|
||||
tgtToSrcCellAddr_(),
|
||||
srcToTgtCellWght_(),
|
||||
tgtToSrcCellWght_(),
|
||||
V_(0.0),
|
||||
singleMeshProc_(-1),
|
||||
srcMapPtr_(NULL),
|
||||
tgtMapPtr_(NULL)
|
||||
{
|
||||
constructNoCuttingPatches
|
||||
(
|
||||
interpolationMethodNames_[method],
|
||||
AMIPatchToPatchInterpolation::interpolationMethodToWord
|
||||
(
|
||||
interpolationMethodAMI(method)
|
||||
),
|
||||
interpAllPatches
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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_(NULL),
|
||||
tgtMapPtr_(NULL)
|
||||
{
|
||||
constructNoCuttingPatches(methodName, AMIMethodName, interpAllPatches);
|
||||
}
|
||||
|
||||
|
||||
@ -530,42 +610,56 @@ Foam::meshToMesh::meshToMesh
|
||||
tgtToSrcCellAddr_(),
|
||||
srcToTgtCellWght_(),
|
||||
tgtToSrcCellWght_(),
|
||||
method_(method),
|
||||
V_(0.0),
|
||||
singleMeshProc_(-1),
|
||||
srcMapPtr_(NULL),
|
||||
tgtMapPtr_(NULL)
|
||||
{
|
||||
srcPatchID_.setSize(patchMap.size());
|
||||
tgtPatchID_.setSize(patchMap.size());
|
||||
constructFromCuttingPatches
|
||||
(
|
||||
interpolationMethodNames_[method],
|
||||
AMIPatchToPatchInterpolation::interpolationMethodToWord
|
||||
(
|
||||
interpolationMethodAMI(method)
|
||||
),
|
||||
patchMap,
|
||||
cuttingPatches
|
||||
);
|
||||
}
|
||||
|
||||
label i = 0;
|
||||
forAllConstIter(HashTable<word>, patchMap, iter)
|
||||
{
|
||||
const word& tgtPatchName = iter.key();
|
||||
const word& srcPatchName = iter();
|
||||
|
||||
const polyPatch& srcPatch = srcRegion_.boundaryMesh()[srcPatchName];
|
||||
const polyPatch& tgtPatch = tgtRegion_.boundaryMesh()[tgtPatchName];
|
||||
|
||||
srcPatchID_[i] = srcPatch.index();
|
||||
tgtPatchID_[i] = tgtPatch.index();
|
||||
i++;
|
||||
}
|
||||
|
||||
// calculate volume addressing and weights
|
||||
calculate();
|
||||
|
||||
// calculate patch addressing and weights
|
||||
(void)patchAMIs();
|
||||
|
||||
// set IDs of cutting patches on target mesh
|
||||
cuttingPatches_.setSize(cuttingPatches.size());
|
||||
forAll(cuttingPatches_, i)
|
||||
{
|
||||
const word& patchName = cuttingPatches[i];
|
||||
cuttingPatches_[i] = tgt.boundaryMesh().findPatchID(patchName);
|
||||
}
|
||||
Foam::meshToMesh::meshToMesh
|
||||
(
|
||||
const polyMesh& src,
|
||||
const polyMesh& tgt,
|
||||
const word& methodName, // internal mapping
|
||||
const word& AMIMethodName, // boundary mapping
|
||||
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_(NULL),
|
||||
tgtMapPtr_(NULL)
|
||||
{
|
||||
constructFromCuttingPatches
|
||||
(
|
||||
methodName,
|
||||
AMIMethodName,
|
||||
patchMap,
|
||||
cuttingPatches
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ private:
|
||||
List<label> tgtPatchID_;
|
||||
|
||||
//- List of AMIs between source and target patches
|
||||
mutable PtrList<AMIPatchToPatchInterpolation> patchAMIs_;
|
||||
PtrList<AMIPatchToPatchInterpolation> patchAMIs_;
|
||||
|
||||
//- Cutting patches whose values are set using a zero-gradient condition
|
||||
List<label> cuttingPatches_;
|
||||
@ -109,9 +109,6 @@ private:
|
||||
//- Target to source cell interpolation weights
|
||||
scalarListList tgtToSrcCellWght_;
|
||||
|
||||
//- Interpolation method
|
||||
interpolationMethod method_;
|
||||
|
||||
//- Cell total volume in overlap region [m3]
|
||||
scalar V_;
|
||||
|
||||
@ -143,22 +140,41 @@ private:
|
||||
scalarListList& wght
|
||||
) const;
|
||||
|
||||
//- Calculate the addressing between overalping regions of src and tgt
|
||||
//- Calculate the addressing between overlapping regions of src and tgt
|
||||
// meshes
|
||||
void calcAddressing(const polyMesh& src, const polyMesh& tgt);
|
||||
void calcAddressing
|
||||
(
|
||||
const word& methodName,
|
||||
const polyMesh& src,
|
||||
const polyMesh& tgt
|
||||
);
|
||||
|
||||
//- Calculate - main driver function
|
||||
void calculate();
|
||||
void calculate(const word& methodName);
|
||||
|
||||
//- Conversion between mesh and patch interpolation methods
|
||||
AMIPatchToPatchInterpolation::interpolationMethod
|
||||
interpolationMethodAMI
|
||||
//- Calculate patch overlap
|
||||
void calculatePatchAMIs(const word& amiMethodName);
|
||||
|
||||
//- Constructor helper
|
||||
void constructNoCuttingPatches
|
||||
(
|
||||
const interpolationMethod method
|
||||
) const;
|
||||
const word& methodName,
|
||||
const word& AMIMethodName,
|
||||
const bool interpAllPatches
|
||||
);
|
||||
|
||||
//- Constructor helper
|
||||
void constructFromCuttingPatches
|
||||
(
|
||||
const word& methodName,
|
||||
const word& AMIMethodName,
|
||||
const HashTable<word>& patchMap,
|
||||
const wordList& cuttingPatches
|
||||
);
|
||||
|
||||
//- Return the list of AMIs between source and target patches
|
||||
const PtrList<AMIPatchToPatchInterpolation>& patchAMIs() const;
|
||||
inline const PtrList<AMIPatchToPatchInterpolation>&
|
||||
patchAMIs() const;
|
||||
|
||||
|
||||
// Parallel operations
|
||||
@ -237,6 +253,15 @@ public:
|
||||
const bool interpAllPatches = true
|
||||
);
|
||||
|
||||
//- 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 bool interpAllPatches = true
|
||||
);
|
||||
|
||||
//- Construct from source and target meshes
|
||||
meshToMesh
|
||||
@ -249,6 +274,18 @@ public:
|
||||
);
|
||||
|
||||
|
||||
//- 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 wordList& cuttingPatches
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~meshToMesh();
|
||||
|
||||
@ -278,6 +315,13 @@ public:
|
||||
//- Return const access to the overlap volume
|
||||
inline scalar V() const;
|
||||
|
||||
//- Conversion between mesh and patch interpolation methods
|
||||
static AMIPatchToPatchInterpolation::interpolationMethod
|
||||
interpolationMethodAMI
|
||||
(
|
||||
const interpolationMethod method
|
||||
);
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
|
||||
@ -73,4 +73,11 @@ inline Foam::scalar Foam::meshToMesh::V() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::PtrList<Foam::AMIPatchToPatchInterpolation>&
|
||||
Foam::meshToMesh::patchAMIs() const
|
||||
{
|
||||
return patchAMIs_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user