42 fieldTableName_(iF.
name()),
48 startSampledValues_(0),
67 fieldTableName_(iF.name()),
68 setAverage_(dict.lookupOrDefault(
"setAverage",
false)),
69 perturb_(dict.lookupOrDefault(
"perturb", 1
e-5)),
72 dict.lookupOrDefault<
word>
81 startSampledValues_(0),
88 if (dict.found(
"offset"))
95 mapMethod_ !=
"planarInterpolation" 96 && mapMethod_ !=
"nearest" 102 ) <<
"mapMethod should be one of 'planarInterpolation'" 106 dict.readIfPresent(
"fieldTable", fieldTableName_);
108 if (dict.found(
"value"))
118 this->evaluate(Pstream::commsTypes::blocking);
134 fieldTableName_(ptf.fieldTableName_),
135 setAverage_(ptf.setAverage_),
136 perturb_(ptf.perturb_),
137 mapMethod_(ptf.mapMethod_),
140 startSampleTime_(-1),
141 startSampledValues_(0),
144 endSampledValues_(0),
146 offset_(ptf.offset_,
false)
158 fieldTableName_(ptf.fieldTableName_),
159 setAverage_(ptf.setAverage_),
160 perturb_(ptf.perturb_),
161 mapMethod_(ptf.mapMethod_),
163 sampleTimes_(ptf.sampleTimes_),
164 startSampleTime_(ptf.startSampleTime_),
165 startSampledValues_(ptf.startSampledValues_),
166 startAverage_(ptf.startAverage_),
167 endSampleTime_(ptf.endSampleTime_),
168 endSampledValues_(ptf.endSampledValues_),
169 endAverage_(ptf.endAverage_),
170 offset_(ptf.offset_,
false)
183 fieldTableName_(ptf.fieldTableName_),
184 setAverage_(ptf.setAverage_),
185 perturb_(ptf.perturb_),
186 mapMethod_(ptf.mapMethod_),
188 sampleTimes_(ptf.sampleTimes_),
189 startSampleTime_(ptf.startSampleTime_),
190 startSampledValues_(ptf.startSampledValues_),
191 startAverage_(ptf.startAverage_),
192 endSampleTime_(ptf.endSampleTime_),
193 endSampledValues_(ptf.endSampledValues_),
194 endAverage_(ptf.endAverage_),
195 offset_(ptf.offset_,
false)
208 if (startSampledValues_.size())
210 startSampledValues_.autoMap(m);
211 endSampledValues_.autoMap(m);
215 startSampleTime_ = -1;
230 refCast<const timeVaryingMappedFixedValueFvPatchField<Type>>(ptf);
232 startSampledValues_.
rmap(tiptf.startSampledValues_, addr);
233 endSampledValues_.rmap(tiptf.endSampledValues_, addr);
237 startSampleTime_ = -1;
246 if (mapperPtr_.empty())
253 /this->patch().
name()
261 Info<<
"timeVaryingMappedFixedValueFvPatchField :" 262 <<
" Read " << samplePoints.
size() <<
" sample points from " 263 << samplePointsFile <<
endl;
271 && mapMethod_ !=
"planarInterpolation" 280 this->patch().patch().faceCentres(),
287 const fileName samplePointsDir = samplePointsFile.
path();
288 sampleTimes_ = Time::findTimes(samplePointsDir);
292 Info<<
"timeVaryingMappedFixedValueFvPatchField : In directory " 293 << samplePointsDir <<
" found times " 294 << pointToPointPlanarInterpolation::timeNames(sampleTimes_)
304 bool foundTime = mapperPtr_().findTime
308 this->db().time().value(),
316 <<
"Cannot find starting sampling values for current time " 317 << this->db().time().value() <<
nl 318 <<
"Have sampling values for times " 319 << pointToPointPlanarInterpolation::timeNames(sampleTimes_) <<
nl 321 << this->db().time().constant()/
"boundaryData"/this->patch().name()
322 <<
"\n on patch " << this->patch().name()
323 <<
" of field " << fieldTableName_
330 if (lo != startSampleTime_)
332 startSampleTime_ = lo;
334 if (startSampleTime_ == endSampleTime_)
339 Pout<<
"checkTable : Setting startValues to (already read) " 341 /this->patch().
name()
342 /sampleTimes_[startSampleTime_].
name()
345 startSampledValues_ = endSampledValues_;
346 startAverage_ = endAverage_;
352 Pout<<
"checkTable : Reading startValues from " 354 /this->patch().
name()
355 /sampleTimes_[lo].
name()
365 /this->patch().
name()
366 /sampleTimes_[startSampleTime_].
name()
376 startAverage_ = avals.
average();
383 if (vals.
size() != mapperPtr_().sourceSize())
386 <<
"Number of values (" << vals.
size()
387 <<
") differs from the number of points (" 388 << mapperPtr_().sourceSize()
392 startSampledValues_ = mapperPtr_().interpolate(vals);
396 if (hi != endSampleTime_)
400 if (endSampleTime_ == -1)
405 Pout<<
"checkTable : Clearing endValues" <<
endl;
407 endSampledValues_.clear();
413 Pout<<
"checkTable : Reading endValues from " 415 /this->patch().
name()
416 /sampleTimes_[endSampleTime_].
name()
425 /this->patch().
name()
426 /sampleTimes_[endSampleTime_].
name()
443 if (vals.
size() != mapperPtr_().sourceSize())
446 <<
"Number of values (" << vals.
size()
447 <<
") differs from the number of points (" 448 << mapperPtr_().sourceSize()
452 endSampledValues_ = mapperPtr_().interpolate(vals);
473 if (endSampleTime_ == -1)
478 Pout<<
"updateCoeffs : Sampled, non-interpolated values" 479 <<
" from start time:" 480 << sampleTimes_[startSampleTime_].
name() <<
nl;
484 wantedAverage = startAverage_;
488 scalar start = sampleTimes_[startSampleTime_].value();
489 scalar end = sampleTimes_[endSampleTime_].value();
491 scalar
s = (this->db().time().value() - start)/(end - start);
495 Pout<<
"updateCoeffs : Sampled, interpolated values" 496 <<
" between start time:" 497 << sampleTimes_[startSampleTime_].
name()
498 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
499 <<
" with weight:" << s <<
endl;
502 this->
operator==((1 - s)*startSampledValues_ + s*endSampledValues_);
503 wantedAverage = (1 -
s)*startAverage_ + s*endAverage_;
513 gSum(this->patch().magSf()*fld)
514 /
gSum(this->patch().magSf());
518 Pout<<
"updateCoeffs :" 519 <<
" actual average:" << averagePsi
520 <<
" wanted average:" << wantedAverage
524 if (
mag(averagePsi) < VSMALL)
527 const Type offset = wantedAverage - averagePsi;
530 Pout<<
"updateCoeffs :" 531 <<
" offsetting with:" << offset <<
endl;
537 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
541 Pout<<
"updateCoeffs :" 542 <<
" scaling with:" << scale <<
endl;
551 const scalar t = this->db().time().timeOutputValue();
557 Pout<<
"updateCoeffs : set fixedValue to min:" <<
gMin(*
this)
558 <<
" max:" <<
gMax(*
this)
574 this->writeEntryIfDifferent(os,
"setAverage",
Switch(
false), setAverage_);
576 this->writeEntryIfDifferent(os,
"perturb", scalar(1
e-5), perturb_);
578 this->writeEntryIfDifferent
582 this->internalField().
name(),
586 this->writeEntryIfDifferent
590 word(
"planarInterpolation"),
596 offset_->writeData(os);
599 this->writeEntry(
"value", os);
virtual const fileName & name() const
Return the name of the stream.
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const word & name() const
Return name.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
A primitive field with a separate average value.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual void write(Ostream &) const
Write.
const dimensionedScalar e
Elementary charge.
This boundary conditions interpolates the values from a set of supplied points in space and time...
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){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Type gSum(const FieldField< Field, Type > &f)
Pre-declare SubField and related Field type.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Foam::fvPatchFieldMapper.
word name() const
Return file name (part beyond last /)
void checkTable()
Find boundary data inbetween current time and interpolate.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Type gMax(const FieldField< Field, Type > &f)
word name(const complex &)
Return a string representation of a complex.
timeVaryingMappedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Constant dispersed-phase particle diameter model.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Type gAverage(const FieldField< Field, Type > &f)
prefixOSstream Pout(cout, "Pout")
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensioned< scalar > mag(const dimensioned< Type > &)
fileName path() const
Return directory path name (part before last /)
const Type & average() const
Interpolates between two sets of unstructured points using 2D Delaunay triangulation. Used in e.g. timeVaryingMapped bcs.