Loading...
Searching...
No Matches
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"
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
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,
52 stateFunctionObject& state
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);
64 conditionDict.readIfPresent("iter", iter_);
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
93{
94 dictionary& conditionDict = this->conditionDict();
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:133
Average run time condition - satisfied when average does not change by more than a given value.
averageCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
label nIterStartUp_
Number of start-up iterations before allowing satisfied checks.
const objectRegistry & obr_
Reference to the object registry.
const dictionary & conditionDict() const
Return const access to the conditions dictionary.
runTimeCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
virtual const word & name() const
Return the condition name.
Base class for function objects, adding functionality to read/write state information (data required ...
virtual void readState(dictionary &dict)
Read state from dictionary.
virtual void writeState(dictionary &dict)
Write state to dictionary for restarts.
virtual bool calculate(dictionary &dict)
Calculate the averages.
valueAverageBase(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state, const bool writeToFile=true)
Construct from Time and dictionary.
virtual void resetState(dictionary &dict)
Reset state.
Registry of regIOobjects.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition Ostream.H:490
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition Ostream.H:499
dictionary dict