44 fieldTableName_(iF.
name()),
50 startSampledValues_(0),
69 fieldTableName_(iF.
name()),
70 setAverage_(
dict.getOrDefault(
"setAverage", false)),
71 perturb_(
dict.getOrDefault(
"perturb", 1
e-5)),
83 startSampledValues_(0),
95 mapMethod_ !=
"planarInterpolation"
96 && mapMethod_ !=
"nearest"
100 <<
"mapMethod should be one of 'planarInterpolation'"
135 fieldTableName_(ptf.fieldTableName_),
136 setAverage_(ptf.setAverage_),
137 perturb_(ptf.perturb_),
138 mapMethod_(ptf.mapMethod_),
141 startSampleTime_(-1),
142 startSampledValues_(0),
145 endSampledValues_(0),
147 offset_(ptf.offset_.clone())
159 fieldTableName_(ptf.fieldTableName_),
160 setAverage_(ptf.setAverage_),
161 perturb_(ptf.perturb_),
162 mapMethod_(ptf.mapMethod_),
163 mapperPtr_(ptf.mapperPtr_),
164 sampleTimes_(ptf.sampleTimes_),
165 startSampleTime_(ptf.startSampleTime_),
166 startSampledValues_(ptf.startSampledValues_),
167 startAverage_(ptf.startAverage_),
168 endSampleTime_(ptf.endSampleTime_),
169 endSampledValues_(ptf.endSampledValues_),
170 endAverage_(ptf.endAverage_),
171 offset_(ptf.offset_.clone())
184 fieldTableName_(ptf.fieldTableName_),
185 setAverage_(ptf.setAverage_),
186 perturb_(ptf.perturb_),
187 mapMethod_(ptf.mapMethod_),
188 mapperPtr_(ptf.mapperPtr_),
189 sampleTimes_(ptf.sampleTimes_),
190 startSampleTime_(ptf.startSampleTime_),
191 startSampledValues_(ptf.startSampledValues_),
192 startAverage_(ptf.startAverage_),
193 endSampleTime_(ptf.endSampleTime_),
194 endSampledValues_(ptf.endSampledValues_),
195 endAverage_(ptf.endAverage_),
196 offset_(ptf.offset_.clone())
209 if (startSampledValues_.size())
211 startSampledValues_.autoMap(m);
212 endSampledValues_.autoMap(m);
216 startSampleTime_ = -1;
231 refCast<const timeVaryingMappedFixedValuePointPatchField<Type>>(ptf);
233 startSampledValues_.
rmap(tiptf.startSampledValues_, addr);
234 endSampledValues_.rmap(tiptf.endSampledValues_, addr);
238 startSampleTime_ = -1;
246 const Time& time = this->db().
time();
249 if (startSampleTime_ == -1 && endSampleTime_ == -1)
251 const polyMesh& pMesh = this->patch().boundaryMesh().mesh()();
290 /this->patch().
name()
311 && mapMethod_ !=
"planarInterpolation"
328 const fileName samplePointsDir = samplePointsFile.
path();
333 Info<<
"timeVaryingMappedFixedValuePointPatchField : In directory "
334 << samplePointsDir <<
" found times "
344 bool foundTime = mapperPtr_().findTime
356 <<
"Cannot find starting sampling values for current time "
358 <<
"Have sampling values for times "
361 << time.
constant()/
"boundaryData"/this->patch().name()
362 <<
"\n on patch " << this->patch().name()
363 <<
" of field " << fieldTableName_
370 if (lo != startSampleTime_)
372 startSampleTime_ = lo;
374 if (startSampleTime_ == endSampleTime_)
379 Pout<<
"checkTable : Setting startValues to (already read) "
381 /this->patch().name()
382 /sampleTimes_[startSampleTime_].name()
385 startSampledValues_ = endSampledValues_;
386 startAverage_ = endAverage_;
392 Pout<<
"checkTable : Reading startValues from "
394 /this->patch().name()
395 /sampleTimes_[lo].name()
404 /this->patch().
name()
405 /sampleTimes_[startSampleTime_].name()
422 startAverage_ = vals.
average();
425 if (vals.
size() != mapperPtr_().sourceSize())
428 <<
"Number of values (" << vals.
size()
429 <<
") differs from the number of points ("
430 << mapperPtr_().sourceSize()
434 startSampledValues_ = mapperPtr_().interpolate(vals);
438 if (hi != endSampleTime_)
442 if (endSampleTime_ == -1)
447 Pout<<
"checkTable : Clearing endValues" <<
endl;
449 endSampledValues_.clear();
455 Pout<<
"checkTable : Reading endValues from "
457 /this->patch().name()
458 /sampleTimes_[endSampleTime_].name()
467 /this->patch().
name()
468 /sampleTimes_[endSampleTime_].name()
489 if (vals.
size() != mapperPtr_().sourceSize())
492 <<
"Number of values (" << vals.
size()
493 <<
") differs from the number of points ("
494 << mapperPtr_().sourceSize()
498 endSampledValues_ = mapperPtr_().interpolate(vals);
518 if (endSampleTime_ == -1)
523 Pout<<
"updateCoeffs : Sampled, non-interpolated values"
524 <<
" from start time:"
525 << sampleTimes_[startSampleTime_].
name() <<
nl;
529 wantedAverage = startAverage_;
533 scalar start = sampleTimes_[startSampleTime_].value();
534 scalar end = sampleTimes_[endSampleTime_].value();
536 scalar
s = (this->db().time().value()-start)/(end-start);
540 Pout<<
"updateCoeffs : Sampled, interpolated values"
541 <<
" between start time:"
542 << sampleTimes_[startSampleTime_].
name()
543 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
544 <<
" with weight:" <<
s <<
endl;
547 this->
operator==((1-s)*startSampledValues_ +
s*endSampledValues_);
548 wantedAverage = (1-
s)*startAverage_ +
s*endAverage_;
561 Pout<<
"updateCoeffs :"
562 <<
" actual average:" << averagePsi
563 <<
" wanted average:" << wantedAverage
567 if (
mag(averagePsi) < VSMALL)
570 const Type offset = wantedAverage - averagePsi;
573 Pout<<
"updateCoeffs :"
574 <<
" offsetting with:" << offset <<
endl;
580 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
584 Pout<<
"updateCoeffs :"
585 <<
" scaling with:" << scale <<
endl;
594 const scalar t = this->db().time().timeOutputValue();
600 Pout<<
"updateCoeffs : set fixedValue to min:" <<
gMin(*
this)
601 <<
" max:" <<
gMax(*
this)
623 this->internalField().name(),
630 "planarInterpolation",
636 offset_->writeData(
os);
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-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.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
void evaluate()
Evaluate boundary conditions.
A primitive field of type <T> with automated input and output.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual const fileName & name() const
Get the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
static instantList findTimes(const fileName &directory, const word &constantName="constant")
Search a given directory for valid time directories.
fileName caseConstant() const
const word & constant() const
Return constant name.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void size(const label n)
Older name for setAddressableSize.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
void rmap(const atmBoundaryLayer &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
const Type & value() const
Return const reference to value.
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.
virtual bool write()
Write the output fields.
const Time & time() const noexcept
Return time registry.
Foam::pointPatchFieldMapper.
Abstract base class for point-mesh patch fields.
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.
const fileName & facesInstance() const
Return the current instance directory for faces.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual const pointField & points() const
Return raw points.
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....
const Type & average() const
A time-varying form of a mapped fixed value boundary condition.
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.
void checkTable()
Find boundary data inbetween current time and interpolate.
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#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))
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Type gAverage(const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0)
Type gMin(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gMax(const FieldField< Field, Type > &f)
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, false)))