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"))
71 mapMethod_ !=
"planarInterpolation"
72 && mapMethod_ !=
"nearest"
78 ) <<
"mapMethod should be one of 'planarInterpolation'"
82 dict.readIfPresent(
"fieldTableName", fieldTableName_);
84 if (
dict.found(
"value"))
113 fieldTableName_(ptf.fieldTableName_),
114 setAverage_(ptf.setAverage_),
115 perturb_(ptf.perturb_),
116 mapMethod_(ptf.mapMethod_),
119 startSampleTime_(-1),
120 startSampledValues_(0),
123 endSampledValues_(0),
125 offset_(ptf.offset_, false)
138 fieldTableName_(ptf.fieldTableName_),
139 setAverage_(ptf.setAverage_),
140 perturb_(ptf.perturb_),
141 mapMethod_(ptf.mapMethod_),
142 mapperPtr_(ptf.mapperPtr_),
143 sampleTimes_(ptf.sampleTimes_),
144 startSampleTime_(ptf.startSampleTime_),
145 startSampledValues_(ptf.startSampledValues_),
146 startAverage_(ptf.startAverage_),
147 endSampleTime_(ptf.endSampleTime_),
148 endSampledValues_(ptf.endSampledValues_),
149 endAverage_(ptf.endAverage_),
150 offset_(ptf.offset_, false)
166 refCast<const timeVaryingMappedFixedValuePointPatchField<Type>>(ptf);
168 mapper(startSampledValues_, tiptf.startSampledValues_);
169 mapper(endSampledValues_, tiptf.endSampledValues_);
173 startSampleTime_ = -1;
187 refCast<const timeVaryingMappedFixedValuePointPatchField<Type>>(ptf);
189 startSampledValues_.
reset(tiptf.startSampledValues_);
190 endSampledValues_.reset(tiptf.endSampledValues_);
194 startSampleTime_ = -1;
203 if (startSampleTime_ == -1 && endSampleTime_ == -1)
236 meshPts =
pointField(points0, this->patch().meshPoints());
242 this->db().time().constant()
244 /this->patch().
name()
254 && mapMethod_ !=
"planarInterpolation"
271 const fileName samplePointsDir = samplePointsFile.
path();
276 Info<<
"timeVaryingMappedFixedValuePointPatchField : In directory "
277 << samplePointsDir <<
" found times "
287 bool foundTime = mapperPtr_().findTime
291 this->db().time().value(),
299 <<
"Cannot find starting sampling values for current time "
300 << this->db().time().value() <<
nl
301 <<
"Have sampling values for times "
304 << this->db().time().constant()/
"boundaryData"/this->patch().name()
305 <<
"\n on patch " << this->patch().name()
306 <<
" of field " << fieldTableName_
313 if (lo != startSampleTime_)
315 startSampleTime_ = lo;
317 if (startSampleTime_ == endSampleTime_)
322 Pout<<
"checkTable : Setting startValues to (already read) "
324 /this->patch().
name()
325 /sampleTimes_[startSampleTime_].
name()
328 startSampledValues_ = endSampledValues_;
329 startAverage_ = endAverage_;
335 Pout<<
"checkTable : Reading startValues from "
337 /this->patch().
name()
338 /sampleTimes_[lo].
name()
345 this->db().time().constant()
347 /this->patch().
name()
348 /sampleTimes_[startSampleTime_].
name()
358 startAverage_ = avals.
average();
365 if (vals.
size() != mapperPtr_().sourceSize())
368 <<
"Number of values (" << vals.
size()
369 <<
") differs from the number of points ("
370 << mapperPtr_().sourceSize()
374 startSampledValues_ = mapperPtr_().interpolate(vals);
378 if (hi != endSampleTime_)
382 if (endSampleTime_ == -1)
387 Pout<<
"checkTable : Clearing endValues" <<
endl;
389 endSampledValues_.clear();
395 Pout<<
"checkTable : Reading endValues from "
397 /this->patch().
name()
398 /sampleTimes_[endSampleTime_].
name()
405 this->db().time().constant()
407 /this->patch().
name()
408 /sampleTimes_[endSampleTime_].
name()
425 if (vals.
size() != mapperPtr_().sourceSize())
428 <<
"Number of values (" << vals.
size()
429 <<
") differs from the number of points ("
430 << mapperPtr_().sourceSize()
434 endSampledValues_ = mapperPtr_().interpolate(vals);
454 if (endSampleTime_ == -1)
459 Pout<<
"updateCoeffs : Sampled, non-interpolated values"
460 <<
" from start time:"
461 << sampleTimes_[startSampleTime_].
name() <<
nl;
465 wantedAverage = startAverage_;
469 scalar start = sampleTimes_[startSampleTime_].value();
470 scalar end = sampleTimes_[endSampleTime_].value();
472 scalar
s = (this->db().time().value()-start)/(end-start);
476 Pout<<
"updateCoeffs : Sampled, interpolated values"
477 <<
" between start time:"
478 << sampleTimes_[startSampleTime_].
name()
479 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
480 <<
" with weight:" <<
s <<
endl;
483 this->
operator==((1-s)*startSampledValues_ +
s*endSampledValues_);
484 wantedAverage = (1-
s)*startAverage_ +
s*endAverage_;
497 Pout<<
"updateCoeffs :"
498 <<
" actual average:" << averagePsi
499 <<
" wanted average:" << wantedAverage
503 if (
mag(averagePsi) < vSmall)
506 const Type
offset = wantedAverage - averagePsi;
509 Pout<<
"updateCoeffs :"
516 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
520 Pout<<
"updateCoeffs :"
521 <<
" scaling with:" << scale <<
endl;
530 const scalar t = this->db().time().userTimeValue();
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...
Pre-declare SubField and related Field type.
static autoPtr< Function1< Type > > New(const word &name, const dictionary &dict)
Selector.
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,...
static instantList findTimes(const fileName &, const word &constantName="constant")
Search a given directory for valid time directories.
A list of keyword definitions, which are a keyword followed by any number of values (e....
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.
Foam::pointPatchFieldMapper.
Abstract base class for point-mesh patch fields.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
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 pointPatchFieldMapper &)
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.
virtual void map(const pointPatchField< Type > &, const pointPatchFieldMapper &)
Map the given pointPatchField onto this 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(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(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), 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.
word name(const bool)
Return a word representation of a bool.
vectorField pointField
pointField is a vectorField.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
dimensioned< scalar > mag(const dimensioned< Type > &)
Type gAverage(const FieldField< Field, Type > &f)
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)