35 namespace functionObjects
48 >::names[] = {
"iteration",
"time"};
73 initialiseMeanField<scalar>(fieldi);
74 initialiseMeanField<vector>(fieldi);
75 initialiseMeanField<sphericalTensor>(fieldi);
76 initialiseMeanField<symmTensor>(fieldi);
77 initialiseMeanField<tensor>(fieldi);
81 initialisePrime2MeanField<scalar, scalar>(fieldi);
82 initialisePrime2MeanField<vector, symmTensor>(fieldi);
89 Log <<
" Restarting averaging at time " << time_.name() <<
nl;
98 if (faItems_[i].mean())
100 if (obr_.found(faItems_[i].meanFieldName()))
102 obr_.checkOut(*obr_[faItems_[i].meanFieldName()]);
106 if (faItems_[i].prime2Mean())
108 if (obr_.found(faItems_[i].prime2MeanFieldName()))
110 obr_.checkOut(*obr_[faItems_[i].prime2MeanFieldName()]);
127 const label currentTimeIndex = time_.timeIndex();
128 const scalar currentTime = time_.value();
130 if (prevTimeIndex_ == currentTimeIndex)
135 prevTimeIndex_ = currentTimeIndex;
137 if (periodicRestart_ && currentTime > restartPeriod_*periodIndex_)
150 totalIter_[fieldi]++;
151 totalTime_[fieldi] += time_.deltaTValue();
154 Log <<
" Calculating averages" <<
nl;
156 addMeanSqrToPrime2Mean<scalar, scalar>();
157 addMeanSqrToPrime2Mean<vector, symmTensor>();
159 calculateMeanFields<scalar>();
160 calculateMeanFields<vector>();
161 calculateMeanFields<sphericalTensor>();
162 calculateMeanFields<symmTensor>();
163 calculateMeanFields<tensor>();
165 calculatePrime2MeanFields<scalar, scalar>();
166 calculatePrime2MeanFields<vector, symmTensor>();
175 <<
" Writing average fields" <<
endl;
177 writeFields<scalar>();
178 writeFields<vector>();
179 writeFields<sphericalTensor>();
180 writeFields<symmTensor>();
181 writeFields<tensor>();
187 name() +
"Properties",
199 const word& fieldName = faItems_[fieldi].fieldName();
201 propsDict.subDict(fieldName).add(
"totalIter", totalIter_[fieldi]);
202 propsDict.subDict(fieldName).add(
"totalTime", totalTime_[fieldi]);
217 dict.readIfPresent(
"restartOnRestart", restartOnRestart_);
218 dict.readIfPresent(
"restartOnOutput", restartOnOutput_);
219 dict.readIfPresent(
"periodicRestart", periodicRestart_);
221 if (periodicRestart_)
223 dict.lookup(
"restartPeriod") >> restartPeriod_;
226 mean_ =
dict.lookupOrDefault<
Switch>(
"mean",
true);
227 prime2Mean_ =
dict.lookupOrDefault<
Switch>(
"prime2Mean",
false);
228 base_ = baseTypeNames_[
dict.lookupOrDefault<
word>(
"base",
"time")];
229 window_ =
dict.lookupOrDefault<scalar>(
"window", -1);
230 windowName_ =
dict.lookupOrDefault<
word>(
"windowName",
"");
244 dict.lookup(
"fields"),
247 totalIter_.setSize(faItems_.size(), 0);
248 totalTime_.setSize(faItems_.size(), -1);
252 name() +
"Properties",
275 const word& fieldName = faItems_[fieldi].fieldName();
280 Log <<
" Starting averaging for fields:" <<
nl;
283 Log <<
" " << fieldName <<
nl;
290 const word& fieldName = faItems_[fieldi].fieldName();
295 Log <<
" Restarting averaging for fields:" <<
nl;
299 totalIter_[fieldi] = fieldPropsDict.
lookup<
label>(
"totalIter");
300 totalTime_[fieldi] = fieldPropsDict.
lookup<scalar>(
"totalTime");
301 Log <<
" " << fieldName
302 <<
" iters = " << totalIter_[fieldi]
303 <<
" time = " << totalTime_[fieldi] <<
nl;
322 dict.lookup(
"fields"),
325 totalIter_.resize(faItems_.size(), 0);
326 totalTime_.resize(faItems_.size(), -1);
329 labelList fieldiFieldi0s(faItems_.size(), -1);
332 const word& fieldName = faItems_[fieldi].fieldName();
335 if (faItems0[fieldi0].fieldName() == fieldName)
337 fieldiFieldi0s[fieldi] = fieldi0;
346 if (fieldiFieldi0s[fieldi] == -1)
350 Log <<
" Starting averaging for fields:" <<
nl;
353 Log <<
" " << faItems_[fieldi].fieldName() <<
nl;
360 if (fieldiFieldi0s[fieldi] != -1)
364 Log <<
" Continuing averaging for fields:" <<
nl;
367 totalIter_[fieldi] = totalIter0[fieldiFieldi0s[fieldi]];
368 totalTime_[fieldi] = totalTime0[fieldiFieldi0s[fieldi]];
369 Log <<
" " << faItems_[fieldi].fieldName()
370 <<
" iters = " << totalIter_[fieldi]
371 <<
" time = " << totalTime_[fieldi] <<
nl;
389 restartOnRestart_(false),
390 restartOnOutput_(false),
391 periodicRestart_(false),
392 restartPeriod_(great),
410 readMeanField<scalar>(fieldi);
411 readMeanField<vector>(fieldi);
412 readMeanField<sphericalTensor>(fieldi);
413 readMeanField<symmTensor>(fieldi);
414 readMeanField<tensor>(fieldi);
418 readPrime2MeanField<scalar, scalar>(fieldi);
419 readPrime2MeanField<vector, symmTensor>(fieldi);
454 fields[fieldi] = faItems_[fieldi].fieldName();
466 <<
"fieldAverage is not supported with the foamPostProcess utility"
482 if (restartOnOutput_)
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Initialise the NamedEnum HashTable from the static list of names.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
void transfer(PtrList< T > &)
Transfer the contents of the argument PtrList into this PtrList.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Abstract base-class for Time/database functionObjects.
virtual const word & type() const =0
Runtime type information.
static bool postProcess
Global post-processing mode switch.
const word & name() const
Return the name of this functionObject.
Class used for the read-construction of.
Calculates average quantities for a user-specified selection of volumetric and surface fields.
baseType
Enumeration defining the averaging base type.
void initialise()
Reset lists (clear existing values) and initialise averaging.
void restart()
Restart averaging for restartOnOutput.
static const NamedEnum< baseType, 2 > baseTypeNames_
Averaging base type names.
virtual void calcAverages()
Main calculation routine.
virtual wordList fields() const
Return the list of fields required.
virtual ~fieldAverage()
Destructor.
void read(const dictionary &dict, const bool construct)
Read.
List< scalar > totalTime_
Total time counter.
PtrList< fieldAverageItem > faItems_
List of field average items, describing what averages to be.
virtual void writeAverages() const
Write averages.
virtual bool execute()
Calculate the field averages.
virtual bool write()
Write the field averages.
fieldAverage(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual bool read(const dictionary &)
Read optional controls.
timeIOdictionary derived from IOdictionary with globalFile set false to enable writing to processor t...
Templated form of IOobject providing type information for file reading and header type checking.
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
A class for handling words, derived from string.
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
#define WarningInFunction
Report a warning using Foam::Warning.
#define Log
Report write to Foam::Info if the local log switch is true.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
bool read(const char *, int32_t &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
labelList first(const UList< labelPair > &p)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
IOdictionary propsDict(systemDict("particleTracksDict", args, runTime))