34 template<
class Type,
class CombineOp>
37 const scalar lowWeightCorrection,
53 result[facei] = defaultValues[facei];
62 cop(result[facei], facei,
fld[slots[i]], weights[i]);
76 cop(result[facei], facei,
fld[slots[i]], weights[i]);
86 const bool interpolateToSource,
87 const UList<Type>&
fld,
89 const UList<Type>& defaultValues
95 (interpolateToSource ? srcAddress_ : tgtAddress_),
96 (interpolateToSource ? srcWeights_ : tgtWeights_),
97 (interpolateToSource ? srcWeightsSum_ : tgtWeightsSum_),
99 multiplyWeightedOp<Type, plusEqOp<Type>>(plusEqOp<Type>()),
106 template<
class Type,
class CombineOp>
110 const CombineOp& cop,
115 addProfiling(ami,
"AMIInterpolation::interpolateToTarget");
117 if (
fld.size() != srcAddress_.size())
120 <<
"Supplied field size is not equal to source patch size" <<
nl 121 <<
" source patch = " << srcAddress_.size() <<
nl 122 <<
" target patch = " << tgtAddress_.size() <<
nl 123 <<
" supplied field = " <<
fld.size()
128 (lowWeightCorrection_ > 0)
129 && (defaultValues.
size() != tgtAddress_.size())
133 <<
"Employing default values when sum of weights falls below " 134 << lowWeightCorrection_
135 <<
" but supplied default field size is not equal to target " 136 <<
"patch size" <<
nl 137 <<
" default values = " << defaultValues.
size() <<
nl 138 <<
" target patch = " << tgtAddress_.size() <<
nl 142 result.
setSize(tgtAddress_.size());
145 if (distributed() && srcMapPtr_)
147 const mapDistribute& map = srcMapPtr_();
149 if (map.comm() == -1)
154 work.resize_nocopy(map.constructSize());
155 SubList<Type>(work,
fld.size()) =
fld;
156 map.distribute(work);
161 lowWeightCorrection_,
165 (distributed() ? work :
fld),
173 template<
class Type,
class CombineOp>
177 const CombineOp& cop,
182 addProfiling(ami,
"AMIInterpolation::interpolateToSource");
184 if (
fld.size() != tgtAddress_.size())
187 <<
"Supplied field size is not equal to target patch size" <<
nl 188 <<
" source patch = " << srcAddress_.size() <<
nl 189 <<
" target patch = " << tgtAddress_.size() <<
nl 190 <<
" supplied field = " <<
fld.size()
195 (lowWeightCorrection_ > 0)
196 && (defaultValues.
size() != srcAddress_.size())
200 <<
"Employing default values when sum of weights falls below " 201 << lowWeightCorrection_
202 <<
" but number of default values is not equal to source " 203 <<
"patch size" <<
nl 204 <<
" default values = " << defaultValues.
size() <<
nl 205 <<
" source patch = " << srcAddress_.size() <<
nl 209 result.
setSize(srcAddress_.size());
212 if (distributed() && tgtMapPtr_)
214 const mapDistribute& map = tgtMapPtr_();
216 if (map.comm() == -1)
221 work.resize_nocopy(map.constructSize());
222 SubList<Type>(work,
fld.size()) =
fld;
223 map.distribute(work);
228 lowWeightCorrection_,
232 (distributed() ? work :
fld),
240 template<
class Type,
class CombineOp>
244 const CombineOp& cop,
262 template<
class Type,
class CombineOp>
266 const CombineOp& cop,
270 return interpolateToSource(tFld(), cop, defaultValues);
274 template<
class Type,
class CombineOp>
278 const CombineOp& cop,
296 template<
class Type,
class CombineOp>
300 const CombineOp& cop,
304 return interpolateToTarget(tFld(), cop, defaultValues);
326 return interpolateToSource(tFld(),
plusEqOp<Type>(), defaultValues);
348 return interpolateToTarget(tFld(),
plusEqOp<Type>(), defaultValues);
void size(const label n)
Older name for setAddressableSize.
Type weightedSum(const UList< scalar > &weights, const UList< Type > &fld)
The local weighted sum (integral) of a field, using the mag() of the weights.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
constexpr char nl
The newline '\n' character (0x0a)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
#define addProfiling(Name,...)
Define profiling trigger with specified name and description string. The description is generated by ...
#define forAll(list, i)
Loop across all elements in list.
void setSize(const label n)
Alias for resize()
void interpolateToTarget(const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues=UList< Type >::null()) const
Interpolate from source to target with supplied op to combine existing value with remote value and we...
errorManip< error > abort(error &err)
static void weightedSum(const scalar lowWeightCorrection, const labelListList &allSlots, const scalarListList &allWeights, const scalarField &weightsSum, const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues)
Weighted sum of contributions.
void interpolateToSource(const UList< Type > &fld, const CombineOp &cop, List< Type > &result, const UList< Type > &defaultValues=UList< Type >::null()) const
Interpolate from target to source with supplied op to combine existing value with remote value and we...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class for managing temporary objects.
scalar lowWeightCorrection() const
Threshold weight below which interpolation is deactivated.
static constexpr const zero Zero
Global zero (0)