43 fieldTableName_(iF.
name()),
44 setAverage_(
dict.lookupOrDefault(
"setAverage", false)),
45 perturb_(
dict.lookupOrDefault(
"perturb", 1
e-5)),
57 startSampledValues_(0),
64 if (
dict.found(
"offset"))
69 this->
time().userUnits(),
77 mapMethod_ !=
"planarInterpolation"
78 && mapMethod_ !=
"nearest"
84 ) <<
"mapMethod should be one of 'planarInterpolation'"
88 dict.readIfPresent(
"fieldTableName", fieldTableName_);
90 if (
dict.found(
"value"))
119 fieldTableName_(ptf.fieldTableName_),
120 setAverage_(ptf.setAverage_),
121 perturb_(ptf.perturb_),
122 mapMethod_(ptf.mapMethod_),
125 startSampleTime_(-1),
126 startSampledValues_(0),
129 endSampledValues_(0),
131 offset_(ptf.offset_, false)
144 fieldTableName_(ptf.fieldTableName_),
145 setAverage_(ptf.setAverage_),
146 perturb_(ptf.perturb_),
147 mapMethod_(ptf.mapMethod_),
148 mapperPtr_(ptf.mapperPtr_),
149 sampleTimes_(ptf.sampleTimes_),
150 startSampleTime_(ptf.startSampleTime_),
151 startSampledValues_(ptf.startSampledValues_),
152 startAverage_(ptf.startAverage_),
153 endSampleTime_(ptf.endSampleTime_),
154 endSampledValues_(ptf.endSampledValues_),
155 endAverage_(ptf.endAverage_),
156 offset_(ptf.offset_, false)
182 refCast<const timeVaryingMappedFixedValuePointPatchField<Type>>(ptf);
186 startSampledValues_.
reset(tiptf.startSampledValues_);
187 endSampledValues_.reset(tiptf.endSampledValues_);
192 startSampleTime_ = -1;
201 if (startSampleTime_ == -1 && endSampleTime_ == -1)
203 const polyMesh& pMesh = this->patch().mesh()();
234 meshPts =
pointField(points0, this->patch().meshPoints());
240 this->
time().constant()
242 /this->patch().
name()
252 && mapMethod_ !=
"planarInterpolation"
269 const fileName samplePointsDir = samplePointsFile.
path();
270 sampleTimes_ = this->
time().findTimes(samplePointsDir);
274 Info<<
"timeVaryingMappedFixedValuePointPatchField : In directory "
275 << samplePointsDir <<
" found times "
285 bool foundTime = mapperPtr_().findTime
289 this->
time().userTimeValue(),
297 <<
"Cannot find starting sampling values for current time "
298 << this->
time().userTimeValue() <<
nl
299 <<
"Have sampling values for times "
302 << this->
time().constant()/
"boundaryData"/this->patch().name()
303 <<
"\n on patch " << this->patch().name()
304 <<
" of field " << fieldTableName_
311 if (lo != startSampleTime_)
313 startSampleTime_ = lo;
315 if (startSampleTime_ == endSampleTime_)
320 Pout<<
"checkTable : Setting startValues to (already read) "
322 /this->patch().
name()
323 /sampleTimes_[startSampleTime_].
name()
326 startSampledValues_ = endSampledValues_;
327 startAverage_ = endAverage_;
333 Pout<<
"checkTable : Reading startValues from "
335 /this->patch().
name()
336 /sampleTimes_[lo].
name()
343 this->
time().constant()
345 /this->patch().
name()
346 /sampleTimes_[startSampleTime_].
name()
356 startAverage_ = avals.
average();
363 if (vals.
size() != mapperPtr_().sourceSize())
366 <<
"Number of values (" << vals.
size()
367 <<
") differs from the number of points ("
368 << mapperPtr_().sourceSize()
372 startSampledValues_ = mapperPtr_().interpolate(vals);
376 if (hi != endSampleTime_)
380 if (endSampleTime_ == -1)
385 Pout<<
"checkTable : Clearing endValues" <<
endl;
387 endSampledValues_.clear();
393 Pout<<
"checkTable : Reading endValues from "
395 /this->patch().
name()
396 /sampleTimes_[endSampleTime_].
name()
403 this->
time().constant()
405 /this->patch().
name()
406 /sampleTimes_[endSampleTime_].
name()
423 if (vals.
size() != mapperPtr_().sourceSize())
426 <<
"Number of values (" << vals.
size()
427 <<
") differs from the number of points ("
428 << mapperPtr_().sourceSize()
432 endSampledValues_ = mapperPtr_().interpolate(vals);
452 if (endSampleTime_ == -1)
457 Pout<<
"updateCoeffs : Sampled, non-interpolated values"
458 <<
" from start time:"
459 << sampleTimes_[startSampleTime_].
name() <<
nl;
463 wantedAverage = startAverage_;
467 scalar start = sampleTimes_[startSampleTime_].value();
468 scalar end = sampleTimes_[endSampleTime_].value();
470 scalar
s = (this->
time().userTimeValue()-start)/(end-start);
474 Pout<<
"updateCoeffs : Sampled, interpolated values"
475 <<
" between start time:"
476 << sampleTimes_[startSampleTime_].
name()
477 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
478 <<
" with weight:" <<
s <<
endl;
481 this->
operator==((1 - s)*startSampledValues_ +
s*endSampledValues_);
482 wantedAverage = (1 -
s)*startAverage_ +
s*endAverage_;
495 Pout<<
"updateCoeffs :"
496 <<
" actual average:" << averagePsi
497 <<
" wanted average:" << wantedAverage
501 if (
mag(averagePsi) < vSmall)
504 const Type
offset = wantedAverage - averagePsi;
507 Pout<<
"updateCoeffs :"
514 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
518 Pout<<
"updateCoeffs :"
519 <<
" scaling with:" << scale <<
endl;
530 *
this + offset_->value(this->
time().value())
536 Pout<<
"updateCoeffs : set fixedValue to min:" <<
gMin(*
this)
537 <<
" max:" <<
gMax(*
this)
561 this->internalField().
name(),
569 word(
"planarInterpolation"),
A primitive field with a separate average value.
const Type & average() const
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
static autoPtr< Function1< Type > > New(const word &name, const Function1s::unitSets &units, const dictionary &dict)
Select from dictionary.
A primitive field of type <Type> with automated input and output.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void size(const label)
Override size to be inconsistent with allocated storage.
virtual const fileName & name() const
Return the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Abstract base class for field mapping.
A class for handling file names.
word name() const
Return file name (part beyond last /)
fileName path() const
Return directory path name (part before last /)
A FixedValue boundary condition for pointField.
Abstract base class for point-mesh patch fields.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
const Time & time() const
Return time.
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")
A time-varying form of a mapped fixed value boundary condition.
timeVaryingMappedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
void checkTable()
Find boundary data in between current time and interpolate.
virtual void reset(const pointPatchField< Type > &)
Reset the pointPatchField to the given pointPatchField.
virtual void map(const pointPatchField< Type > &, const fieldMapper &)
Map the given pointPatchField onto this pointPatchField.
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void reset(const pointPatchField< Type > &)
Reset the pointPatchField to the given pointPatchField.
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar e
Elementary charge.
Type gMin(const UList< Type > &f, const label comm)
errorManipArg< error, int > exit(error &err, const int errNo=1)
void writeEntryIfDifferent(Ostream &os, const word &entryName, const EntryType &value1, const EntryType &value2)
Helper function to write the keyword and entry only if the.
Type gAverage(const UList< Type > &f, const label comm)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorField pointField
pointField is a vectorField.
Type gMax(const UList< Type > &f, const label comm)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void offset(label &lst, const label o)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)