averageCondition.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "averageCondition.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
35namespace functionObjects
36{
37namespace runTimeControls
38{
41}
42}
43}
44
45// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46
48(
49 const word& name,
50 const objectRegistry& obr,
51 const dictionary& dict,
53)
54:
55 runTimeCondition(name, obr, dict, state),
56 valueAverageBase(name, obr_, dict, state, false),
57 nIterStartUp_(dict.getOrDefault<label>("nIterStartUp", 10)),
58 iter_(-1)
59{
61
62 readState(conditionDict);
63
65}
66
67
68// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
69
71{
72 if (!active_)
73 {
74 return true;
75 }
76
77 bool running = iter_ > nIterStartUp_;
78
79 ++iter_;
80
81 dictionary& conditionDict = this->conditionDict();
82
83
85 running = valueAverageBase::calculate(conditionDict) && running;
87
88 return running;
89}
90
91
93{
94 dictionary& conditionDict = this->conditionDict();
95
96 valueAverageBase::writeState(conditionDict);
97
98 conditionDict.set("iter", iter_);
99}
100
101
103{
104 valueAverageBase::resetState(this->conditionDict());
105
106 iter_ = 0;
107}
108
109
110// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:780
Average run time condition - satisfied when average does not change by more than a given value.
const dictionary & conditionDict() const
Return const access to the conditions dictionary.
Base class for function objects, adding functionality to read/write state information (data required ...
Base class that computes the ensemble- or time-based singular-value average values,...
virtual void readState(dictionary &dict)
Read state from dictionary.
virtual void writeState(dictionary &dict)
Write state to dictionary for restarts.
virtual void resetState(dictionary &dict)
Reset state.
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:349
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:356
dictionary dict