37 const dictionary&
dict,
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_),
86 setAverage_(rhs.setAverage_),
87 average_(rhs.average_),
88 interpolationScheme_(rhs.interpolationScheme_)
110 if (this->sameRegion())
114 return thisMesh.template lookupObject<fieldType>(fieldName_);
118 const fvMesh& nbrMesh = refCast<const fvMesh>(this->sampleMesh());
119 return nbrMesh.template lookupObject<fieldType>(fieldName_);
129 if (this->sameRegion())
133 return thisMesh.template foundObject<fieldType>(fieldName_);
137 const fvMesh& nbrMesh = refCast<const fvMesh>(this->sampleMesh());
138 return nbrMesh.template foundObject<fieldType>(fieldName_);
156 const fvMesh& thisMesh = refCast<const fvMesh>
160 const fvMesh& nbrMesh = refCast<const fvMesh>(this->sampleMesh());
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;
210 newValues[celli] = interp.interpolate
220 newValues = sampleField();
222 distMap.distribute(newValues);
229 const label nbrPatchID =
230 nbrMesh.boundaryMesh().findPatchID(this->samplePatch());
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())
288 averagePsi =
gSum(magSf*newValues)/
gSum(magSf);
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_);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
const GeometricField< Type, fvPatchField, volMesh > & sampleField() const
Field to sample. Either on my or nbr mesh.
virtual void writeData(Ostream &os) const
Write in dictionary format.
nearest face on selected patch
static int incrMsgType(int val=1) noexcept
Increment the message tag for standard messages.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const polyPatch & patch_
Patch to sample.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static autoPtr< interpolation< Type > > New(const word &interpolationType, const GeometricField< Type, fvPatchField, volMesh > &psi)
Return a reference to the specified interpolation scheme.
constexpr char nl
The newline '\n' character (0x0a)
scalarField samples(nIntervals, Zero)
PatchFunction1 to sample an existing field.
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.
static int & msgType() noexcept
Message tag of standard messages.
word interpolationScheme_
Interpolation scheme to use for nearestcell mode.
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
#define forAll(list, i)
Loop across all elements in list.
nearest patch face + AMI interpolation
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
bool haveSampleField() const
Field to sample. Either on my or nbr mesh.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Type gSum(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Sampled(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name and dictionary.
const polyMesh & mesh() const noexcept
Return the mesh reference.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
errorManip< error > abort(error &err)
virtual void writeData(Ostream &os) const
Write in dictionary format.
const word & name() const noexcept
The patch name.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
virtual tmp< Field< Type > > value(const scalar x) const
Return sampled value.
OBJstream os(runTime.globalPath()/outputName)
virtual void write(Ostream &os) const
Write as a dictionary.
sampleMode mode() const noexcept
What to sample.
label nCells() const noexcept
Number of mesh cells.
Type gAverage(const FieldField< Field, Type > &f)
Mesh data needed to do the Finite Volume discretisation.
nearest cell containing sample
const std::string patch
OpenFOAM patch number as a std::string.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Mesh consisting of general polyhedral cells.
A class for managing temporary objects.
A patch is a list of labels that address the faces in the global face list.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Uses the cell value for any location within the cell.
static constexpr const zero Zero
Global zero (0)