52template<
class Type,
class CombineOp>
60 if (result.
size() != tgtToSrcCellAddr_.size())
63 <<
"Supplied field size is not equal to target mesh size" <<
nl
64 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
65 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
66 <<
" supplied field = " << result.
size()
72 if (singleMeshProc_ == -1)
81 const labelList& srcAddress = tgtToSrcCellAddr_[celli];
82 const scalarList& srcWeight = tgtToSrcCellWght_[celli];
84 if (srcAddress.
size())
87 result[celli] *= (1.0 -
sum(srcWeight));
90 label srcI = srcAddress[i];
91 scalar w = srcWeight[i];
92 cbop(result[celli], celli, work[srcI], w);
101 const labelList& srcAddress = tgtToSrcCellAddr_[celli];
102 const scalarList& srcWeight = tgtToSrcCellWght_[celli];
104 if (srcAddress.
size())
107 result[celli] *= (1.0 -
sum(srcWeight));
110 label srcI = srcAddress[i];
111 scalar w = srcWeight[i];
112 cbop(result[celli], celli, srcField[srcI], w);
120template<
class Type,
class CombineOp>
125 const CombineOp& cop,
129 if (result.
size() != tgtToSrcCellAddr_.size())
132 <<
"Supplied field size is not equal to target mesh size" <<
nl
133 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
134 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
135 <<
" supplied field = " << result.
size()
141 if (singleMeshProc_ == -1)
146 mapSrcToTgt(srcField, cop, result);
163 const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
164 const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
165 const pointList& srcVec = tgtToSrcCellVec_[cellI];
167 if (srcAddress.
size())
169 result[cellI] *= (1.0 -
sum(srcWeight));
172 label srcI = srcAddress[i];
173 scalar w = srcWeight[i];
174 const vector& v = srcVec[i];
175 const Type srcVal = work[srcI]+(workGrad[srcI]&v);
176 cbop(result[cellI], cellI, srcVal, w);
183 if (tgtToSrcCellVec_.empty())
186 mapSrcToTgt(srcField, cop, result);
192 const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
193 const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
194 const pointList& srcVec = tgtToSrcCellVec_[cellI];
196 if (srcAddress.
size())
199 result[cellI] *= (1.0 -
sum(srcWeight));
202 label srcI = srcAddress[i];
203 scalar w = srcWeight[i];
204 const vector& v = srcVec[i];
205 const Type srcVal = srcField[srcI]+(srcGradField[srcI]&v);
206 cbop(result[cellI], cellI, srcVal, w);
214template<
class Type,
class CombineOp>
225 tgtToSrcCellAddr_.size(),
230 mapSrcToTgt(srcField, cop, tresult.
ref());
236template<
class Type,
class CombineOp>
243 return mapSrcToTgt(tsrcField(), cop);
263 return mapSrcToTgt(tsrcField());
267template<
class Type,
class CombineOp>
271 const CombineOp& cop,
275 if (result.
size() != srcToTgtCellAddr_.size())
278 <<
"Supplied field size is not equal to source mesh size" <<
nl
279 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
280 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
281 <<
" supplied field = " << result.
size()
287 if (singleMeshProc_ == -1)
296 const labelList& tgtAddress = srcToTgtCellAddr_[celli];
297 const scalarList& tgtWeight = srcToTgtCellWght_[celli];
299 if (tgtAddress.
size())
301 result[celli] *= (1.0 -
sum(tgtWeight));
304 label tgtI = tgtAddress[i];
305 scalar w = tgtWeight[i];
306 cbop(result[celli], celli, work[tgtI], w);
315 const labelList& tgtAddress = srcToTgtCellAddr_[celli];
316 const scalarList& tgtWeight = srcToTgtCellWght_[celli];
318 if (tgtAddress.
size())
320 result[celli] *= (1.0 -
sum(tgtWeight));
323 label tgtI = tgtAddress[i];
324 scalar w = tgtWeight[i];
325 cbop(result[celli], celli, tgtField[tgtI], w);
333template<
class Type,
class CombineOp>
338 const CombineOp& cop,
342 if (result.
size() != srcToTgtCellAddr_.size())
345 <<
"Supplied field size is not equal to source mesh size" <<
nl
346 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
347 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
348 <<
" supplied field = " << result.
size()
354 if (singleMeshProc_ == -1)
359 mapTgtToSrc(tgtField, cop, result);
376 const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
377 const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
378 const pointList& tgtVec = srcToTgtCellVec_[cellI];
380 if (tgtAddress.
size())
382 result[cellI] *= (1.0 -
sum(tgtWeight));
385 label tgtI = tgtAddress[i];
386 scalar w = tgtWeight[i];
387 const vector& v = tgtVec[i];
388 const Type tgtVal = work[tgtI]+(workGrad[tgtI]&v);
389 cbop(result[cellI], cellI, tgtVal, w);
398 const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
399 const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
400 const pointList& tgtVec = srcToTgtCellVec_[cellI];
402 if (tgtAddress.
size())
404 result[cellI] *= (1.0 -
sum(tgtWeight));
407 label tgtI = tgtAddress[i];
408 scalar w = tgtWeight[i];
409 const vector& v = tgtVec[i];
410 const Type tgtVal = tgtField[tgtI]+(tgtGradField[tgtI]&v);
411 cbop(result[cellI], cellI, tgtVal, w);
419template<
class Type,
class CombineOp>
430 srcToTgtCellAddr_.size(),
435 mapTgtToSrc(tgtField, cop, tresult.
ref());
441template<
class Type,
class CombineOp>
448 return mapTgtToSrc(ttgtField(), cop);
472template<
class Type,
class CombineOp>
473void Foam::meshToMesh::mapInternalSrcToTgt
476 const CombineOp& cop,
478 const bool secondOrder
498template<
class Type,
class CombineOp>
499void Foam::meshToMesh::mapAndOpSrcToTgt
502 const Field<Type>& srcField,
503 Field<Type>& tgtField,
507 tgtField = Type(
Zero);
509 AMI.interpolateToTarget
512 multiplyWeightedOp<Type, CombineOp>(cop),
519template<
class Type,
class CombineOp>
523 const CombineOp& cop,
525 const bool secondOrder
528 mapInternalSrcToTgt(
field, cop, result, secondOrder);
536 label srcPatchi = srcPatchID_[i];
537 label tgtPatchi = tgtPatchID_[i];
552 AMIList[i].singlePatchProc(),
554 AMIList[i].singlePatchProc() == -1
555 ? &AMIList[i].srcMap()
558 AMIList[i].tgtAddress(),
559 AMIList[i].tgtWeights()
570 mapAndOpSrcToTgt(AMIList[i], srcField, tgtField, cop);
573 forAll(cuttingPatches_, i)
575 label patchi = cuttingPatches_[i];
582template<
class Type,
class CombineOp>
587 const CombineOp& cop,
588 const bool secondOrder
591 const fvMesh& tgtMesh =
static_cast<const fvMesh&
>(tgtRegion_);
594 const auto& srcBfld =
field.boundaryField();
603 label srcPatchi = srcPatchID_[i];
604 label tgtPatchi = tgtPatchID_[i];
606 if (!tgtPatchFields.
set(tgtPatchi))
626 forAll(tgtPatchFields, tgtPatchi)
628 if (!tgtPatchFields.
set(tgtPatchi))
650 type() +
":interpolate(" +
field.name() +
")",
662 mapSrcToTgt(
field, cop, tresult.ref(), secondOrder);
668template<
class Type,
class CombineOp>
673 const CombineOp& cop,
674 const bool secondOrder
677 return mapSrcToTgt(tfield(), cop, secondOrder);
686 const bool secondOrder
698 const bool secondOrder
705template<
class Type,
class CombineOp>
706void Foam::meshToMesh::mapInternalTgtToSrc
709 const CombineOp& cop,
711 const bool secondOrder
731template<
class Type,
class CombineOp>
732void Foam::meshToMesh::mapAndOpTgtToSrc
735 Field<Type>& srcField,
736 const Field<Type>& tgtField,
740 srcField = Type(
Zero);
742 AMI.interpolateToSource
745 multiplyWeightedOp<Type, CombineOp>(cop),
752template<
class Type,
class CombineOp>
756 const CombineOp& cop,
758 const bool secondOrder
761 mapInternalTgtToSrc(
field, cop, result, secondOrder);
767 label srcPatchi = srcPatchID_[i];
768 label tgtPatchi = tgtPatchID_[i];
784 AMIList[i].singlePatchProc(),
786 AMIList[i].singlePatchProc() == -1
787 ? &AMIList[i].tgtMap()
790 AMIList[i].srcAddress(),
791 AMIList[i].srcWeights()
801 mapAndOpTgtToSrc(AMIList[i], srcField, tgtField, cop);
804 forAll(cuttingPatches_, i)
806 label patchi = cuttingPatches_[i];
813template<
class Type,
class CombineOp>
818 const CombineOp& cop,
819 const bool secondOrder
822 const fvMesh& srcMesh =
static_cast<const fvMesh&
>(srcRegion_);
825 const auto& tgtBfld =
field.boundaryField();
834 label srcPatchi = srcPatchID_[i];
835 label tgtPatchi = tgtPatchID_[i];
837 if (!srcPatchFields.
set(tgtPatchi))
857 forAll(srcPatchFields, srcPatchi)
859 if (!srcPatchFields.
set(srcPatchi))
881 type() +
":interpolate(" +
field.name() +
")",
893 mapTgtToSrc(
field, cop, tresult.ref(), secondOrder);
899template<
class Type,
class CombineOp>
904 const CombineOp& cop,
905 const bool secondOrder
908 return mapTgtToSrc(tfield(), cop, secondOrder);
917 const bool secondOrder
929 const bool secondOrder
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A templated direct mapper for the given FieldMapper type.
Generic templated field type.
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
static word timeName(const scalar t, const int precision=precision_)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
FieldMapper with weighted mapping from (optionally remote) quantities.
Sums a given list of (at least two or more) fields and outputs the result into a new field,...
Mesh data needed to do the Finite Volume discretisation.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const Time & time() const
Return the top-level database.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
const fvPatch & patch() const
Return patch.
Class containing processor-to-processor mapping information.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
void mapTgtToSrc(const UList< Type > &tgtFld, const CombineOp &cop, List< Type > &result) const
Map field from tgt to src mesh with defined operation.
void mapSrcToTgt(const UList< Type > &srcFld, const CombineOp &cop, List< Type > &result) const
Map field from src to tgt mesh with defined operation.
label nCells() const noexcept
Number of mesh cells.
A class for managing temporary objects.
type
Volume classification types.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Calculate the gradient of the given field.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
List< label > labelList
A List of labels.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
AMIInterpolation AMIPatchToPatchInterpolation
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.