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());
147 const mapDistribute& map = srcMapPtr_();
149 map.distribute(work);
154 lowWeightCorrection_,
158 (distributed() ? work :
fld),
166 template<
class Type,
class CombineOp>
170 const CombineOp& cop,
175 addProfiling(ami,
"AMIInterpolation::interpolateToSource");
177 if (
fld.size() != tgtAddress_.size())
180 <<
"Supplied field size is not equal to target patch size" <<
nl 181 <<
" source patch = " << srcAddress_.size() <<
nl 182 <<
" target patch = " << tgtAddress_.size() <<
nl 183 <<
" supplied field = " <<
fld.size()
188 (lowWeightCorrection_ > 0)
189 && (defaultValues.
size() != srcAddress_.size())
193 <<
"Employing default values when sum of weights falls below " 194 << lowWeightCorrection_
195 <<
" but number of default values is not equal to source " 196 <<
"patch size" <<
nl 197 <<
" default values = " << defaultValues.
size() <<
nl 198 <<
" source patch = " << srcAddress_.size() <<
nl 202 result.
setSize(srcAddress_.size());
207 const mapDistribute& map = tgtMapPtr_();
209 map.distribute(work);
214 lowWeightCorrection_,
218 (distributed() ? work :
fld),
226 template<
class Type,
class CombineOp>
230 const CombineOp& cop,
248 template<
class Type,
class CombineOp>
252 const CombineOp& cop,
256 return interpolateToSource(tFld(), cop, defaultValues);
260 template<
class Type,
class CombineOp>
264 const CombineOp& cop,
282 template<
class Type,
class CombineOp>
286 const CombineOp& cop,
290 return interpolateToTarget(tFld(), cop, defaultValues);
312 return interpolateToSource(tFld(),
plusEqOp<Type>(), defaultValues);
334 return interpolateToTarget(tFld(),
plusEqOp<Type>(), defaultValues);
void size(const label n)
Older name for setAddressableSize.
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)