34 namespace functionObjects
47 >::names[] = {
"iteration",
"time"};
62 if (faItems_[i].mean())
64 if (obr_.found(faItems_[i].meanFieldName()))
66 obr_.checkOut(*obr_[faItems_[i].meanFieldName()]);
70 if (faItems_[i].prime2Mean())
72 if (obr_.found(faItems_[i].prime2MeanFieldName()))
74 obr_.checkOut(*obr_[faItems_[i].prime2MeanFieldName()]);
83 if (!totalIter_.size())
85 totalIter_.setSize(faItems_.size(), 1);
88 if (!totalTime_.size())
90 totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
97 if (totalTime_[fieldi] < 0)
99 totalTime_[fieldi] = obr_.time().deltaTValue();
109 addMeanField<scalar>(fieldi);
110 addMeanField<vector>(fieldi);
111 addMeanField<sphericalTensor>(fieldi);
112 addMeanField<symmTensor>(fieldi);
113 addMeanField<tensor>(fieldi);
119 addPrime2MeanField<scalar, scalar>(fieldi);
120 addPrime2MeanField<vector, symmTensor>(fieldi);
132 Log <<
" Restarting averaging at time " << obr_.time().timeName()
149 const label currentTimeIndex = obr_.time().timeIndex();
150 const scalar currentTime = obr_.time().value();
152 if (prevTimeIndex_ == currentTimeIndex)
158 prevTimeIndex_ = currentTimeIndex;
161 if (periodicRestart_ && currentTime > restartPeriod_*periodIndex_)
168 <<
" Calculating averages" <<
nl;
170 addMeanSqrToPrime2Mean<scalar, scalar>();
171 addMeanSqrToPrime2Mean<vector, symmTensor>();
173 calculateMeanFields<scalar>();
174 calculateMeanFields<vector>();
175 calculateMeanFields<sphericalTensor>();
176 calculateMeanFields<symmTensor>();
177 calculateMeanFields<tensor>();
179 calculatePrime2MeanFields<scalar, scalar>();
180 calculatePrime2MeanFields<vector, symmTensor>();
184 totalIter_[fieldi]++;
185 totalTime_[fieldi] += obr_.time().deltaTValue();
194 Log <<
" Writing average fields" <<
endl;
196 writeFields<scalar>();
197 writeFields<vector>();
198 writeFields<sphericalTensor>();
199 writeFields<symmTensor>();
200 writeFields<tensor>();
212 name() +
"Properties",
213 obr_.time().timeName(),
224 const word& fieldName = faItems_[fieldi].fieldName();
226 propsDict.
subDict(fieldName).
add(
"totalIter", totalIter_[fieldi]);
227 propsDict.
subDict(fieldName).
add(
"totalTime", totalTime_[fieldi]);
230 propsDict.regIOobject::write();
238 if ((restartOnRestart_ || restartOnOutput_) &&
log)
240 Info<<
" Starting averaging at time " << obr_.time().timeName()
247 name() +
"Properties",
248 obr_.time().timeName(obr_.time().startTime().value()),
258 Log <<
" Starting averaging at time " 259 << obr_.time().timeName() <<
nl;
266 Log <<
" Restarting averaging for fields:" <<
nl;
268 totalIter_.setSize(faItems_.size(), 1);
272 totalTime_.setSize(faItems_.size(), -1);
276 const word& fieldName = faItems_[fieldi].fieldName();
277 if (propsDict.
found(fieldName))
281 totalIter_[fieldi] = fieldDict.
lookup<
label>(
"totalIter");
282 totalTime_[fieldi] = fieldDict.lookup<scalar>(
"totalTime");
284 Log <<
" " << fieldName
285 <<
" iters = " << totalIter_[fieldi]
286 <<
" time = " << totalTime_[fieldi] <<
nl;
304 restartOnRestart_(
false),
305 restartOnOutput_(
false),
306 periodicRestart_(
false),
307 restartPeriod_(great),
309 base_(baseType::iter),
333 initialised_ =
false;
343 base_ = baseTypeNames_
356 if (periodicRestart_)
358 dict.
lookup(
"restartPeriod") >> restartPeriod_;
361 readAveragingProperties();
380 writeAveragingProperties();
382 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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool typeHeaderOk(const bool checkType=true)
Read header (uses typeFilePath to find file) and check header.
A list of keyword definitions, which are a keyword followed by any number of values (e...
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.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
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)
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.