Go to the documentation of this file.
37 const dictionary&
dict,
43 return dict.get<Type>(
"average");
57 const word& entryName,
65 setAverage_(
dict.lookupOrDefault(
"setAverage",
false)),
66 average_(getAverage(
dict, setAverage_)),
69 if (this->
mode() == mappedPatchBase::NEARESTCELL)
71 dict.readEntry(
"interpolationScheme", interpolationScheme_);
115 if (this->sameRegion())
119 return thisMesh.template lookupObject<fieldType>(fieldName_);
123 const fvMesh& nbrMesh = refCast<const fvMesh>(this->sampleMesh());
124 return nbrMesh.template lookupObject<fieldType>(fieldName_);
134 if (this->sameRegion())
138 return thisMesh.template foundObject<fieldType>(fieldName_);
142 const fvMesh& nbrMesh = refCast<const fvMesh>(this->sampleMesh());
143 return nbrMesh.template foundObject<fieldType>(fieldName_);
159 int oldTag = UPstream::msgType();
160 UPstream::msgType() = oldTag + 1;
162 const fvMesh& thisMesh = refCast<const fvMesh>
166 const fvMesh& nbrMesh = refCast<const fvMesh>(this->sampleMesh());
171 auto& newValues = tnewValues.ref();
173 if (!haveSampleField())
176 UPstream::msgType() = oldTag;
177 newValues.setSize(this->mappedPatchBase::patch_.size());
182 switch (this->
mode())
184 case mappedPatchBase::NEARESTCELL:
206 interpolationScheme_,
210 const auto& interp = *interpolator;
217 newValues[celli] = interp.interpolate
227 newValues = sampleField();
233 case mappedPatchBase::NEARESTPATCHFACE:
234 case mappedPatchBase::NEARESTPATCHFACEAMI:
236 const label nbrPatchID =
242 <<
"Unable to find sample patch " << this->samplePatch()
243 <<
" in region " << this->sampleRegion()
244 <<
" for patch " << this->mappedPatchBase::patch_.name() <<
nl
248 const fieldType& nbrField = sampleField();
250 newValues = nbrField.boundaryField()[nbrPatchID];
251 this->distribute(newValues);
255 case mappedPatchBase::NEARESTFACE:
259 const fieldType& nbrField = sampleField();
263 label faceStart = pf.patch().start();
267 allValues[faceStart++] = pf[facei];
271 this->distribute(allValues);
272 newValues.transfer(allValues);
279 <<
"Unknown sampling mode: " << this->
mode() <<
nl
289 if (this->faceValues_)
293 mag(this->mappedPatchBase::patch_.faceAreas())
295 averagePsi =
gSum(magSf*newValues)/
gSum(magSf);
302 if (
mag(averagePsi)/
mag(average_) > 0.5)
304 newValues *=
mag(average_)/
mag(averagePsi);
308 newValues += (average_ - averagePsi);
313 UPstream::msgType() = oldTag;
351 os.
writeEntry(
"interpolationScheme", interpolationScheme_);
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
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.
Type gAverage(const FieldField< Field, Type > &f)
const GeometricField< Type, fvPatchField, volMesh > & sampleField() const
Field to sample. Either on my or nbr mesh.
label nFaces() const
Number of mesh faces.
Sampled(const polyPatch &pp, const word &type, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name and dictionary.
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.
bool haveSampleField() const
Field to sample. Either on my or nbr mesh.
label nCells() const
Number of mesh cells.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A patch is a list of labels that address the faces in the global face list.
word name(const complex &c)
Return string representation of complex.
Class containing processor-to-processor mapping information.
virtual void writeData(Ostream &os) const
Write in dictionary format.
scalarField samples(nIntervals, Zero)
const polyMesh & mesh() const
Return the mesh reference.
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,...
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.
Traits class for primitives.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
virtual tmp< Field< Type > > value(const scalar x) const
Return sampled value.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
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....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
PatchFunction1 to sample an existing field.