41 const fileName fieldFileName
43 dataDir_/timeName/sampleName_/fieldTableName_
46 const fileName typeFieldFileName
48 dataDir_/timeName/sampleName_
49 /pTraits<Type>::typeName + Field<Type>::typeName
57 else if (
exists(typeFieldFileName))
59 return typeFieldFileName;
64 <<
"Cannot find field file " 65 << fieldFileName <<
" " << typeFieldFileName
68 return fileName::null;
77 if (mapperPtr_.empty())
80 const fileName samplePointsFile(dataDir_/pointsName_);
82 pointField samplePoints((IFstream(samplePointsFile)()));
86 Info<<
"timeVaryingMappedFvPatchField :" 87 <<
" Read " << samplePoints.size() <<
" sample points from " 88 << samplePointsFile <<
endl;
93 const bool nearestOnly
96 && mapMethod_ !=
"planarInterpolation" 102 new pointToPointPlanarInterpolation
105 patch_.patch().faceCentres(),
112 sampleTimes_ = Time::findTimes(dataDir_);
116 Info<<
"timeVaryingMappedFvPatchField : In directory " 117 << dataDir_ <<
" found times " 118 << pointToPointPlanarInterpolation::timeNames(sampleTimes_)
128 bool foundTime = mapperPtr_().findTime
140 <<
"Cannot find starting sampling values for current time " 141 << time().value() <<
nl 142 <<
"Have sampling values for times " 143 << pointToPointPlanarInterpolation::timeNames(sampleTimes_) <<
nl 144 <<
"In directory " << dataDir_ <<
" of field " << fieldTableName_
151 if (lo != startSampleTime_)
153 startSampleTime_ = lo;
155 if (startSampleTime_ == endSampleTime_)
160 Pout<<
"checkTable : Setting startValues to (already read) " 161 << dataDir_/sampleTimes_[startSampleTime_].
name()
164 startSampledValues_ = endSampledValues_;
165 startAverage_ = endAverage_;
171 Pout<<
"checkTable : Reading startValues from " 172 << dataDir_/sampleTimes_[lo].
name()
177 const fileName valsFile
179 findFieldFile(sampleTimes_[startSampleTime_].
name())
186 AverageField<Type> avals((IFstream(valsFile)()));
188 startAverage_ = avals.average();
192 (IFstream(valsFile)()) >> vals;
195 if (vals.size() != mapperPtr_().sourceSize())
198 <<
"Number of values (" << vals.size()
199 <<
") differs from the number of points (" 200 << mapperPtr_().sourceSize()
204 startSampledValues_ = mapperPtr_().interpolate(vals);
208 if (hi != endSampleTime_)
212 if (endSampleTime_ == -1)
217 Pout<<
"checkTable : Clearing endValues" <<
endl;
219 endSampledValues_.clear();
225 Pout<<
"checkTable : Reading endValues from " 226 << dataDir_/sampleTimes_[endSampleTime_].
name()
231 const fileName valsFile
233 findFieldFile(sampleTimes_[endSampleTime_].
name())
240 AverageField<Type> avals((IFstream(valsFile)()));
242 endAverage_ = avals.average();
246 (IFstream(valsFile)()) >> vals;
249 if (vals.size() != mapperPtr_().sourceSize())
252 <<
"Number of values (" << vals.size()
253 <<
") differs from the number of points (" 254 << mapperPtr_().sourceSize()
258 endSampledValues_ = mapperPtr_().interpolate(vals);
270 const word& fieldName
274 fieldTableName_(word::null),
275 dataDir_(time().constant()/
"boundaryData"/p.
name()),
276 pointsName_(
"points"),
277 sampleName_(word::null),
282 startSampleTime_(-1),
283 startSampledValues_(0),
286 endSampledValues_(0),
297 const word& fieldName
307 time().constant()/
"boundaryData"/p.
name()
319 "planarInterpolation" 324 startSampleTime_(-1),
325 startSampledValues_(0),
328 endSampledValues_(0),
333 pointsName_.expand();
334 sampleName_.expand();
336 if (dict.
found(
"offset"))
343 mapMethod_ !=
"planarInterpolation" 344 && mapMethod_ !=
"nearest" 350 ) <<
"mapMethod should be one of 'planarInterpolation'" 364 fieldTableName_(ptf.fieldTableName_),
365 dataDir_(ptf.dataDir_),
366 pointsName_(ptf.pointsName_),
367 sampleName_(ptf.sampleName_),
368 setAverage_(ptf.setAverage_),
369 perturb_(ptf.perturb_),
370 mapMethod_(ptf.mapMethod_),
372 sampleTimes_(ptf.sampleTimes_),
373 startSampleTime_(ptf.startSampleTime_),
374 startSampledValues_(ptf.startSampledValues_),
375 startAverage_(ptf.startAverage_),
376 endSampleTime_(ptf.endSampleTime_),
377 endSampledValues_(ptf.endSampledValues_),
378 endAverage_(ptf.endAverage_),
379 offset_(ptf.offset_,
false)
391 if (startSampledValues_.size())
393 m(startSampledValues_, startSampledValues_);
394 m(endSampledValues_, endSampledValues_);
398 startSampleTime_ = -1;
410 startSampledValues_.rmap(tiptf.startSampledValues_, addr);
411 endSampledValues_.rmap(tiptf.endSampledValues_, addr);
415 startSampleTime_ = -1;
432 if (endSampleTime_ == -1)
437 Pout<<
"updateCoeffs : Sampled, non-interpolated values" 438 <<
" from start time:" 439 << sampleTimes_[startSampleTime_].
name() <<
nl;
442 fld = startSampledValues_;
443 wantedAverage = startAverage_;
447 const scalar start = sampleTimes_[startSampleTime_].value();
448 const scalar end = sampleTimes_[endSampleTime_].value();
450 const scalar
s = (time().value() - start)/(end - start);
454 Pout<<
"updateCoeffs : Sampled, interpolated values" 455 <<
" between start time:" 456 << sampleTimes_[startSampleTime_].
name()
457 <<
" and end time:" << sampleTimes_[endSampleTime_].
name()
458 <<
" with weight:" << s <<
endl;
461 fld = (1 -
s)*startSampledValues_ + s*endSampledValues_;
462 wantedAverage = (1 -
s)*startAverage_ + s*endAverage_;
469 Type averagePsi =
gSum(patch_.magSf()*
fld)/
gSum(patch_.magSf());
473 Pout<<
"updateCoeffs :" 474 <<
" actual average:" << averagePsi
475 <<
" wanted average:" << wantedAverage
479 if (
mag(averagePsi) < vSmall)
482 const Type offset = wantedAverage - averagePsi;
485 Pout<<
"updateCoeffs :" 486 <<
" offsetting with:" << offset <<
endl;
492 const scalar scale =
mag(wantedAverage)/
mag(averagePsi);
496 Pout<<
"updateCoeffs :" 497 <<
" scaling with:" << scale <<
endl;
506 const scalar t = time().timeOutputValue();
507 fld += offset_->value(t);
512 Pout<<
"updateCoeffs : set fixedValue to min:" <<
gMin(fld)
513 <<
" max:" <<
gMax(fld)
531 time().constant()/
"boundaryData"/patch_.
name(),
540 writeEntry(os,
"fieldTable", fieldTableName_);
546 word(
"planarInterpolation"),
virtual const fileName & name() const
Return the name of the stream.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
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)
tmp< Field< Type > > map()
Return the current mapped patch field.
T & ref() const
Return non-const reference or generate a fatal error.
void writeEntryIfDifferent(Ostream &os, const word &entryName, const EntryType &value1, const EntryType &value2)
Helper function to write the keyword and entry only if the.
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/any.
void write(Ostream &) const
Write.
Patch field mapper which interpolates the values from a set of supplied points in space and time...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
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))
vectorField pointField
pointField is a vectorField.
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)
void rmap(const timeVaryingMappedFvPatchField< Type > &, const labelList &)
Reverse map the given timeVaryingMappedFvPatchField.
Pre-declare SubField and related Field type.
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
A class for handling words, derived from string.
virtual const fileName & name() const
Return the name of the stream.
Foam::fvPatchFieldMapper.
word name() const
Return file name (part beyond last /)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Type gMax(const FieldField< Field, Type > &f)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
word name(const complex &)
Return a string representation of a complex.
timeVaryingMappedFvPatchField(const fvPatch &, const word &fieldName)
Construct from patch and field name.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Type gAverage(const FieldField< Field, Type > &f)
prefixOSstream Pout(cout, "Pout")
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual const word & name() const
Return name.
A class for managing temporary objects.
const dimensionedScalar e
Elementary charge.