averageCondition.H
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) 2015 OpenFOAM Foundation
9  Copyright (C) 2016-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::runTimeControls::averageCondition
29 
30 Description
31  Average run time condition - satisfied when average does not change by
32  more than a given value.
33 
34 SourceFiles
35  averageCondition.H
36  averageCondition.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef averageCondition_H
41 #define averageCondition_H
42 
43 #include "runTimeCondition.H"
44 #include "Switch.H"
45 #include "Enum.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 namespace functionObjects
52 {
53 namespace runTimeControls
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class averageCondition Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class averageCondition
61 :
62  public runTimeCondition
63 {
64 public:
65 
66  // Public enumerations
67 
68  enum class windowType
69  {
70  NONE,
72  EXACT
73  };
74 
75  static const Enum<windowType> windowTypeNames;
76 
77 
78 protected:
79 
80  // Protected data
81 
82  //- Name of function object to retrieve data from
84 
85  //- List of fields on which to operate
87 
88  //- Satisfied when difference in mean values is less than this value
89  const scalar tolerance_;
90 
91  //- Averaging window
92  const scalar window_;
93 
94  //- Averaging window type
96 
97  //- Average time per field
99 
100  //- Reset the averaging process on restart flag
102 
103  //- Number of start-up iterations before allowing satisfied checks
104  label nIterStartUp_;
105 
106  //- Current iteration count
107  label iter_;
108 
109  // Protected Member Functions
110 
111  //- Templated function to calculate the average
112  template<class Type>
113  void calc
114  (
115  const label fieldi,
116  bool& satisfied,
117  bool& processed
118  );
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("average");
125 
126  //- Constructor
128  (
129  const word& name,
130  const objectRegistry& obr,
131  const dictionary& dict,
132  stateFunctionObject& state
133  );
134 
135  //- Destructor
136  virtual ~averageCondition() = default;
137 
138 
139  // Public Member Functions
140 
141  //- Apply the condition
142  virtual bool apply();
143 
144  //- Write
145  virtual void write();
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace runTimeControls
152 } // End namespace functionObjects
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #ifdef NoRepository
158  #include "averageConditionTemplates.C"
159 #endif
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
Foam::functionObjects::runTimeControls::runTimeCondition::name
virtual const word & name() const
Return the condition name.
Definition: runTimeCondition.C:98
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::Enum< windowType >
Foam::functionObjects::runTimeControls::runTimeCondition
Base class for run time conditions.
Definition: runTimeCondition.H:61
Foam::functionObjects::runTimeControls::averageCondition::totalTime_
List< scalar > totalTime_
Average time per field.
Definition: averageCondition.H:97
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::runTimeControls::averageCondition::window_
const scalar window_
Averaging window.
Definition: averageCondition.H:91
Foam::functionObjects::runTimeControls::averageCondition::nIterStartUp_
label nIterStartUp_
Number of start-up iterations before allowing satisfied checks.
Definition: averageCondition.H:103
Foam::functionObjects::stateFunctionObject
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: stateFunctionObject.H:69
Foam::functionObjects::runTimeControls::averageCondition::TypeName
TypeName("average")
Runtime type information.
Foam::functionObjects::runTimeControls::averageCondition::windowType::NONE
Foam::functionObjects::runTimeControls::averageCondition::windowType::APPROXIMATE
Foam::functionObjects::runTimeControls::averageCondition::tolerance_
const scalar tolerance_
Satisfied when difference in mean values is less than this value.
Definition: averageCondition.H:88
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
runTimeCondition.H
Foam::functionObjects::runTimeControls::averageCondition
Average run time condition - satisfied when average does not change by more than a given value.
Definition: averageCondition.H:59
Foam::functionObjects::runTimeControls::averageCondition::functionObjectName_
word functionObjectName_
Name of function object to retrieve data from.
Definition: averageCondition.H:82
Foam::functionObjects::runTimeControls::averageCondition::windowType
windowType
Definition: averageCondition.H:67
Foam::functionObjects::runTimeControls::averageCondition::iter_
label iter_
Current iteration count.
Definition: averageCondition.H:106
Foam::functionObjects::runTimeControls::averageCondition::windowType_
windowType windowType_
Averaging window type.
Definition: averageCondition.H:94
Foam::functionObjects::runTimeControls::averageCondition::write
virtual void write()
Write.
Definition: averageCondition.C:172
Switch.H
Foam::functionObjects::runTimeControls::averageCondition::calc
void calc(const label fieldi, bool &satisfied, bool &processed)
Templated function to calculate the average.
Definition: averageConditionTemplates.C:36
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::runTimeControls::averageCondition::apply
virtual bool apply()
Apply the condition.
Definition: averageCondition.C:115
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::runTimeControls::averageCondition::~averageCondition
virtual ~averageCondition()=default
Destructor.
Foam::functionObjects::runTimeControls::averageCondition::averageCondition
averageCondition(const word &name, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Constructor.
Definition: averageCondition.C:62
Foam::functionObjects::runTimeControls::averageCondition::fieldNames_
wordList fieldNames_
List of fields on which to operate.
Definition: averageCondition.H:85
averageConditionTemplates.C
Foam::List< word >
Foam::functionObjects::runTimeControls::averageCondition::windowType::EXACT
Foam::functionObjects::runTimeControls::averageCondition::resetOnRestart_
Switch resetOnRestart_
Reset the averaging process on restart flag.
Definition: averageCondition.H:100
Enum.H
Foam::functionObjects::runTimeControls::averageCondition::windowTypeNames
static const Enum< windowType > windowTypeNames
Definition: averageCondition.H:74