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 | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::averageCondition
26 
27 Description
28  Average run time condition - satisfied when average does not change by
29  more than a given value.
30 
31 SourceFiles
32  averageCondition.H
33  averageCondition.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef averageCondition_H
38 #define averageCondition_H
39 
40 #include "runTimeCondition.H"
41 #include "Switch.H"
42 
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class averageCondition Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class averageCondition
54 :
55  public runTimeCondition
56 {
57 protected:
58 
59  // Protected data
60 
61  //- Name of function object to retrueve data from
63 
64  //- List of fields on which to operate
66 
67  //- Satisfied when difference in mean values is less than this value
68  const scalar tolerance_;
69 
70  //- Averaging window
71  const scalar window_;
72 
73  //- Average time per field
75 
76  //- Reset the averaging process on restart flag
78 
79 
80  // Protected Member Functions
81 
82  //- Templated function to calculate the average
83  template<class Type>
84  void calc
85  (
86  const word& fieldName,
87  const scalar alpha,
88  const scalar beta,
89  bool& satisfied,
90  bool& processed
91  );
92 
93 
94 public:
95 
96  //- Runtime type information
97  TypeName("average");
98 
99  //- Constructor
101  (
102  const word& name,
103  const objectRegistry& obr,
104  const dictionary& dict,
105  functionObjectState& state
106  );
107 
108  //- Destructor
109  virtual ~averageCondition();
110 
111 
112  // Public Member Functions
113 
114  //- Apply the condition
115  virtual bool apply();
116 
117  //- Write
118  virtual void write();
119 };
120 
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 } // End namespace Foam
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 #ifdef NoRepository
129  #include "averageConditionTemplates.C"
130 #endif
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 #endif
135 
136 // ************************************************************************* //
Foam::runTimeCondition
Base class for run time conditions.
Definition: runTimeCondition.H:54
beta
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
Foam::averageCondition::window_
const scalar window_
Averaging window.
Definition: averageCondition.H:70
Foam::averageCondition::apply
virtual bool apply()
Apply the condition.
Definition: averageCondition.C:83
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::averageCondition::calc
void calc(const word &fieldName, const scalar alpha, const scalar beta, bool &satisfied, bool &processed)
Templated function to calculate the average.
Definition: averageConditionTemplates.C:30
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
Foam::averageCondition::TypeName
TypeName("average")
Runtime type information.
Foam::averageCondition::totalTime_
List< scalar > totalTime_
Average time per field.
Definition: averageCondition.H:73
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
Foam::averageCondition::averageCondition
averageCondition(const word &name, const objectRegistry &obr, const dictionary &dict, functionObjectState &state)
Constructor.
Definition: averageCondition.C:42
Foam::averageCondition::write
virtual void write()
Write.
Definition: averageCondition.C:155
Foam::averageCondition::functionObjectName_
word functionObjectName_
Name of function object to retrueve data from.
Definition: averageCondition.H:61
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
runTimeCondition.H
Foam::runTimeCondition::name
virtual const word & name() const
Return the condition name.
Definition: runTimeCondition.C:92
Foam::averageCondition::tolerance_
const scalar tolerance_
Satisfied when difference in mean values is less than this value.
Definition: averageCondition.H:67
Switch.H
Foam::averageCondition
Average run time condition - satisfied when average does not change by more than a given value.
Definition: averageCondition.H:52
Foam::averageCondition::~averageCondition
virtual ~averageCondition()
Destructor.
Definition: averageCondition.C:77
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::averageCondition::resetOnRestart_
Switch resetOnRestart_
Reset the averaging process on restart flag.
Definition: averageCondition.H:76
averageConditionTemplates.C
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::averageCondition::fieldNames_
wordList fieldNames_
List of fields on which to operate.
Definition: averageCondition.H:64