37 const word& redirectType,
38 const word& entryName,
44 dictConstructed_(true),
45 setAverage_(
dict.getOrDefault(
"setAverage", false)),
46 fieldTableName_(
dict.getOrDefault<
word>(
"fieldTable", entryName)),
47 perturb_(
dict.getOrDefault<scalar>(
"perturb", 1
e-5)),
48 pointsName_(
dict.getOrDefault<
word>(
"points",
"points")),
60 startSampledValues_(0),
69 mapMethod_ !=
"planarInterpolation"
70 && mapMethod_ !=
"nearest"
74 <<
"mapMethod should be one of 'planarInterpolation'"
84 const word& entryName,
86 const word& fieldTableName,
91 dictConstructed_(false),
92 setAverage_(
dict.getOrDefault(
"setAverage", false)),
93 fieldTableName_(fieldTableName),
94 perturb_(
dict.getOrDefault<scalar>(
"perturb", 1
e-5)),
95 pointsName_(
dict.getOrDefault<
word>(
"points",
"points")),
101 "planarInterpolation"
106 startSampleTime_(-1),
107 startSampledValues_(0),
110 endSampledValues_(0),
116 mapMethod_ !=
"planarInterpolation"
117 && mapMethod_ !=
"nearest"
121 <<
"mapMethod should be one of 'planarInterpolation'"
145 dictConstructed_(rhs.dictConstructed_),
146 setAverage_(rhs.setAverage_),
147 fieldTableName_(rhs.fieldTableName_),
148 perturb_(rhs.perturb_),
149 pointsName_(rhs.pointsName_),
150 mapMethod_(rhs.mapMethod_),
151 mapperPtr_(rhs.mapperPtr_.clone()),
152 sampleTimes_(rhs.sampleTimes_),
153 startSampleTime_(rhs.startSampleTime_),
154 startSampledValues_(rhs.startSampledValues_),
155 startAverage_(rhs.startAverage_),
156 endSampleTime_(rhs.endSampleTime_),
157 endSampledValues_(rhs.endSampledValues_),
158 endAverage_(rhs.endAverage_),
159 offset_(rhs.offset_.clone())
173 if (startSampledValues_.size())
175 startSampledValues_.autoMap(mapper);
178 if (endSampledValues_.size())
180 endSampledValues_.autoMap(mapper);
185 startSampleTime_ = -1;
200 refCast<const PatchFunction1Types::MappedFile<Type>>(pf1);
202 if (tiptf.startSampledValues_.size())
204 startSampledValues_.setSize(this->size());
205 startSampledValues_.
rmap(tiptf.startSampledValues_, addr);
208 if (tiptf.endSampledValues_.size())
210 endSampledValues_.setSize(this->size());
211 endSampledValues_.rmap(tiptf.endSampledValues_, addr);
216 startSampleTime_ = -1;
227 const polyMesh&
mesh = this->patch_.boundaryMesh().mesh();
258 <<
"Read " << samplePoints.
size() <<
" sample points from "
259 << samplePointsFile <<
endl;
266 && mapMethod_ !=
"planarInterpolation"
270 if (this->faceValues())
277 this->localPosition(this->patch_.faceCentres()),
290 this->localPosition(this->patch_.localPoints()),
304 << samplePointsDir <<
" found times "
314 bool foundTime = mapperPtr_().findTime
326 <<
"Cannot find starting sampling values for index "
328 <<
"Have sampling values for "
331 << time.
constant()/
mesh.dbDir()/
"boundaryData"/this->patch_.name()
332 <<
"\n on patch " << this->patch_.name()
333 <<
" of field " << fieldTableName_
340 if (lo != startSampleTime_)
342 startSampleTime_ = lo;
344 if (startSampleTime_ == endSampleTime_)
349 Pout<<
"checkTable : Setting startValues to (already read) "
352 /sampleTimes_[startSampleTime_].
name()
355 startSampledValues_ = endSampledValues_;
356 startAverage_ = endAverage_;
362 Pout<<
"checkTable : Reading startValues from "
365 /sampleTimes_[lo].
name()
371 const fileName valsFile
378 /sampleTimes_[startSampleTime_].name()
392 const rawIOField<Type> vals(
io, setAverage_);
395 startAverage_ = vals.average();
398 if (vals.size() != mapperPtr_().sourceSize())
401 <<
"Number of values (" << vals.size()
402 <<
") differs from the number of points ("
403 << mapperPtr_().sourceSize()
407 startSampledValues_ = mapperPtr_().interpolate(vals);
411 if (hi != endSampleTime_)
415 if (endSampleTime_ == -1)
420 Pout<<
"checkTable : Clearing endValues" <<
endl;
422 endSampledValues_.clear();
428 Pout<<
"checkTable : Reading endValues from "
431 /sampleTimes_[endSampleTime_].
name()
443 /sampleTimes_[endSampleTime_].name()
457 const rawIOField<Type> vals(
io, setAverage_);
460 endAverage_ = vals.average();
463 if (vals.size() != mapperPtr_().sourceSize())
466 <<
"Number of values (" << vals.size()
467 <<
") differs from the number of points ("
468 << mapperPtr_().sourceSize()
472 endSampledValues_ = mapperPtr_().interpolate(vals);
488 auto&
fld = tfld.ref();
491 if (endSampleTime_ == -1)
496 Pout<<
"MappedFile<Type>::value : Sampled, non-interpolated values"
497 <<
" from start time:"
498 << sampleTimes_[startSampleTime_].
name() <<
nl;
501 fld = startSampledValues_;
502 wantedAverage = startAverage_;
506 scalar start = sampleTimes_[startSampleTime_].value();
507 scalar end = sampleTimes_[endSampleTime_].value();
509 scalar
s = (
x - start)/(end - start);
513 Pout<<
"MappedFile<Type>::value : Sampled, interpolated values"
514 <<
" between start time:"
515 << sampleTimes_[startSampleTime_].
name()
516 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
517 <<
" with weight:" <<
s <<
endl;
520 fld = ((1 -
s)*startSampledValues_ +
s*endSampledValues_);
521 wantedAverage = (1 -
s)*startAverage_ +
s*endAverage_;
529 if (this->faceValues())
541 Pout<<
"MappedFile<Type>::value :"
542 <<
" actual average:" << averagePsi
543 <<
" wanted average:" << wantedAverage
547 if (
mag(averagePsi) < VSMALL)
550 const Type offset = wantedAverage - averagePsi;
553 Pout<<
"MappedFile<Type>::value :"
554 <<
" offsetting with:" << offset <<
endl;
560 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
564 Pout<<
"MappedFile<Type>::value :"
565 <<
" scaling with:" << scale <<
endl;
574 fld += offset_->value(
x);
579 Pout<<
"MappedFile<Type>::value : set fixedValue to min:" <<
gMin(
fld)
607 os.writeEntryIfDifferent
616 os.writeEntry(
"setAverage", setAverage_);
619 os.writeEntryIfDifferent<scalar>(
"perturb", 1
e-5, perturb_);
621 os.writeEntryIfDifferent<
word>(
"points",
"points", pointsName_);
623 os.writeEntryIfDifferent<
word>
626 "planarInterpolation",
632 offset_->writeData(
os);
647 if (dictConstructed_)
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Abstract base class to hold the Field mapping addressing and weights.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual const fileName & name() const
Get the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Patch value mapping from a set of values stored in a file and a set of unstructured points using the ...
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
virtual void writeEntries(Ostream &os) const
Write coefficient entries in dictionary format.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
virtual void rmap(const PatchFunction1< Type > &rhs, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
const polyPatch const word const word const dictionary & dict
static instantList findTimes(const fileName &directory, const word &constantName="constant")
Search a given directory for valid time directories.
const word & constant() const
Return constant name.
fileName globalPath() const
Return global path for the case.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
static std::string path(const std::string &str)
Return directory path name (part before last /)
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
Interpolates between two sets of unstructured points using 2D Delaunay triangulation....
static wordList timeNames(const instantList &)
Helper: extract words of times.
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
Like IOField but falls back to raw IFstream if no header found. Optionally reads average value....
void checkTable()
Find boundary data inbetween current time and interpolate.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
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))
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define DebugInfo
Report an information message using Foam::Info.
Type gSum(const FieldField< Field, Type > &f)
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Type gAverage(const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Type gMin(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gMax(const FieldField< Field, Type > &f)
constexpr char nl
The newline '\n' character (0x0a)