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->
db().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);
184 startSampledValues_.
reset(tiptf.startSampledValues_);
185 endSampledValues_.reset(tiptf.endSampledValues_);
189 startSampleTime_ = -1;
198 if (startSampleTime_ == -1 && endSampleTime_ == -1)
231 meshPts =
pointField(points0, this->patch().meshPoints());
237 this->db().time().constant()
239 /this->patch().
name()
249 && mapMethod_ !=
"planarInterpolation"
266 const fileName samplePointsDir = samplePointsFile.
path();
267 sampleTimes_ = this->db().time().findTimes(samplePointsDir);
271 Info<<
"timeVaryingMappedFixedValuePointPatchField : In directory "
272 << samplePointsDir <<
" found times "
282 bool foundTime = mapperPtr_().findTime
286 this->db().time().userTimeValue(),
294 <<
"Cannot find starting sampling values for current time "
295 << this->db().time().userTimeValue() <<
nl
296 <<
"Have sampling values for times "
299 << this->db().time().constant()/
"boundaryData"/this->patch().name()
300 <<
"\n on patch " << this->patch().name()
301 <<
" of field " << fieldTableName_
308 if (lo != startSampleTime_)
310 startSampleTime_ = lo;
312 if (startSampleTime_ == endSampleTime_)
317 Pout<<
"checkTable : Setting startValues to (already read) "
319 /this->patch().
name()
320 /sampleTimes_[startSampleTime_].
name()
323 startSampledValues_ = endSampledValues_;
324 startAverage_ = endAverage_;
330 Pout<<
"checkTable : Reading startValues from "
332 /this->patch().
name()
333 /sampleTimes_[lo].
name()
340 this->db().time().constant()
342 /this->patch().
name()
343 /sampleTimes_[startSampleTime_].
name()
353 startAverage_ = avals.
average();
360 if (vals.
size() != mapperPtr_().sourceSize())
363 <<
"Number of values (" << vals.
size()
364 <<
") differs from the number of points ("
365 << mapperPtr_().sourceSize()
369 startSampledValues_ = mapperPtr_().interpolate(vals);
373 if (hi != endSampleTime_)
377 if (endSampleTime_ == -1)
382 Pout<<
"checkTable : Clearing endValues" <<
endl;
384 endSampledValues_.clear();
390 Pout<<
"checkTable : Reading endValues from "
392 /this->patch().
name()
393 /sampleTimes_[endSampleTime_].
name()
400 this->db().time().constant()
402 /this->patch().
name()
403 /sampleTimes_[endSampleTime_].
name()
420 if (vals.
size() != mapperPtr_().sourceSize())
423 <<
"Number of values (" << vals.
size()
424 <<
") differs from the number of points ("
425 << mapperPtr_().sourceSize()
429 endSampledValues_ = mapperPtr_().interpolate(vals);
449 if (endSampleTime_ == -1)
454 Pout<<
"updateCoeffs : Sampled, non-interpolated values"
455 <<
" from start time:"
456 << sampleTimes_[startSampleTime_].
name() <<
nl;
460 wantedAverage = startAverage_;
464 scalar start = sampleTimes_[startSampleTime_].value();
465 scalar end = sampleTimes_[endSampleTime_].value();
467 scalar
s = (this->db().time().userTimeValue()-start)/(end-start);
471 Pout<<
"updateCoeffs : Sampled, interpolated values"
472 <<
" between start time:"
473 << sampleTimes_[startSampleTime_].
name()
474 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
475 <<
" with weight:" <<
s <<
endl;
478 this->
operator==((1 - s)*startSampledValues_ +
s*endSampledValues_);
479 wantedAverage = (1 -
s)*startAverage_ +
s*endAverage_;
492 Pout<<
"updateCoeffs :"
493 <<
" actual average:" << averagePsi
494 <<
" wanted average:" << wantedAverage
498 if (
mag(averagePsi) < vSmall)
501 const Type
offset = wantedAverage - averagePsi;
504 Pout<<
"updateCoeffs :"
511 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
515 Pout<<
"updateCoeffs :"
516 <<
" scaling with:" << scale <<
endl;
527 *
this + offset_->value(this->db().time().value())
533 Pout<<
"updateCoeffs : set fixedValue to min:" <<
gMin(*
this)
534 <<
" max:" <<
gMax(*
this)
558 this->internalField().
name(),
566 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::unitConversions &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 objectRegistry & db() const
Return local objectRegistry.
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.
const polyMesh & mesh() const
Return the mesh reference.
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.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
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.
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.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Type gAverage(const FieldField< Field, Type > &f)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
Type gMin(const FieldField< Field, Type > &f)
void offset(label &lst, const label o)
Type gMax(const FieldField< Field, Type > &f)