ENH: Updated mesh-to-mesh interpolation for vol-field mapping

This commit is contained in:
andy
2013-03-22 15:30:56 +00:00
parent ea9112b5c3
commit 97373ec669
4 changed files with 467 additions and 234 deletions

View File

@ -271,6 +271,7 @@ void Foam::meshToMeshNew::calcDirect
DynamicList<label> srcSeeds;
const scalarField& srcVc = src.cellVolumes();
const scalarField& tgtVc = tgt.cellVolumes();
label srcCellI = srcSeedI;
label tgtCellI = tgtSeedI;
@ -305,14 +306,16 @@ void Foam::meshToMeshNew::calcDirect
// transfer addressing into persistent storage
forAll(srcToTgtCellAddr_, i)
{
scalar v = srcVc[i];
srcToTgtCellAddr_[i].transfer(srcToTgt[i]);
srcToTgtCellWght_[i] = scalarList(srcToTgtCellAddr_[i].size(), 1.0);
srcToTgtCellWght_[i] = scalarList(srcToTgtCellAddr_[i].size(), v);
}
forAll(tgtToSrcCellAddr_, i)
{
scalar v = tgtVc[i];
tgtToSrcCellAddr_[i].transfer(tgtToSrc[i]);
tgtToSrcCellWght_[i] = scalarList(tgtToSrcCellAddr_[i].size(), 1.0);
tgtToSrcCellWght_[i] = scalarList(tgtToSrcCellAddr_[i].size(), v);
}
}
@ -347,7 +350,7 @@ void Foam::meshToMeshNew::normaliseWeights
maxW = max(maxW, s/Vc);
}
Info<< type() << ": " << descriptor << " weights min/max = "
Info<< " " << descriptor << " weights min/max = "
<< returnReduce(minW, minOp<scalar>()) << ", "
<< returnReduce(maxW, maxOp<scalar>()) << endl;
}
@ -765,42 +768,24 @@ void Foam::meshToMeshNew::calcAddressing
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::meshToMeshNew::meshToMeshNew
(
const polyMesh& src,
const polyMesh& tgt,
const interpolationMethod& method
)
:
srcRegionName_(src.name()),
tgtRegionName_(tgt.name()),
srcToTgtCellAddr_(),
tgtToSrcCellAddr_(),
srcToTgtCellWght_(),
tgtToSrcCellWght_(),
method_(method),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
void Foam::meshToMeshNew::calculate()
{
Info<< "Creating mesh-to-mesh addressing for " << src.name()
<< " and " << tgt.name() << " regions" << endl;
Info<< "Creating mesh-to-mesh addressing for " << srcRegion_.name()
<< " and " << tgtRegion_.name() << " regions using "
<< interpolationMethodNames_[method_] << endl;
singleMeshProc_ = calcDistribution(src, tgt);
singleMeshProc_ = calcDistribution(srcRegion_, tgtRegion_);
if (singleMeshProc_ == -1)
{
// create global indexing for src and tgt meshes
globalIndex globalSrcCells(src.nCells());
globalIndex globalTgtCells(tgt.nCells());
globalIndex globalSrcCells(srcRegion_.nCells());
globalIndex globalTgtCells(tgtRegion_.nCells());
// Create processor map of overlapping cells. This map gets
// (possibly remote) cells from the tgt mesh such that they (together)
// cover all of the src mesh
autoPtr<mapDistribute> mapPtr = calcProcMap(src, tgt);
autoPtr<mapDistribute> mapPtr = calcProcMap(srcRegion_, tgtRegion_);
const mapDistribute& map = mapPtr();
pointField newTgtPoints;
@ -812,7 +797,7 @@ Foam::meshToMeshNew::meshToMeshNew
distributeAndMergeCells
(
map,
tgt,
tgtRegion_,
globalTgtCells,
newTgtPoints,
newTgtFaces,
@ -827,9 +812,9 @@ Foam::meshToMeshNew::meshToMeshNew
(
IOobject
(
"newTgt::" + Foam::name(Pstream::myProcNo()),
tgt.time().timeName(),
tgt.time(),
"newTgt." + Foam::name(Pstream::myProcNo()),
tgtRegion_.time().timeName(),
tgtRegion_.time(),
IOobject::NO_READ
),
xferMove(newTgtPoints),
@ -862,9 +847,9 @@ Foam::meshToMeshNew::meshToMeshNew
if (debug)
{
Pout<< "Created newTgt mesh:" << nl
<< " old cells = " << tgt.nCells()
<< " old cells = " << tgtRegion_.nCells()
<< ", new cells = " << newTgt.nCells() << nl
<< " old faces = " << tgt.nFaces()
<< " old faces = " << tgtRegion_.nFaces()
<< ", new faces = " << newTgt.nFaces() << endl;
if (debug > 1)
@ -874,7 +859,7 @@ Foam::meshToMeshNew::meshToMeshNew
}
}
calcAddressing(src, newTgt);
calcAddressing(srcRegion_, newTgt);
// per source cell the target cell address in newTgt mesh
forAll(srcToTgtCellAddr_, i)
@ -901,7 +886,7 @@ Foam::meshToMeshNew::meshToMeshNew
(
Pstream::nonBlocking,
List<labelPair>(),
tgt.nCells(),
tgtRegion_.nCells(),
map.constructMap(),
map.subMap(),
tgtToSrcCellAddr_,
@ -914,7 +899,7 @@ Foam::meshToMeshNew::meshToMeshNew
(
Pstream::nonBlocking,
List<labelPair>(),
tgt.nCells(),
tgtRegion_.nCells(),
map.constructMap(),
map.subMap(),
tgtToSrcCellWght_,
@ -926,7 +911,7 @@ Foam::meshToMeshNew::meshToMeshNew
normaliseWeights
(
"source",
src.cellVolumes(),
srcRegion_.cellVolumes(),
srcToTgtCellAddr_,
srcToTgtCellWght_
);
@ -934,7 +919,7 @@ Foam::meshToMeshNew::meshToMeshNew
normaliseWeights
(
"target",
tgt.cellVolumes(),
tgtRegion_.cellVolumes(),
tgtToSrcCellAddr_,
tgtToSrcCellWght_
);
@ -955,12 +940,12 @@ Foam::meshToMeshNew::meshToMeshNew
}
else
{
calcAddressing(src, tgt);
calcAddressing(srcRegion_, tgtRegion_);
normaliseWeights
(
"source",
src.cellVolumes(),
srcRegion_.cellVolumes(),
srcToTgtCellAddr_,
srcToTgtCellWght_
);
@ -968,7 +953,7 @@ Foam::meshToMeshNew::meshToMeshNew
normaliseWeights
(
"target",
tgt.cellVolumes(),
tgtRegion_.cellVolumes(),
tgtToSrcCellAddr_,
tgtToSrcCellWght_
);
@ -978,6 +963,162 @@ Foam::meshToMeshNew::meshToMeshNew
}
const Foam::PtrList<Foam::AMIPatchToPatchInterpolation>&
Foam::meshToMeshNew::patchAMIs() const
{
if (patchAMIs_.empty())
{
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() << endl;
Info<< incrIndent;
patchAMIs_.set
(
i,
new AMIPatchToPatchInterpolation
(
srcPP,
tgtPP,
faceAreaIntersect::tmMesh,
true // flip target patch since patch normals are aligned
)
);
Info<< decrIndent;
}
}
return patchAMIs_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::meshToMeshNew::meshToMeshNew
(
const polyMesh& src,
const polyMesh& tgt,
const interpolationMethod& method,
bool interpAllPatches
)
:
srcRegion_(src),
tgtRegion_(tgt),
srcPatchID_(),
tgtPatchID_(),
patchAMIs_(),
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();
if (srcBM.size() != tgtBM.size())
{
FatalErrorIn
(
"Foam::meshToMeshNew::meshToMeshNew"
"("
"const polyMesh&, "
"const polyMesh&, "
"const interpolationMethod&"
")"
) << "Source and target meshes are dissimiar:" << nl
<< " Source patches: " << srcBM.size() << nl
<< " Target patches: " << tgtBM.size() << exit(FatalError);
}
DynamicList<label> patchID(src.boundaryMesh().size());
forAll(srcBM, patchI)
{
const polyPatch& pp = srcBM[patchI];
if (!polyPatch::constraintType(pp.type()))
{
patchID.append(pp.index());
}
}
srcPatchID_.transfer(patchID);
tgtPatchID_ = srcPatchID_;
}
// calculate volume addressing and weights
calculate();
// calculate patch addressing and weights
(void)patchAMIs();
}
Foam::meshToMeshNew::meshToMeshNew
(
const polyMesh& src,
const polyMesh& tgt,
const interpolationMethod& method,
const HashTable<word>& patchMap
)
:
srcRegion_(src),
tgtRegion_(tgt),
srcPatchID_(),
tgtPatchID_(),
patchAMIs_(),
srcToTgtCellAddr_(),
tgtToSrcCellAddr_(),
srcToTgtCellWght_(),
tgtToSrcCellWght_(),
method_(method),
V_(0.0),
singleMeshProc_(-1),
srcMapPtr_(NULL),
tgtMapPtr_(NULL)
{
srcPatchID_.setSize(patchMap.size());
tgtPatchID_.setSize(patchMap.size());
label i = 0;
forAllConstIter(HashTable<word>, patchMap, iter)
{
const word& srcPatchName = iter.key();
const word& tgtPatchName = 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();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::meshToMeshNew::~meshToMeshNew()

View File

@ -41,6 +41,7 @@ SourceFiles
#include "mapDistribute.H"
#include "volFieldsFwd.H"
#include "NamedEnum.H"
#include "AMIPatchToPatchInterpolation.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,11 +72,20 @@ private:
// Private data
//- Name of source mesh region
const word srcRegionName_;
//- Reference to the source mesh
const polyMesh& srcRegion_;
//- Name of target mesh region
const word tgtRegionName_;
//- Reference to the target mesh
const polyMesh& tgtRegion_;
//- List of target patch IDs per source patch (local index)
List<label> srcPatchID_;
//- List of source patch IDs per target patch (local index)
List<label> tgtPatchID_;
//- List of AMIs between source and target patches
mutable PtrList<AMIPatchToPatchInterpolation> patchAMIs_;
//- Source to target cell addressing
labelListList srcToTgtCellAddr_;
@ -230,9 +240,15 @@ private:
//- Calculate the addressing between overalping regions of src and tgt
// meshes - main driver function
// meshes
void calcAddressing(const polyMesh& src, const polyMesh& tgt);
//- Calculate - main driver function
void calculate();
//- Return the list of AMIs between source and target patches
const PtrList<AMIPatchToPatchInterpolation>& patchAMIs() const;
// Parallel operations
@ -306,7 +322,18 @@ public:
(
const polyMesh& src,
const polyMesh& tgt,
const interpolationMethod& method
const interpolationMethod& method,
const bool interpAllPatches = true
);
//- Construct from source and target meshes
meshToMeshNew
(
const polyMesh& src,
const polyMesh& tgt,
const interpolationMethod& method,
const HashTable<word>& patchMap
);
@ -318,6 +345,12 @@ public:
// Access
//- Return const access to the source mesh
inline const polyMesh& srcRegion() const;
//- Return const access to the target mesh
inline const polyMesh& tgtRegion() const;
//- Return const access to the source to target cell addressing
inline const labelListList& srcToTgtCellAddr() const;
@ -432,60 +465,103 @@ public:
) const;
// Volume field mapping
// Source-to-target volume field mapping
//- Interpolare a field with a defined operation. Values
//- Interpolate a field with a defined operation. Values
// passed in via 'result' are used to initialise the return
// value. Optionally interpolate patch values
// value
template<class Type, class CombineOp>
void interpolate
void mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
const bool interpPatches = true
GeometricField<Type, fvPatchField, volMesh>& result
) const;
//- Interpolare a field with a defined operation. The initial
// values of the result are set to zero. Optionally
// interpolate patch values
//- Interpolate a field with a defined operation. The initial
// values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
tmp<GeometricField<Type, fvPatchField, volMesh> > mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
const bool interpPatches = true
const CombineOp& cop
) const;
//- Interpolare a tmp field with a defined operation. The
// initial values of the result are set to zero. Optionally
// interpolate patch values
//- Interpolate a tmp field with a defined operation. The
// initial values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
tmp<GeometricField<Type, fvPatchField, volMesh> > mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield,
const CombineOp& cop,
const bool interpPatches = true
const CombineOp& cop
) const;
//- Convenience function to map a field with a default
// operation (plusEqOp). Optionally interpolate patch values
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
tmp<GeometricField<Type, fvPatchField, volMesh> > mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const bool interpPatches = true
const GeometricField<Type, fvPatchField, volMesh>& field
) const;
//- Convenience function to map a tmp field with a default
// operation (plusEqOp). Optionally interpolate patch values
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
tmp<GeometricField<Type, fvPatchField, volMesh> > mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield
) const;
// Target-to-source volume field mapping
//- Interpolate a field with a defined operation. Values
// passed in via 'result' are used to initialise the return
// value
template<class Type, class CombineOp>
void mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result
) const;
//- Interpolate a field with a defined operation. The initial
// values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh> > mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
) const;
//- Interpolate a tmp field with a defined operation. The
// initial values of the result are set to zero
template<class Type, class CombineOp>
tmp<GeometricField<Type, fvPatchField, volMesh> > mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield,
const bool interpPatches = true
const CombineOp& cop
) const;
//- Convenience function to map a field with a default
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field
) const;
//- Convenience function to map a tmp field with a default
// operation (plusEqOp)
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> > mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >&
tfield
) const;
};

View File

@ -27,6 +27,18 @@ License
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
inline const Foam::polyMesh& Foam::meshToMeshNew::srcRegion() const
{
return srcRegion_;
}
inline const Foam::polyMesh& Foam::meshToMeshNew::tgtRegion() const
{
return tgtRegion_;
}
inline const Foam::labelListList&
Foam::meshToMeshNew::srcToTgtCellAddr() const
{

View File

@ -25,7 +25,6 @@ License
#include "fvMesh.H"
#include "volFields.H"
//#include "ops.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -56,31 +55,6 @@ namespace Foam
}
}
};
//- Combine operator for maps/interpolations
template<class Type, class CombineOp>
class combineBinaryOp
{
const CombineOp& cop_;
public:
combineBinaryOp(const CombineOp& cop)
:
cop_(cop)
{}
void operator()
(
Type& x,
const label faceI,
const Type& y,
const scalar weight
) const
{
cop_(x, weight*y);
}
};
}
@ -119,13 +93,13 @@ void Foam::meshToMeshNew::mapSrcToTgt
"List<Type>&"
") const"
) << "Supplied field size is not equal to target mesh size" << nl
<< " source mesh = " << srcToTgtCellAddr_.size() << nl
<< " target mesh = " << tgtToSrcCellAddr_.size() << nl
<< " source mesh = " << srcToTgtCellAddr_.size() << nl
<< " target mesh = " << tgtToSrcCellAddr_.size() << nl
<< " supplied field = " << result.size()
<< abort(FatalError);
}
combineBinaryOp<Type, CombineOp> cbop(cop);
multiplyWeightedOp<Type, CombineOp> cbop(cop);
if (singleMeshProc_ == -1)
{
@ -247,13 +221,13 @@ void Foam::meshToMeshNew::mapTgtToSrc
"List<Type>&"
") const"
) << "Supplied field size is not equal to source mesh size" << nl
<< " source mesh = " << srcToTgtCellAddr_.size() << nl
<< " target mesh = " << tgtToSrcCellAddr_.size() << nl
<< " source mesh = " << srcToTgtCellAddr_.size() << nl
<< " target mesh = " << tgtToSrcCellAddr_.size() << nl
<< " supplied field = " << result.size()
<< abort(FatalError);
}
combineBinaryOp<Type, CombineOp> cbop(cop);
multiplyWeightedOp<Type, CombineOp> cbop(cop);
if (singleMeshProc_ == -1)
{
@ -269,7 +243,6 @@ void Foam::meshToMeshNew::mapTgtToSrc
if (tgtAddress.size())
{
// result[cellI] = pTraits<Type>::zero;
result[cellI] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
@ -289,7 +262,6 @@ void Foam::meshToMeshNew::mapTgtToSrc
if (tgtAddress.size())
{
// result[cellI] = pTraits<Type>::zero;
result[cellI] *= (1.0 - sum(tgtWeight));
forAll(tgtAddress, i)
{
@ -357,140 +329,75 @@ Foam::tmp<Foam::Field<Type> > Foam::meshToMeshNew::mapTgtToSrc
template<class Type, class CombineOp>
void Foam::meshToMeshNew::interpolate
void Foam::meshToMeshNew::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result,
const bool interpPatches
GeometricField<Type, fvPatchField, volMesh>& result
) const
{
const fvMesh& mesh = field.mesh();
// clear any previously stored values
if (mesh.name() == srcRegionName_)
mapSrcToTgt(field, cop, result.internalField());
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
forAll(AMIList, i)
{
mapSrcToTgt(field, cop, result.internalField());
}
else if (mesh.name() == tgtRegionName_)
{
mapTgtToSrc(field, cop, result.internalField());
}
else
{
FatalErrorIn
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
const Field<Type>& srcField = field.boundaryField()[srcPatchI];
Field<Type>& tgtField = result.boundaryField()[tgtPatchI];
tgtField = pTraits<Type>::zero;
AMIList[i].interpolateToTarget
(
"void Foam::meshToMeshNew::interpolate"
"("
"const GeometricField<Type, fvPatchField, volMesh>&, "
"const CombineOp&, "
"GeometricField<Type, fvPatchField, volMesh>&, "
"const bool"
") const"
)
<< "Supplied field " << field.name() << " did not originate from "
<< "either the source or target meshes used to create this "
<< "interpolation object"
<< abort(FatalError);
}
if (interpPatches)
{
switch (method_)
{
case imMap:
{
result.boundaryField() == field.boundaryField();
break;
}
default:
{
notImplemented
(
"void Foam::meshToMeshNew::interpolate"
"("
"const GeometricField<Type, fvPatchField, volMesh>&, "
"const CombineOp&, "
"GeometricField<Type, fvPatchField, volMesh>&, "
"const bool"
") const - non-conformal patches"
)
// do something...
}
}
srcField,
multiplyWeightedOp<Type, CombineOp>(cop),
tgtField
);
}
}
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::interpolate
Foam::meshToMeshNew::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop,
const bool interpPatches
const CombineOp& cop
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& mesh = field.mesh();
const fvMesh& tgtMesh = static_cast<const fvMesh&>(tgtRegion_);
tmp<fieldType> tresult;
if (mesh.name() == srcRegionName_)
{
const fvMesh& tgtMesh =
mesh.time().lookupObject<fvMesh>(tgtRegionName_);
tresult =
new fieldType
tmp<fieldType> tresult
(
new fieldType
(
IOobject
(
IOobject
(
type() + "::interpolate(" + field.name() + ")",
tgtMesh.time().timeName(),
tgtMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
type() + ".interpolate(" + field.name() + ")",
tgtMesh.time().timeName(),
tgtMesh,
dimensioned<Type>
(
"zero",
field.dimensions(),
pTraits<Type>::zero
)
);
interpolate(field, cop, tresult(), interpPatches);
}
else if (mesh.name() == tgtRegionName_)
{
const fvMesh& srcMesh =
mesh.time().lookupObject<fvMesh>(srcRegionName_);
tresult =
new fieldType
IOobject::NO_READ,
IOobject::NO_WRITE
),
tgtMesh,
dimensioned<Type>
(
IOobject
(
type() + "::interpolate(" + field.name() + ")",
srcMesh.time().timeName(),
srcMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
srcMesh,
dimensioned<Type>
(
"zero",
field.dimensions(),
pTraits<Type>::zero
)
);
"zero",
field.dimensions(),
pTraits<Type>::zero
)
)
);
interpolate(field, cop, tresult(), interpPatches);
}
mapSrcToTgt(field, cop, tresult());
return tresult;
}
@ -498,44 +405,141 @@ Foam::meshToMeshNew::interpolate
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::interpolate
Foam::meshToMeshNew::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield,
const CombineOp& cop,
const bool interpPatches
const CombineOp& cop
) const
{
return
interpolate
(
tfield(),
combineBinaryOp<Type, CombineOp>(cop),
interpPatches
);
return mapSrcToTgt(tfield(), cop);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::interpolate
Foam::meshToMeshNew::mapSrcToTgt
(
const GeometricField<Type, fvPatchField, volMesh>& field
) const
{
return mapSrcToTgt(field, plusEqOp<Type>());
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::mapSrcToTgt
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield
) const
{
return mapSrcToTgt(tfield(), plusEqOp<Type>());
}
template<class Type, class CombineOp>
void Foam::meshToMeshNew::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const bool interpPatches
const CombineOp& cop,
GeometricField<Type, fvPatchField, volMesh>& result
) const
{
return interpolate(field, plusEqOp<Type>(), interpPatches);
mapTgtToSrc(field, cop, result.internalField());
const PtrList<AMIPatchToPatchInterpolation>& AMIList = patchAMIs();
forAll(AMIList, i)
{
label srcPatchI = srcPatchID_[i];
label tgtPatchI = tgtPatchID_[i];
Field<Type>& srcField = result.boundaryField()[srcPatchI];
const Field<Type>& tgtField = field.boundaryField()[tgtPatchI];
srcField = pTraits<Type>::zero;
AMIList[i].interpolateToSource
(
tgtField,
multiplyWeightedOp<Type, CombineOp>(cop),
srcField
);
}
}
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::mapTgtToSrc
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const CombineOp& cop
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const fvMesh& srcMesh = static_cast<const fvMesh&>(srcRegion_);
tmp<fieldType> tresult
(
new fieldType
(
IOobject
(
type() + ".interpolate(" + field.name() + ")",
srcMesh.time().timeName(),
srcMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
srcMesh,
dimensioned<Type>
(
"zero",
field.dimensions(),
pTraits<Type>::zero
)
)
);
mapTgtToSrc(field, cop, tresult());
return tresult;
}
template<class Type, class CombineOp>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield,
const CombineOp& cop
) const
{
return mapTgtToSrc(tfield(), cop);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::interpolate
Foam::meshToMeshNew::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield,
const bool interpPatches
const GeometricField<Type, fvPatchField, volMesh>& field
) const
{
return interpolate(tfield(), plusEqOp<Type>(), interpPatches);
return mapTgtToSrc(field, plusEqOp<Type>());
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::meshToMeshNew::mapTgtToSrc
(
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tfield
) const
{
return mapTgtToSrc(tfield(), plusEqOp<Type>());
}