Go to the documentation of this file.
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_)),
69 if (this->
mode() == mappedPatchBase::NEARESTCELL)
71 dict.readEntry(
"interpolationScheme", 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_);
154 int oldTag = UPstream::msgType();
155 UPstream::msgType() = oldTag + 1;
157 const fvMesh& thisMesh = refCast<const fvMesh>
161 const fvMesh& nbrMesh = refCast<const fvMesh>(this->sampleMesh());
166 auto& newValues = tnewValues.ref();
168 if (!haveSampleField())
171 UPstream::msgType() = oldTag;
172 newValues.setSize(this->mappedPatchBase::patch_.size());
177 switch (this->
mode())
179 case mappedPatchBase::NEARESTCELL:
201 interpolationScheme_,
205 const auto& interp = *interpolator;
212 newValues[celli] = interp.interpolate
222 newValues = sampleField();
228 case mappedPatchBase::NEARESTPATCHFACE:
229 case mappedPatchBase::NEARESTPATCHFACEAMI:
231 const label nbrPatchID =
237 <<
"Unable to find sample patch " << this->samplePatch()
238 <<
" in region " << this->sampleRegion()
239 <<
" for patch " << this->mappedPatchBase::patch_.name() <<
nl
243 const fieldType& nbrField = sampleField();
245 newValues = nbrField.boundaryField()[nbrPatchID];
246 this->distribute(newValues);
250 case mappedPatchBase::NEARESTFACE:
254 const fieldType& nbrField = sampleField();
258 label faceStart = pf.patch().start();
262 allValues[faceStart++] = pf[facei];
266 this->distribute(allValues);
267 newValues.transfer(allValues);
274 <<
"Unknown sampling mode: " << this->
mode() <<
nl
284 if (this->faceValues())
288 mag(this->mappedPatchBase::patch_.faceAreas())
290 averagePsi =
gSum(magSf*newValues)/
gSum(magSf);
297 if (
mag(averagePsi) > 0.5*
mag(average_))
299 newValues *=
mag(average_)/
mag(averagePsi);
303 newValues += (average_ - averagePsi);
308 UPstream::msgType() = oldTag;
339 os.writeEntry(
"field", fieldName_);
342 os.writeEntry(
"setAverage",
"true");
343 os.writeEntry(
"average", average_);
346 os.writeEntry(
"interpolationScheme", interpolationScheme_);
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Sampled(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name and dictionary.
A class for handling words, derived from Foam::string.
const bool setAverage_
If true adjust the mapped field to maintain average value average_.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
Type gAverage(const FieldField< Field, Type > &f)
const GeometricField< Type, fvPatchField, volMesh > & sampleField() const
Field to sample. Either on my or nbr mesh.
const bool writeData(pdfDictionary.get< bool >("writeData"))
word interpolationScheme_
Interpolation scheme to use for nearestcell mode.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Type gSum(const FieldField< Field, Type > &f)
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Mesh consisting of general polyhedral cells.
word fieldName_
Name of the field.
#define forAll(list, i)
Loop across all elements in list.
Uses the cell value for any point in the cell.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
label nCells() const noexcept
Number of mesh cells.
bool haveSampleField() const
Field to sample. Either on my or nbr mesh.
const polyMesh & mesh() const noexcept
Return the mesh reference.
A patch is a list of labels that address the faces in the global face list.
Class containing processor-to-processor mapping information.
virtual void writeData(Ostream &os) const
Write in dictionary format.
scalarField samples(nIntervals, Zero)
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void distribute(List< T > &fld, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Distribute data using default commsType.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Mesh data needed to do the Finite Volume discretisation.
errorManip< error > abort(error &err)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A traits class, which is primarily used for primitives.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
virtual tmp< Field< Type > > value(const scalar x) const
Return sampled value.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
void reverseDistribute(const label constructSize, List< T > &, const bool dummyTransform=true, const int tag=UPstream::msgType()) const
Reverse distribute data using default commsType.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
label nFaces() const noexcept
Number of mesh faces.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
PatchFunction1 to sample an existing field.