Go to the documentation of this file.
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),
92 mapMethod_ !=
"planarInterpolation"
93 && mapMethod_ !=
"nearest"
97 <<
"mapMethod should be one of 'planarInterpolation'"
101 dict.readIfPresent(
"fieldTableName", fieldTableName_);
103 if (
dict.found(
"value"))
132 fieldTableName_(ptf.fieldTableName_),
133 setAverage_(ptf.setAverage_),
134 perturb_(ptf.perturb_),
135 mapMethod_(ptf.mapMethod_),
138 startSampleTime_(-1),
139 startSampledValues_(0),
142 endSampledValues_(0),
144 offset_(ptf.offset_.clone())
156 fieldTableName_(ptf.fieldTableName_),
157 setAverage_(ptf.setAverage_),
158 perturb_(ptf.perturb_),
159 mapMethod_(ptf.mapMethod_),
160 mapperPtr_(ptf.mapperPtr_),
161 sampleTimes_(ptf.sampleTimes_),
162 startSampleTime_(ptf.startSampleTime_),
163 startSampledValues_(ptf.startSampledValues_),
164 startAverage_(ptf.startAverage_),
165 endSampleTime_(ptf.endSampleTime_),
166 endSampledValues_(ptf.endSampledValues_),
167 endAverage_(ptf.endAverage_),
168 offset_(ptf.offset_.clone())
181 fieldTableName_(ptf.fieldTableName_),
182 setAverage_(ptf.setAverage_),
183 perturb_(ptf.perturb_),
184 mapMethod_(ptf.mapMethod_),
185 mapperPtr_(ptf.mapperPtr_),
186 sampleTimes_(ptf.sampleTimes_),
187 startSampleTime_(ptf.startSampleTime_),
188 startSampledValues_(ptf.startSampledValues_),
189 startAverage_(ptf.startAverage_),
190 endSampleTime_(ptf.endSampleTime_),
191 endSampledValues_(ptf.endSampledValues_),
192 endAverage_(ptf.endAverage_),
193 offset_(ptf.offset_.clone())
206 if (startSampledValues_.size())
208 startSampledValues_.autoMap(m);
209 endSampledValues_.autoMap(m);
213 startSampleTime_ = -1;
228 refCast<const timeVaryingMappedFixedValuePointPatchField<Type>>(ptf);
230 startSampledValues_.
rmap(tiptf.startSampledValues_, addr);
231 endSampledValues_.rmap(tiptf.endSampledValues_, addr);
235 startSampleTime_ = -1;
243 const Time& time = this->db().
time();
246 if (startSampleTime_ == -1 && endSampleTime_ == -1)
248 const polyMesh& pMesh = this->
patch().boundaryMesh().mesh()();
272 polyMesh::meshSubDir,
287 /this->
patch().name()
308 && mapMethod_ !=
"planarInterpolation"
325 const fileName samplePointsDir = samplePointsFile.
path();
326 sampleTimes_ = Time::findTimes(samplePointsDir);
330 Info<<
"timeVaryingMappedFixedValuePointPatchField : In directory "
331 << samplePointsDir <<
" found times "
332 << pointToPointPlanarInterpolation::timeNames(sampleTimes_)
341 bool foundTime = mapperPtr_().findTime
353 <<
"Cannot find starting sampling values for current time "
355 <<
"Have sampling values for times "
356 << pointToPointPlanarInterpolation::timeNames(sampleTimes_) <<
nl
359 <<
"\n on patch " << this->
patch().name()
360 <<
" of field " << fieldTableName_
367 if (lo != startSampleTime_)
369 startSampleTime_ = lo;
371 if (startSampleTime_ == endSampleTime_)
376 Pout<<
"checkTable : Setting startValues to (already read) "
378 /this->
patch().name()
379 /sampleTimes_[startSampleTime_].name()
382 startSampledValues_ = endSampledValues_;
383 startAverage_ = endAverage_;
389 Pout<<
"checkTable : Reading startValues from "
391 /this->
patch().name()
392 /sampleTimes_[lo].name()
401 /this->
patch().name()
402 /sampleTimes_[startSampleTime_].name()
419 startAverage_ = vals.
average();
422 if (vals.size() != mapperPtr_().sourceSize())
425 <<
"Number of values (" << vals.size()
426 <<
") differs from the number of points ("
427 << mapperPtr_().sourceSize()
431 startSampledValues_ = mapperPtr_().interpolate(vals);
435 if (hi != endSampleTime_)
439 if (endSampleTime_ == -1)
444 Pout<<
"checkTable : Clearing endValues" <<
endl;
446 endSampledValues_.clear();
452 Pout<<
"checkTable : Reading endValues from "
454 /this->
patch().name()
455 /sampleTimes_[endSampleTime_].name()
464 /this->
patch().name()
465 /sampleTimes_[endSampleTime_].name()
486 if (vals.size() != mapperPtr_().sourceSize())
489 <<
"Number of values (" << vals.size()
490 <<
") differs from the number of points ("
491 << mapperPtr_().sourceSize()
495 endSampledValues_ = mapperPtr_().interpolate(vals);
515 if (endSampleTime_ == -1)
520 Pout<<
"updateCoeffs : Sampled, non-interpolated values"
521 <<
" from start time:"
522 << sampleTimes_[startSampleTime_].
name() <<
nl;
526 wantedAverage = startAverage_;
530 scalar start = sampleTimes_[startSampleTime_].value();
531 scalar
end = sampleTimes_[endSampleTime_].value();
533 scalar
s = (this->db().time().value()-start)/(
end-start);
537 Pout<<
"updateCoeffs : Sampled, interpolated values"
538 <<
" between start time:"
539 << sampleTimes_[startSampleTime_].
name()
540 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
541 <<
" with weight:" <<
s <<
endl;
544 this->
operator==((1-s)*startSampledValues_ +
s*endSampledValues_);
545 wantedAverage = (1-
s)*startAverage_ +
s*endAverage_;
558 Pout<<
"updateCoeffs :"
559 <<
" actual average:" << averagePsi
560 <<
" wanted average:" << wantedAverage
564 if (
mag(averagePsi) < VSMALL)
567 const Type offset = wantedAverage - averagePsi;
570 Pout<<
"updateCoeffs :"
571 <<
" offsetting with:" << offset <<
endl;
577 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
581 Pout<<
"updateCoeffs :"
582 <<
" scaling with:" << scale <<
endl;
591 const scalar t = this->db().time().timeOutputValue();
597 Pout<<
"updateCoeffs : set fixedValue to min:" <<
gMin(*
this)
598 <<
" max:" <<
gMax(*
this)
620 this->internalField().
name(),
627 "planarInterpolation",
633 offset_->writeData(os);
int debug
Static debugging option.
vectorField pointField
pointField is a vectorField.
virtual const pointField & points() const
Return raw points.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
A class for handling file names.
A primitive field of type <T> with automated input and output.
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))
static std::string path(const std::string &str)
Return directory path name (part before last /)
static constexpr const zero Zero
Global zero (0)
Type gAverage(const FieldField< Field, Type > &f)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
const Time & time() const
Return time.
const fileName & facesInstance() const
Return the current instance directory for faces.
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type & value() const
Return const reference to value.
Basic pointPatch represents a set of points from the mesh.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Abstract base class for point-mesh patch fields.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Mesh consisting of general polyhedral cells.
Foam::pointPatchFieldMapper.
const fileName & pointsInstance() const
Return the current instance directory for points.
A FixedValue boundary condition for pointField.
Generic templated field type.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Like IOField but falls back to raw IFstream if no header found. Optionally reads average value....
messageStream Info
Information stream (uses stdout - output is on the master only)
A time-varying form of a mapped fixed value boundary condition.
word name(const complex &c)
Return string representation of complex.
virtual const fileName & name() const
Return the name of the stream.
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
virtual void write(Ostream &) const
Write.
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
timeVaryingMappedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))
const Type & average() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const std::string patch
OpenFOAM patch number as a std::string.
fileName caseConstant() const
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const dimensionedScalar e
Elementary charge.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Type gMin(const FieldField< Field, Type > &f)
void checkTable()
Find boundary data inbetween current time and interpolate.
const word & constant() const
Return constant name.
Type gMax(const FieldField< Field, Type > &f)
string evaluate(const std::string &s, size_t pos=0, size_t len=std::string::npos)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...