52 x.setSize(sz +
y.size());
71 void Foam::meshToMesh::add
84 template<
class Type,
class CombineOp>
92 if (result.size() != tgtToSrcCellAddr_.size())
95 <<
"Supplied field size is not equal to target mesh size" <<
nl
96 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
97 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
98 <<
" supplied field = " << result.size()
104 if (singleMeshProc_ == -1)
113 const labelList& srcAddress = tgtToSrcCellAddr_[celli];
114 const scalarList& srcWeight = tgtToSrcCellWght_[celli];
116 if (srcAddress.size())
119 result[celli] *= (1.0 -
sum(srcWeight));
122 label srcI = srcAddress[i];
123 scalar w = srcWeight[i];
124 cbop(result[celli], celli, work[srcI], w);
133 const labelList& srcAddress = tgtToSrcCellAddr_[celli];
134 const scalarList& srcWeight = tgtToSrcCellWght_[celli];
136 if (srcAddress.size())
139 result[celli] *= (1.0 -
sum(srcWeight));
142 label srcI = srcAddress[i];
143 scalar w = srcWeight[i];
144 cbop(result[celli], celli, srcField[srcI], w);
152 template<
class Type,
class CombineOp>
157 const CombineOp& cop,
161 if (result.size() != tgtToSrcCellAddr_.size())
164 <<
"Supplied field size is not equal to target mesh size" <<
nl
165 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
166 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
167 <<
" supplied field = " << result.size()
173 if (singleMeshProc_ == -1)
178 mapSrcToTgt(srcField, cop, result);
195 const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
196 const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
197 const pointList& srcVec = tgtToSrcCellVec_[cellI];
199 if (srcAddress.size())
201 result[cellI] *= (1.0 -
sum(srcWeight));
204 label srcI = srcAddress[i];
205 scalar w = srcWeight[i];
206 const vector& v = srcVec[i];
207 const Type srcVal = work[srcI]+(workGrad[srcI]&v);
208 cbop(result[cellI], cellI, srcVal, w);
215 if (tgtToSrcCellVec_.empty())
218 mapSrcToTgt(srcField, cop, result);
224 const labelList& srcAddress = tgtToSrcCellAddr_[cellI];
225 const scalarList& srcWeight = tgtToSrcCellWght_[cellI];
226 const pointList& srcVec = tgtToSrcCellVec_[cellI];
228 if (srcAddress.size())
231 result[cellI] *= (1.0 -
sum(srcWeight));
234 label srcI = srcAddress[i];
235 scalar w = srcWeight[i];
236 const vector& v = srcVec[i];
237 const Type srcVal = srcField[srcI]+(srcGradField[srcI]&v);
238 cbop(result[cellI], cellI, srcVal, w);
246 template<
class Type,
class CombineOp>
257 tgtToSrcCellAddr_.size(),
262 mapSrcToTgt(srcField, cop, tresult.
ref());
268 template<
class Type,
class CombineOp>
275 return mapSrcToTgt(tsrcField(), cop);
295 return mapSrcToTgt(tsrcField());
299 template<
class Type,
class CombineOp>
303 const CombineOp& cop,
307 if (result.size() != srcToTgtCellAddr_.size())
310 <<
"Supplied field size is not equal to source mesh size" <<
nl
311 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
312 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
313 <<
" supplied field = " << result.size()
319 if (singleMeshProc_ == -1)
328 const labelList& tgtAddress = srcToTgtCellAddr_[celli];
329 const scalarList& tgtWeight = srcToTgtCellWght_[celli];
331 if (tgtAddress.size())
333 result[celli] *= (1.0 -
sum(tgtWeight));
336 label tgtI = tgtAddress[i];
337 scalar w = tgtWeight[i];
338 cbop(result[celli], celli, work[tgtI], w);
347 const labelList& tgtAddress = srcToTgtCellAddr_[celli];
348 const scalarList& tgtWeight = srcToTgtCellWght_[celli];
350 if (tgtAddress.size())
352 result[celli] *= (1.0 -
sum(tgtWeight));
355 label tgtI = tgtAddress[i];
356 scalar w = tgtWeight[i];
357 cbop(result[celli], celli, tgtField[tgtI], w);
365 template<
class Type,
class CombineOp>
370 const CombineOp& cop,
374 if (result.size() != srcToTgtCellAddr_.size())
377 <<
"Supplied field size is not equal to source mesh size" <<
nl
378 <<
" source mesh = " << srcToTgtCellAddr_.size() <<
nl
379 <<
" target mesh = " << tgtToSrcCellAddr_.size() <<
nl
380 <<
" supplied field = " << result.size()
386 if (singleMeshProc_ == -1)
391 mapTgtToSrc(tgtField, cop, result);
408 const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
409 const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
410 const pointList& tgtVec = srcToTgtCellVec_[cellI];
412 if (tgtAddress.size())
414 result[cellI] *= (1.0 -
sum(tgtWeight));
417 label tgtI = tgtAddress[i];
418 scalar w = tgtWeight[i];
419 const vector& v = tgtVec[i];
420 const Type tgtVal = work[tgtI]+(workGrad[tgtI]&v);
421 cbop(result[cellI], cellI, tgtVal, w);
430 const labelList& tgtAddress = srcToTgtCellAddr_[cellI];
431 const scalarList& tgtWeight = srcToTgtCellWght_[cellI];
432 const pointList& tgtVec = srcToTgtCellVec_[cellI];
434 if (tgtAddress.size())
436 result[cellI] *= (1.0 -
sum(tgtWeight));
439 label tgtI = tgtAddress[i];
440 scalar w = tgtWeight[i];
441 const vector& v = tgtVec[i];
442 const Type tgtVal = tgtField[tgtI]+(tgtGradField[tgtI]&v);
443 cbop(result[cellI], cellI, tgtVal, w);
451 template<
class Type,
class CombineOp>
462 srcToTgtCellAddr_.size(),
467 mapTgtToSrc(tgtField, cop, tresult.
ref());
473 template<
class Type,
class CombineOp>
480 return mapTgtToSrc(ttgtField(), cop);
504 template<
class Type,
class CombineOp>
505 void Foam::meshToMesh::mapInternalSrcToTgt
508 const CombineOp& cop,
510 const bool secondOrder
530 template<
class Type,
class CombineOp>
531 void Foam::meshToMesh::mapAndOpSrcToTgt
534 const Field<Type>& srcField,
535 Field<Type>& tgtField,
539 tgtField = Type(
Zero);
541 AMI.interpolateToTarget
544 multiplyWeightedOp<Type, CombineOp>(cop),
551 template<
class Type,
class CombineOp>
555 const CombineOp& cop,
557 const bool secondOrder
560 mapInternalSrcToTgt(
field, cop, result, secondOrder);
569 label srcPatchi = srcPatchID_[i];
570 label tgtPatchi = tgtPatchID_[i];
585 AMIList[i].singlePatchProc(),
587 AMIList[i].singlePatchProc() == -1
588 ? &AMIList[i].srcMap()
591 AMIList[i].tgtAddress(),
592 AMIList[i].tgtWeights()
603 mapAndOpSrcToTgt(AMIList[i], srcField, tgtField, cop);
606 forAll(cuttingPatches_, i)
608 label patchi = cuttingPatches_[i];
615 template<
class Type,
class CombineOp>
620 const CombineOp& cop,
621 const bool secondOrder
626 const fvMesh& tgtMesh =
static_cast<const fvMesh&
>(tgtRegion_);
629 const typename fieldType::Boundary& srcBfld =
630 field.boundaryField();
639 label srcPatchi = srcPatchID_[i];
640 label tgtPatchi = tgtPatchID_[i];
642 if (!tgtPatchFields.set(tgtPatchi))
662 forAll(tgtPatchFields, tgtPatchi)
664 if (!tgtPatchFields.set(tgtPatchi))
687 type() +
":interpolate(" +
field.name() +
")",
700 mapSrcToTgt(
field, cop, tresult.ref(), secondOrder);
706 template<
class Type,
class CombineOp>
711 const CombineOp& cop,
712 const bool secondOrder
715 return mapSrcToTgt(tfield(), cop, secondOrder);
724 const bool secondOrder
736 const bool secondOrder
743 template<
class Type,
class CombineOp>
744 void Foam::meshToMesh::mapInternalTgtToSrc
747 const CombineOp& cop,
749 const bool secondOrder
769 template<
class Type,
class CombineOp>
770 void Foam::meshToMesh::mapAndOpTgtToSrc
773 Field<Type>& srcField,
774 const Field<Type>& tgtField,
778 srcField = Type(
Zero);
780 AMI.interpolateToSource
783 multiplyWeightedOp<Type, CombineOp>(cop),
790 template<
class Type,
class CombineOp>
794 const CombineOp& cop,
796 const bool secondOrder
799 mapInternalTgtToSrc(
field, cop, result, secondOrder);
805 label srcPatchi = srcPatchID_[i];
806 label tgtPatchi = tgtPatchID_[i];
822 AMIList[i].singlePatchProc(),
824 AMIList[i].singlePatchProc() == -1
825 ? &AMIList[i].tgtMap()
828 AMIList[i].srcAddress(),
829 AMIList[i].srcWeights()
839 mapAndOpTgtToSrc(AMIList[i], srcField, tgtField, cop);
842 forAll(cuttingPatches_, i)
844 label patchi = cuttingPatches_[i];
851 template<
class Type,
class CombineOp>
856 const CombineOp& cop,
857 const bool secondOrder
862 const fvMesh& srcMesh =
static_cast<const fvMesh&
>(srcRegion_);
865 const typename fieldType::Boundary& tgtBfld =
866 field.boundaryField();
875 label srcPatchi = srcPatchID_[i];
876 label tgtPatchi = tgtPatchID_[i];
878 if (!srcPatchFields.set(tgtPatchi))
898 forAll(srcPatchFields, srcPatchi)
900 if (!srcPatchFields.set(srcPatchi))
923 type() +
":interpolate(" +
field.name() +
")",
936 mapTgtToSrc(
field, cop, tresult.ref(), secondOrder);
942 template<
class Type,
class CombineOp>
947 const CombineOp& cop,
948 const bool secondOrder
951 return mapTgtToSrc(tfield(), cop, secondOrder);
960 const bool secondOrder
972 const bool secondOrder