46 fieldTableName_(iF.
name()),
47 pointsName_(
"points"),
68 setAverage_(
dict.getOrDefault(
"setAverage", false)),
69 perturb_(
dict.getOrDefault(
"perturb", 1
e-5)),
70 fieldTableName_(iF.
name()),
71 pointsName_(
dict.getOrDefault<
word>(
"points",
"points")),
85 dict.readIfPresent(
"mapMethod", mapMethod_)
86 && !mapMethod_.empty()
87 && mapMethod_ !=
"nearest" 92 <<
"Unknown mapMethod type " << mapMethod_
93 <<
"\n\nValid mapMethod types :\n" 94 <<
"(nearest planar)" <<
nl 98 dict.readIfPresentCompat
100 "fieldTable", {{
"fieldTableName", 2206}},
119 const timeVaryingMappedFixedValuePointPatchField<Type>& ptf,
121 const DimensionedField<Type, pointMesh>& iF,
122 const pointPatchFieldMapper& mapper
125 fixedValuePointPatchField<Type>(ptf,
p, iF, mapper),
126 setAverage_(ptf.setAverage_),
127 perturb_(ptf.perturb_),
128 fieldTableName_(ptf.fieldTableName_),
129 pointsName_(ptf.pointsName_),
130 mapMethod_(ptf.mapMethod_),
133 sampleIndex_(-1, -1),
136 offset_(ptf.offset_.clone())
148 setAverage_(ptf.setAverage_),
149 perturb_(ptf.perturb_),
150 fieldTableName_(ptf.fieldTableName_),
151 pointsName_(ptf.pointsName_),
152 mapMethod_(ptf.mapMethod_),
153 mapperPtr_(ptf.mapperPtr_),
154 sampleTimes_(ptf.sampleTimes_),
155 sampleIndex_(ptf.sampleIndex_),
156 sampleAverage_(ptf.sampleAverage_),
157 sampleValues_(ptf.sampleValues_),
158 offset_(ptf.offset_.clone())
171 setAverage_(ptf.setAverage_),
172 perturb_(ptf.perturb_),
173 fieldTableName_(ptf.fieldTableName_),
174 pointsName_(ptf.pointsName_),
175 mapMethod_(ptf.mapMethod_),
176 mapperPtr_(ptf.mapperPtr_),
177 sampleTimes_(ptf.sampleTimes_),
178 sampleIndex_(ptf.sampleIndex_),
179 sampleAverage_(ptf.sampleAverage_),
180 sampleValues_(ptf.sampleValues_),
181 offset_(ptf.offset_.clone())
195 if (sampleValues_.first().size())
197 sampleValues_.first().autoMap(m);
200 if (sampleValues_.second().size())
202 sampleValues_.second().autoMap(m);
206 mapperPtr_.reset(
nullptr);
221 refCast<const timeVaryingMappedFixedValuePointPatchField<Type>>(ptf);
223 sampleValues_.
first().rmap(tiptf.sampleValues_.first(), addr);
224 sampleValues_.second().rmap(tiptf.sampleValues_.second(), addr);
227 mapperPtr_.reset(
nullptr);
235 const label sampleIndex,
240 tmp<Field<Type>> tvalues;
244 const Time& time = this->db().time();
248 Pout<<
"checkTable : Reading values from " 252 / this->
patch().name()
253 / sampleTimes_[sampleIndex].name()
259 const fileName valsFile
263 /this->
patch().name()
264 /sampleTimes_[sampleIndex].name()
278 rawIOField<Type> vals(
io, setAverage_);
280 if (vals.hasAverage())
282 avg = vals.average();
285 if (vals.size() != mapperPtr_().sourceSize())
288 <<
"Number of values (" << vals.size()
289 <<
") differs from the number of points (" 290 << mapperPtr_().sourceSize()
294 tvalues = tmp<Field<Type>>
::New(std::move(vals.field()));
298 field = mapperPtr_().interpolate(tvalues);
308 const Time& time = this->db().time();
311 if (sampleIndex_.first() == -1 && sampleIndex_.second() == -1)
313 const polyMesh& pMesh = this->
patch().boundaryMesh().mesh()();
318 if (pMesh.pointsInstance() == pMesh.facesInstance())
326 <<
"Reloading points0 from " << pMesh.facesInstance()
334 pMesh.facesInstance(),
346 const fileName samplePointsFile
350 /this->
patch().name()
365 const rawIOField<point> samplePoints(
io);
368 const bool nearestOnly =
370 !mapMethod_.empty() && !mapMethod_.starts_with(
"planar")
376 new pointToPointPlanarInterpolation
387 const fileName samplePointsDir = samplePointsFile.path();
404 if (timeIndices.first() < 0)
407 <<
"Cannot find starting sampling values for current time " 408 << time.value() <<
nl 409 <<
"Have sampling values for times " 412 << time.constant()/
"boundaryData"/this->
patch().name()
413 <<
"\n on patch " << this->
patch().name()
414 <<
" of field " << fieldTableName_
421 if (sampleIndex_.first() != timeIndices.first())
423 sampleIndex_.first() = timeIndices.first();
425 if (sampleIndex_.first() == sampleIndex_.second())
428 sampleValues_.first() = sampleValues_.second();
429 sampleAverage_.first() = sampleAverage_.second();
434 this->updateSampledValues
436 sampleIndex_.first(),
437 sampleValues_.first(),
438 sampleAverage_.first()
443 if (sampleIndex_.second() != timeIndices.second())
445 sampleIndex_.second() = timeIndices.second();
447 if (sampleIndex_.second() == -1)
450 sampleValues_.second().clear();
455 this->updateSampledValues
457 sampleIndex_.second(),
458 sampleValues_.second(),
459 sampleAverage_.second()
475 const scalar
x = this->db().time().value();
480 auto&
fld =
static_cast<Field<Type>&
>(*this);
483 if (sampleIndex_.second() == -1)
486 fld = sampleValues_.first();
487 wantedAverage = sampleAverage_.first();
491 const scalar beg = sampleTimes_[sampleIndex_.first()].value();
492 const scalar
end = sampleTimes_[sampleIndex_.second()].value();
493 const scalar
s = (
x - beg)/(
end - beg);
495 fld = (1 -
s)*sampleValues_.first() +
s*sampleValues_.second();
498 = (1 -
s)*sampleAverage_.first() +
s*sampleAverage_.second();
501 <<
"Sampled, interpolated values" 503 << sampleTimes_[sampleIndex_.first()].name()
504 <<
" and time:" << sampleTimes_[sampleIndex_.second()].name()
505 <<
" with weight:" <<
s <<
endl;
516 Pout<<
"updateCoeffs :" 517 <<
" actual average:" << averagePsi
518 <<
" wanted average:" << wantedAverage
522 if (
mag(averagePsi) < VSMALL)
525 const Type offset = wantedAverage - averagePsi;
528 Pout<<
"updateCoeffs :" 529 <<
" offsetting with:" << offset <<
endl;
535 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
539 Pout<<
"updateCoeffs :" 540 <<
" scaling with:" << scale <<
endl;
549 const scalar t = this->db().time().timeOutputValue();
550 fld += offset_->value(t);
555 Pout<<
"updateCoeffs : set fixedValue to min:" <<
gMin(*
this)
556 <<
" max:" <<
gMax(*
this)
575 this->internalField().
name(),
579 if (!pointsName_.empty())
584 if (!mapMethod_.empty() && !mapMethod_.starts_with(
"planar"))
598 offset_->writeData(
os);
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
static wordList timeNames(const instantList ×)
Helper: extract words of times.
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A time-varying form of a mapped fixed value boundary condition.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
vectorIOField pointIOField
pointIOField is a vectorIOField.
static Pair< label > findRange(const UList< instant > ×, const scalar timeVal, const label start=-1)
Find lower/upper indices for given time value in list of instances (linear search) continuing after t...
A FixedValue boundary condition for pointField.
constexpr char nl
The newline '\n' character (0x0a)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
T & first()
Access first element of the list, position [0].
Foam::pointPatchFieldMapper.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Ignore writing from objectRegistry::writeObject()
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void write(Ostream &) const
Write.
timeVaryingMappedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Abstract base class for point-mesh patch fields.
virtual void write(Ostream &) const
Write.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
#define DebugInFunction
Report an information message using Foam::Info.
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
Pair< label > labelPair
A pair of labels.
Type gMax(const FieldField< Field, Type > &f)
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
OBJstream os(runTime.globalPath()/outputName)
static instantList findTimes(const fileName &directory, const word &constantDirName="constant")
Search a given directory for valid time directories.
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))
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))
bool starts_with(char c) const
True if string starts with given character (cf. C++20)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Basic pointPatch represents a set of points from the mesh.
Type gAverage(const FieldField< Field, Type > &f)
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const std::string patch
OpenFOAM patch number as a std::string.
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
"buffered" : (MPI_Bsend, MPI_Recv)
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))
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)