35 namespace functionObjects
48 >::names[] = {
"iteration",
"time"};
63 if (faItems_[i].mean())
65 if (obr_.found(faItems_[i].meanFieldName()))
67 obr_.checkOut(*obr_[faItems_[i].meanFieldName()]);
71 if (faItems_[i].prime2Mean())
73 if (obr_.found(faItems_[i].prime2MeanFieldName()))
75 obr_.checkOut(*obr_[faItems_[i].prime2MeanFieldName()]);
84 if (!totalIter_.size())
86 totalIter_.setSize(faItems_.size(), 1);
89 if (!totalTime_.size())
91 totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
98 if (totalTime_[fieldi] < 0)
100 totalTime_[fieldi] = obr_.time().deltaTValue();
110 addMeanField<scalar>(fieldi);
111 addMeanField<vector>(fieldi);
112 addMeanField<sphericalTensor>(fieldi);
113 addMeanField<symmTensor>(fieldi);
114 addMeanField<tensor>(fieldi);
120 addPrime2MeanField<scalar, scalar>(fieldi);
121 addPrime2MeanField<vector, symmTensor>(fieldi);
133 Log <<
" Restarting averaging at time " << obr_.time().timeName()
150 const label currentTimeIndex = obr_.time().timeIndex();
151 const scalar currentTime = obr_.time().value();
153 if (prevTimeIndex_ == currentTimeIndex)
159 prevTimeIndex_ = currentTimeIndex;
162 if (periodicRestart_ && currentTime > restartPeriod_*periodIndex_)
169 <<
" Calculating averages" <<
nl;
171 addMeanSqrToPrime2Mean<scalar, scalar>();
172 addMeanSqrToPrime2Mean<vector, symmTensor>();
174 calculateMeanFields<scalar>();
175 calculateMeanFields<vector>();
176 calculateMeanFields<sphericalTensor>();
177 calculateMeanFields<symmTensor>();
178 calculateMeanFields<tensor>();
180 calculatePrime2MeanFields<scalar, scalar>();
181 calculatePrime2MeanFields<vector, symmTensor>();
185 totalIter_[fieldi]++;
186 totalTime_[fieldi] += obr_.time().deltaTValue();
195 Log <<
" Writing average fields" <<
endl;
197 writeFields<scalar>();
198 writeFields<vector>();
199 writeFields<sphericalTensor>();
200 writeFields<symmTensor>();
201 writeFields<tensor>();
213 name() +
"Properties",
214 obr_.time().timeName(),
225 const word& fieldName = faItems_[fieldi].fieldName();
227 propsDict.
subDict(fieldName).
add(
"totalIter", totalIter_[fieldi]);
228 propsDict.
subDict(fieldName).
add(
"totalTime", totalTime_[fieldi]);
231 propsDict.regIOobject::write();
239 if ((restartOnRestart_ || restartOnOutput_) &&
log)
241 Info<<
" Starting averaging at time " << obr_.time().timeName()
248 name() +
"Properties",
249 obr_.time().timeName(obr_.time().startTime().value()),
259 Log <<
" Starting averaging at time " 260 << obr_.time().timeName() <<
nl;
267 Log <<
" Restarting averaging for fields:" <<
nl;
269 totalIter_.setSize(faItems_.size(), 1);
273 totalTime_.setSize(faItems_.size(), -1);
277 const word& fieldName = faItems_[fieldi].fieldName();
278 if (propsDict.
found(fieldName))
282 totalIter_[fieldi] = fieldDict.
lookup<
label>(
"totalIter");
283 totalTime_[fieldi] = fieldDict.lookup<scalar>(
"totalTime");
285 Log <<
" " << fieldName
286 <<
" iters = " << totalIter_[fieldi]
287 <<
" time = " << totalTime_[fieldi] <<
nl;
305 restartOnRestart_(
false),
306 restartOnOutput_(
false),
307 periodicRestart_(
false),
308 restartPeriod_(great),
310 base_(baseType::iter),
334 initialised_ =
false;
344 base_ = baseTypeNames_
357 if (periodicRestart_)
359 dict.
lookup(
"restartPeriod") >> restartPeriod_;
362 readAveragingProperties();
376 fields[fieldi] = faItems_[fieldi].fieldName();
394 writeAveragingProperties();
396 if (restartOnOutput_)
void writeAveragingProperties() const
Write averaging properties - steps and time.
Class used for the read-construction of.
IOdictionary propsDict(systemDict("particleTracksDict", args, runTime))
void initialise()
Reset lists (clear existing values) and initialise averaging.
Calculates the natural logarithm of the specified scalar field.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
virtual bool read(const dictionary &)
Read the field average data.
#define forAll(list, i)
Loop across all elements in list.
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Templated form of IOobject providing type information for file reading and header type checking...
virtual bool write()
Write the field averages.
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
static const NamedEnum< baseType, 2 > baseTypeNames_
Averaging base type names.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
virtual bool execute()
Calculate the field averages.
Initialise the NamedEnum HashTable from the static list of names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Macros for easy insertion into run-time selection tables.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
fieldAverage(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
void readAveragingProperties()
Read averaging properties - steps and time.
A class for handling words, derived from string.
virtual void calcAverages()
Main calculation routine.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
word name(const complex &)
Return a string representation of a complex.
defineTypeNameAndDebug(Qdot, 0)
timeIOdictionary derived from IOdictionary with globalFile set false to enable writing to processor t...
virtual wordList fields() const
Return the list of fields required.
Info<< "Reading field p_rgh\"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, p_rgh, pimple.dict(), thermo.incompressible());mesh.schemes().setFluxRequired(p_rgh.name());hydrostaticInitialisation(p_rgh, p, rho, U, gh, ghf, pRef, thermo, pimple.dict());Info<< "Creating field dpdt\"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar(p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\"<< endl;volScalarField K("K", 0.5 *magSqr(U));dimensionedScalar initialMass=fvc::domainIntegrate(rho);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
void resetFields()
Checkout fields (causes deletion) from the database.
void restart()
Restart averaging for restartOnOutput.
#define Log
Report write to Foam::Info if the local log switch is true.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual ~fieldAverage()
Destructor.
virtual void writeAverages() const
Write averages.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
baseType
Enumeration defining the averaging base type.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.