40 const fileName fieldFileName
42 dataDir_/timeName/sampleName_/fieldTableName_
45 const fileName typeFieldFileName
47 dataDir_/timeName/sampleName_
48 /pTraits<Type>::typeName + Field<Type>::typeName
56 else if (
exists(typeFieldFileName))
58 return typeFieldFileName;
63 <<
"Cannot find field file " 64 << fieldFileName <<
" " << typeFieldFileName
67 return fileName::null;
76 if (mapperPtr_.empty())
79 const fileName samplePointsFile(dataDir_/pointsName_);
81 pointField samplePoints((IFstream(samplePointsFile)()));
85 Info<<
"timeVaryingMappedFixedValueFvPatchField :" 86 <<
" Read " << samplePoints.size() <<
" sample points from " 87 << samplePointsFile <<
endl;
95 && mapMethod_ !=
"planarInterpolation" 101 new pointToPointPlanarInterpolation
104 this->patch().patch().faceCentres(),
111 sampleTimes_ = Time::findTimes(dataDir_);
115 Info<<
"timeVaryingMappedFixedValueFvPatchField : In directory " 116 << dataDir_ <<
" found times " 117 << pointToPointPlanarInterpolation::timeNames(sampleTimes_)
127 bool foundTime = mapperPtr_().findTime
131 this->db().time().value(),
139 <<
"Cannot find starting sampling values for current time " 140 << this->db().time().value() <<
nl 141 <<
"Have sampling values for times " 142 << pointToPointPlanarInterpolation::timeNames(sampleTimes_) <<
nl 143 <<
"In directory " << dataDir_ <<
" of field " << fieldTableName_
150 if (lo != startSampleTime_)
152 startSampleTime_ = lo;
154 if (startSampleTime_ == endSampleTime_)
159 Pout<<
"checkTable : Setting startValues to (already read) " 160 << dataDir_/sampleTimes_[startSampleTime_].
name()
163 startSampledValues_ = endSampledValues_;
164 startAverage_ = endAverage_;
170 Pout<<
"checkTable : Reading startValues from " 171 << dataDir_/sampleTimes_[lo].
name()
176 const fileName valsFile
178 findFieldFile(sampleTimes_[startSampleTime_].
name())
185 AverageField<Type> avals((IFstream(valsFile)()));
187 startAverage_ = avals.average();
191 IFstream(valsFile)() >> vals;
194 if (vals.size() != mapperPtr_().sourceSize())
197 <<
"Number of values (" << vals.size()
198 <<
") differs from the number of points (" 199 << mapperPtr_().sourceSize()
203 startSampledValues_ = mapperPtr_().interpolate(vals);
207 if (hi != endSampleTime_)
211 if (endSampleTime_ == -1)
216 Pout<<
"checkTable : Clearing endValues" <<
endl;
218 endSampledValues_.clear();
224 Pout<<
"checkTable : Reading endValues from " 225 << dataDir_/sampleTimes_[endSampleTime_].
name()
230 const fileName valsFile
232 findFieldFile(sampleTimes_[endSampleTime_].
name())
239 AverageField<Type> avals((IFstream(valsFile)()));
241 endAverage_ = avals.average();
245 IFstream(valsFile)() >> vals;
248 if (vals.size() != mapperPtr_().sourceSize())
251 <<
"Number of values (" << vals.size()
252 <<
") differs from the number of points (" 253 << mapperPtr_().sourceSize()
257 endSampledValues_ = mapperPtr_().interpolate(vals);
274 fieldTableName_(iF.
name()),
275 dataDir_(this->db().time().constant()/
"boundaryData"/this->patch().name()),
276 pointsName_(
"points"),
277 sampleName_(word::null),
282 startSampleTime_(-1),
283 startSampledValues_(0),
286 endSampledValues_(0),
302 fieldTableName_(dict.lookupOrDefault(
"fieldTable", iF.name())),
308 this->db().time().constant()/
"boundaryData"/this->patch().name()
311 pointsName_(dict.lookupOrDefault<
fileName>(
"points",
"points")),
312 sampleName_(dict.lookupOrDefault(
"sample", word::null)),
313 setAverage_(dict.lookupOrDefault(
"setAverage",
false)),
314 perturb_(dict.lookupOrDefault(
"perturb", 1
e-5)),
317 dict.lookupOrDefault<
word>
320 "planarInterpolation" 325 startSampleTime_(-1),
326 startSampledValues_(0),
329 endSampledValues_(0),
334 pointsName_.expand();
335 sampleName_.expand();
337 if (dict.found(
"offset"))
344 mapMethod_ !=
"planarInterpolation" 345 && mapMethod_ !=
"nearest" 351 ) <<
"mapMethod should be one of 'planarInterpolation'" 355 if (dict.found(
"value"))
365 this->evaluate(Pstream::commsTypes::blocking);
381 fieldTableName_(ptf.fieldTableName_),
382 dataDir_(ptf.dataDir_),
383 pointsName_(ptf.pointsName_),
384 sampleName_(ptf.sampleName_),
385 setAverage_(ptf.setAverage_),
386 perturb_(ptf.perturb_),
387 mapMethod_(ptf.mapMethod_),
390 startSampleTime_(-1),
391 startSampledValues_(0),
394 endSampledValues_(0),
396 offset_(ptf.offset_,
false)
408 fieldTableName_(ptf.fieldTableName_),
409 dataDir_(ptf.dataDir_),
410 pointsName_(ptf.pointsName_),
411 sampleName_(ptf.sampleName_),
412 setAverage_(ptf.setAverage_),
413 perturb_(ptf.perturb_),
414 mapMethod_(ptf.mapMethod_),
416 sampleTimes_(ptf.sampleTimes_),
417 startSampleTime_(ptf.startSampleTime_),
418 startSampledValues_(ptf.startSampledValues_),
419 startAverage_(ptf.startAverage_),
420 endSampleTime_(ptf.endSampleTime_),
421 endSampledValues_(ptf.endSampledValues_),
422 endAverage_(ptf.endAverage_),
423 offset_(ptf.offset_,
false)
436 fieldTableName_(ptf.fieldTableName_),
437 dataDir_(ptf.dataDir_),
438 pointsName_(ptf.pointsName_),
439 sampleName_(ptf.sampleName_),
440 setAverage_(ptf.setAverage_),
441 perturb_(ptf.perturb_),
442 mapMethod_(ptf.mapMethod_),
444 sampleTimes_(ptf.sampleTimes_),
445 startSampleTime_(ptf.startSampleTime_),
446 startSampledValues_(ptf.startSampledValues_),
447 startAverage_(ptf.startAverage_),
448 endSampleTime_(ptf.endSampleTime_),
449 endSampledValues_(ptf.endSampledValues_),
450 endAverage_(ptf.endAverage_),
451 offset_(ptf.offset_,
false)
464 if (startSampledValues_.size())
466 startSampledValues_.autoMap(m);
467 endSampledValues_.autoMap(m);
471 startSampleTime_ = -1;
486 refCast<const timeVaryingMappedFixedValueFvPatchField<Type>>(ptf);
488 startSampledValues_.
rmap(tiptf.startSampledValues_, addr);
489 endSampledValues_.rmap(tiptf.endSampledValues_, addr);
493 startSampleTime_ = -1;
513 if (endSampleTime_ == -1)
518 Pout<<
"updateCoeffs : Sampled, non-interpolated values" 519 <<
" from start time:" 520 << sampleTimes_[startSampleTime_].
name() <<
nl;
524 wantedAverage = startAverage_;
528 scalar start = sampleTimes_[startSampleTime_].value();
529 scalar end = sampleTimes_[endSampleTime_].value();
531 scalar
s = (this->db().time().value() - start)/(end - start);
535 Pout<<
"updateCoeffs : Sampled, interpolated values" 536 <<
" between start time:" 537 << sampleTimes_[startSampleTime_].
name()
538 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
539 <<
" with weight:" << s <<
endl;
542 this->
operator==((1 - s)*startSampledValues_ + s*endSampledValues_);
543 wantedAverage = (1 -
s)*startAverage_ + s*endAverage_;
553 gSum(this->patch().magSf()*fld)
554 /
gSum(this->patch().magSf());
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)
614 this->writeEntryIfDifferent
618 this->db().time().constant()/
"boundaryData"/this->patch().
name(),
622 this->writeEntryIfDifferent(os,
"points",
fileName(
"points"), pointsName_);
624 this->writeEntryIfDifferent(os,
"sample", fileName::null, sampleName_);
626 this->writeEntryIfDifferent(os,
"setAverage",
Switch(
false), setAverage_);
628 this->writeEntryIfDifferent(os,
"perturb", scalar(1
e-5), perturb_);
630 this->writeEntryIfDifferent
634 this->internalField().
name(),
638 this->writeEntryIfDifferent
642 word(
"planarInterpolation"),
648 offset_->writeData(os);
651 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...
#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.
vectorField pointField
pointField is a vectorField.
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 /)
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.
#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 > &)
bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?