46 fieldTableName_(iF.
name()),
47 pointsName_(
"points"),
68 setAverage_(
dict.getOrDefault(
"setAverage", false)),
69 perturb_(
dict.getOrDefault(
"perturb", 1
e-5)),
70 fieldTableName_(iF.
name()),
71 pointsName_(
dict.getOrDefault<
word>(
"points",
"points")),
85 dict.readIfPresent(
"mapMethod", mapMethod_)
86 && !mapMethod_.empty()
87 && mapMethod_ !=
"nearest"
91 FatalIOErrorInFunction(dict)
92 <<
"Unknown mapMethod type " << mapMethod_
93 <<
"\n\nValid mapMethod types :\n"
94 <<
"(nearest planar)" << nl
95 << exit(FatalIOError);
98 dict.readIfPresentCompat
100 "fieldTable", {{
"fieldTableName", 2206}},
104 if (!this->readValueEntry(
dict))
119 const timeVaryingMappedFixedValuePointPatchField<Type>& ptf,
121 const DimensionedField<Type, pointMesh>& iF,
122 const pointPatchFieldMapper& mapper
125 fixedValuePointPatchField<Type>(ptf,
p, iF, mapper),
126 setAverage_(ptf.setAverage_),
127 perturb_(ptf.perturb_),
128 fieldTableName_(ptf.fieldTableName_),
129 pointsName_(ptf.pointsName_),
130 mapMethod_(ptf.mapMethod_),
133 sampleIndex_(-1, -1),
136 offset_(ptf.offset_.
clone())
148 setAverage_(ptf.setAverage_),
149 perturb_(ptf.perturb_),
150 fieldTableName_(ptf.fieldTableName_),
151 pointsName_(ptf.pointsName_),
152 mapMethod_(ptf.mapMethod_),
153 mapperPtr_(ptf.mapperPtr_),
154 sampleTimes_(ptf.sampleTimes_),
155 sampleIndex_(ptf.sampleIndex_),
156 sampleAverage_(ptf.sampleAverage_),
157 sampleValues_(ptf.sampleValues_),
158 offset_(ptf.offset_.
clone())
171 setAverage_(ptf.setAverage_),
172 perturb_(ptf.perturb_),
173 fieldTableName_(ptf.fieldTableName_),
174 pointsName_(ptf.pointsName_),
175 mapMethod_(ptf.mapMethod_),
176 mapperPtr_(ptf.mapperPtr_),
177 sampleTimes_(ptf.sampleTimes_),
178 sampleIndex_(ptf.sampleIndex_),
179 sampleAverage_(ptf.sampleAverage_),
180 sampleValues_(ptf.sampleValues_),
195 if (sampleValues_.first().size())
197 sampleValues_.first().autoMap(m);
200 if (sampleValues_.second().size())
202 sampleValues_.second().autoMap(m);
206 mapperPtr_.reset(
nullptr);
223 sampleValues_.first().rmap(tiptf.sampleValues_.first(), addr);
224 sampleValues_.second().rmap(tiptf.sampleValues_.second(), addr);
227 mapperPtr_.reset(
nullptr);
233void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateSampledValues
235 const label sampleIndex,
240 tmp<Field<Type>> tvalues;
244 const Time& time = this->db().time();
248 Pout<<
"checkTable : Reading values from "
252 / this->patch().name()
253 / sampleTimes_[sampleIndex].name()
263 /this->patch().name()
264 /sampleTimes_[sampleIndex].name()
280 if (vals.hasAverage())
282 avg = vals.average();
285 if (vals.size() != mapperPtr_().sourceSize())
288 <<
"Number of values (" << vals.size()
289 <<
") differs from the number of points ("
290 << mapperPtr_().sourceSize()
298 field = mapperPtr_().interpolate(tvalues);
303void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::checkTable
308 const Time& time = this->db().
time();
311 if (sampleIndex_.first() == -1 && sampleIndex_.second() == -1)
313 const polyMesh& pMesh = this->
patch().boundaryMesh().mesh()();
318 if (pMesh.pointsInstance() == pMesh.facesInstance())
320 meshPts =
pointField(pMesh.points(), this->patch().meshPoints());
326 <<
"Reloading points0 from " << pMesh.facesInstance()
334 pMesh.facesInstance(),
350 /this->patch().name()
368 const bool nearestOnly =
370 !mapMethod_.empty() && !mapMethod_.starts_with(
"planar")
387 const fileName samplePointsDir = samplePointsFile.
path();
404 if (timeIndices.first() < 0)
407 <<
"Cannot find starting sampling values for current time "
408 << time.value() <<
nl
409 <<
"Have sampling values for times "
412 << time.constant()/
"boundaryData"/this->
patch().name()
413 <<
"\n on patch " << this->
patch().name()
414 <<
" of field " << fieldTableName_
421 if (sampleIndex_.first() != timeIndices.first())
423 sampleIndex_.first() = timeIndices.first();
425 if (sampleIndex_.first() == sampleIndex_.second())
428 sampleValues_.first() = sampleValues_.second();
429 sampleAverage_.first() = sampleAverage_.second();
434 this->updateSampledValues
436 sampleIndex_.first(),
437 sampleValues_.first(),
438 sampleAverage_.first()
443 if (sampleIndex_.second() != timeIndices.second())
445 sampleIndex_.second() = timeIndices.second();
447 if (sampleIndex_.second() == -1)
450 sampleValues_.second().clear();
455 this->updateSampledValues
457 sampleIndex_.second(),
458 sampleValues_.second(),
459 sampleAverage_.second()
475 const scalar
x = this->db().time().value();
483 if (sampleIndex_.second() == -1)
486 fld = sampleValues_.first();
487 wantedAverage = sampleAverage_.first();
491 const scalar beg = sampleTimes_[sampleIndex_.first()].value();
492 const scalar
end = sampleTimes_[sampleIndex_.second()].value();
493 const scalar
s = (
x - beg)/(end - beg);
495 fld = (1 -
s)*sampleValues_.first() +
s*sampleValues_.second();
498 = (1 -
s)*sampleAverage_.first() +
s*sampleAverage_.second();
501 <<
"Sampled, interpolated values"
503 << sampleTimes_[sampleIndex_.first()].name()
504 <<
" and time:" << sampleTimes_[sampleIndex_.second()].name()
505 <<
" with weight:" <<
s <<
endl;
516 Pout<<
"updateCoeffs :"
517 <<
" actual average:" << averagePsi
518 <<
" wanted average:" << wantedAverage
522 if (
mag(averagePsi) < VSMALL)
525 const Type offset = wantedAverage - averagePsi;
528 Pout<<
"updateCoeffs :"
529 <<
" offsetting with:" << offset <<
endl;
535 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
539 Pout<<
"updateCoeffs :"
540 <<
" scaling with:" << scale <<
endl;
549 const scalar t = this->db().time().timeOutputValue();
550 fld += offset_->value(t);
558 Pout<<
"updateCoeffs : set fixedValue to min:" <<
limits.min()
559 <<
" max:" <<
limits.max()
560 <<
" avg:" << avg <<
endl;
575 os.writeEntryIfDifferent
578 this->internalField().
name(),
582 if (!pointsName_.empty())
584 os.writeEntryIfDifferent<word>(
"points",
"points", pointsName_);
587 if (!mapMethod_.empty() && !mapMethod_.starts_with(
"planar"))
601 offset_->writeData(
os);
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
static const Field< Type > & null() noexcept
Return a null Field (reference to a nullObject). Behaves like an empty Field.
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
An ordered pair of two objects of type <T> with first() and second() elements.
static instantList findTimes(const fileName &directory, const word &constantDirName="constant")
Search a given directory for valid time directories.
fileName caseConstant() const
Return the constant name for the case, which is ../constant() for parallel runs.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
static std::string path(const std::string &str)
Return directory path name (part before last /).
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
A FixedValue boundary condition for pointField.
fixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
static Pair< label > findRange(const UList< instant > ×, const scalar timeVal, const label start=-1)
Find lower/upper indices for given time value in list of instances (linear search) continuing after t...
const Time & time() const noexcept
Return time registry.
const objectRegistry & db() const
The associated objectRegistry.
bool updated() const noexcept
True if the boundary condition has already been updated.
Foam::pointPatchFieldMapper.
Abstract base class for point-mesh patch fields.
const DimensionedField< Type, pointMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
Basic pointPatch represents a set of points from the mesh.
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
static wordList timeNames(const instantList ×)
Helper: extract words of times.
Mesh consisting of general polyhedral cells.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
Like IOField but falls back to raw IFstream if no header found. Optionally reads average value....
bool starts_with(char c) const
True if string starts with given character (cf. C++20).
A time-varying form of a mapped fixed value boundary condition.
timeVaryingMappedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &) const
Write.
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual autoPtr< pointPatchField< Type > > clone() const
Return a clone.
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
A class for managing temporary objects.
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
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;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for handling debugging switches.
const std::string patch
OpenFOAM patch number as a std::string.
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.
Pair< label > labelPair
A pair of labels.
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.
List< label > labelList
A List of labels.
vectorIOField pointIOField
pointIOField is a vectorIOField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
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...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))