35Type Foam::PatchFunction1Types::Sampled<Type>::getAverage
43 return dict.get<Type>(
"average");
56 const word& redirectType,
57 const word& entryName,
65 setAverage_(
dict.getOrDefault(
"setAverage", false)),
66 average_(getAverage(
dict, setAverage_)),
79 const Sampled<Type>&
rhs,
85 fieldName_(
rhs.fieldName_),
110 if (this->sameRegion())
114 return thisMesh.template lookupObject<fieldType>(fieldName_);
119 return nbrMesh.template lookupObject<fieldType>(
fieldName_);
129 if (this->sameRegion())
133 return thisMesh.template foundObject<fieldType>(fieldName_);
165 auto& newValues = tnewValues.ref();
167 if (!haveSampleField())
175 switch (this->
mode())
179 const mapDistribute& distMap = this->map();
181 if (interpolationScheme_ != interpolationCell<Type>::typeName)
185 distMap.reverseDistribute
199 interpolationScheme_,
203 const auto& interp = *interpolator;
205 newValues.setSize(
samples.size(), pTraits<Type>::max);
210 newValues[celli] = interp.interpolate
220 newValues = sampleField();
222 distMap.distribute(newValues);
229 const label nbrPatchID =
235 <<
"Unable to find sample patch " << this->samplePatch()
236 <<
" in region " << this->sampleRegion()
241 const fieldType& nbrField = sampleField();
243 newValues = nbrField.boundaryField()[nbrPatchID];
244 this->distribute(newValues);
250 Field<Type> allValues(nbrMesh.
nFaces(),
Zero);
252 const fieldType& nbrField = sampleField();
254 for (
const fvPatchField<Type>& pf : nbrField.boundaryField())
256 label faceStart = pf.patch().start();
260 allValues[faceStart++] = pf[facei];
264 this->distribute(allValues);
265 newValues.transfer(allValues);
272 <<
"Unknown sampling mode: " << this->
mode() <<
nl
282 if (this->faceValues())
295 if (
mag(averagePsi) > 0.5*
mag(average_))
297 newValues *=
mag(average_)/
mag(averagePsi);
301 newValues += (average_ - averagePsi);
336 os.writeEntry(
"field", fieldName_);
339 os.writeEntry(
"setAverage",
"true");
340 os.writeEntry(
"average", average_);
343 os.writeEntry(
"interpolationScheme", interpolationScheme_);
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Generic GeometricField class.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
PatchFunction1 to sample an existing field.
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
virtual void writeData(Ostream &os) const
Write in dictionary format.
const Type average_
Average value the mapped field is adjusted to maintain if setAverage_ is set true.
bool haveSampleField() const
Field to sample. Either on my or nbr mesh.
virtual tmp< Field< Type > > value(const scalar x) const
Return sampled value.
Sampled(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name and dictionary.
word fieldName_
Name of the field.
const GeometricField< Type, fvPatchField, volMesh > & sampleField() const
Field to sample. Either on my or nbr mesh.
word interpolationScheme_
Interpolation scheme to use for nearestcell mode.
const bool setAverage_
If true adjust the mapped field to maintain average value average_.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
const polyPatch const word const word & entryName
virtual void writeData(Ostream &os) const
Write in dictionary format.
const polyPatch const word const word const dictionary & dict
const polyPatch const word const word const dictionary const bool faceValues
static int & msgType() noexcept
Message tag of standard messages.
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Mesh data needed to do the Finite Volume discretisation.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Uses the cell value for any location within the cell.
static autoPtr< interpolation< Type > > New(const word &interpolationType, const GeometricField< Type, fvPatchField, volMesh > &psi)
Return a reference to the specified interpolation scheme.
Class containing processor-to-processor mapping information.
void reverseDistribute(const label constructSize, List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute List data using default commsType, default flip/negate operator.
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
tmp< pointField > samplePoints(const pointField &) const
Get the sample points given the face points.
const mapDistribute & map() const
Return reference to the parallel distribution map.
bool sameRegion() const noexcept
Cached sampleRegion != mesh.name().
const polyPatch & patch_
Patch to sample.
@ NEARESTCELL
nearest cell containing sample
@ NEARESTPATCHFACE
nearest face on selected patch
@ NEARESTPATCHFACEAMI
nearest patch face + AMI interpolation
@ NEARESTFACE
nearest face
const polyMesh & sampleMesh() const
Get the region mesh.
virtual void write(Ostream &os) const
Write as a dictionary.
mappedPatchBase(const polyPatch &)
Construct from patch.
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE).
sampleMode mode() const noexcept
What to sample.
const word & sampleRegion() const
Region to sample.
A traits class, which is primarily used for primitives and vector-space.
const polyPatch & patch() const noexcept
Reference to the patch.
label size() const
Number of faces or points on the patch.
const word & name() const noexcept
The patch name.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A patch is a list of labels that address the faces in the global face list.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
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.
Type gWeightedAverage(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted average of a field, using the mag() of the weights.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)