solutionControl.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) 2011-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::solutionControl
26 
27 Description
28  Base class for solution control classes
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef solutionControl_H
33 #define solutionControl_H
34 
35 #include "fvMesh.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 /*---------------------------------------------------------------------------*\
43  Class solutionControl Declaration
44 \*---------------------------------------------------------------------------*/
45 
46 class solutionControl
47 :
48  public IOobject
49 {
50 public:
51 
52  struct fieldData
53  {
55  scalar absTol;
56  scalar relTol;
57  scalar initialResidual;
58  };
59 
60 
61 protected:
62 
63  // Protected data
64 
65  //- Reference to the mesh database
66  fvMesh& mesh_;
67 
68  //- List of residual data per field
70 
71  //- The dictionary name, e.g. SIMPLE, PIMPLE
72  const word algorithmName_;
73 
74 
75  // Solution controls
76 
77  //- Maximum number of non-orthogonal correctors
79 
80  //- Flag to indicate to solve for momentum
81  bool momentumPredictor_;
82 
83  //- Flag to indicate to solve using transonic algorithm
84  bool transonic_;
85 
86  //- Flag to indicate to relax pressure using the
87  // "consistent" approach of SIMPLEC
88  bool consistent_;
89 
90 
91  // Evolution
92 
93  //- Current corrector loop index
94  label corr_;
95 
96  //- Current non-orthogonal corrector loop index
98 
99 
100  // Protected Member Functions
101 
102  //- Read controls from fvSolution dictionary
103  virtual void read(const bool absTolOnly);
104 
105  //- Read controls from fvSolution dictionary
106  virtual void read();
107 
108  //- Return index of field in residualControl_ if present
109  virtual label applyToField
110  (
111  const word& fieldName,
112  const bool useRegEx = true
113  ) const;
114 
115  //- Return true if all convergence checks are satisfied
116  virtual bool criteriaSatisfied() = 0;
117 
118  //- Store previous iteration fields
119  virtual void storePrevIterFields() const;
120 
121  //- Store previous iteration field for vol<Type>Fields
122  template<class Type>
123  void storePrevIter() const;
124 
125  template<class Type>
126  void maxTypeResidual
127  (
128  const word& fieldName,
129  ITstream& data,
130  scalar& firstRes,
131  scalar& lastRes
132  ) const;
133 
134  scalar maxResidual
135  (
136  const word& fieldName,
137  ITstream& data,
138  scalar& lastRes
139  ) const;
140 
141 
142 private:
143 
144  //- Disallow default bitwise copy construct
146 
147  //- Disallow default bitwise assignment
148  void operator=(const solutionControl&);
149 
150 
151 public:
152 
153 
154  // Static Data Members
155 
156  //- Run-time type information
157  TypeName("solutionControl");
158 
159 
160  // Constructors
161 
162  //- Construct from mesh
163  solutionControl(fvMesh& mesh, const word& algorithmName);
164 
165 
166  //- Destructor
167  virtual ~solutionControl();
168 
169 
170  // Member Functions
171 
172  // Access
173 
174  //- Return the solution dictionary
175  inline const dictionary& dict() const;
176 
177  //- Current corrector loop index
178  inline label corr() const;
179 
180  //- Current non-orthogonal corrector index
181  inline label corrNonOrtho() const;
182 
183 
184  // Solution control
185 
186  //- Maximum number of non-orthogonal correctors
187  inline label nNonOrthCorr() const;
188 
189  //- Helper function to identify final non-orthogonal iteration
190  inline bool finalNonOrthogonalIter() const;
191 
192  //- Flag to indicate to solve for momentum
193  inline bool momentumPredictor() const;
194 
195  //- Flag to indicate to solve using transonic algorithm
196  inline bool transonic() const;
197 
198  //- Flag to indicate to relax pressure using the
199  // "consistent" approach of SIMPLEC
200  inline bool consistent() const;
201 
202 
203  // Evolution
204 
205  //- Main control loop
206  virtual bool loop() = 0;
207 
208  //- Non-orthogonal corrector loop
209  inline bool correctNonOrthogonal();
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #ifdef NoRepository
220  #include "solutionControlTemplates.C"
221 #endif
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #include "solutionControlI.H"
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool consistent() const
Flag to indicate to relax pressure using the.
fvMesh & mesh_
Reference to the mesh database.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
List< fieldData > residualControl_
List of residual data per field.
virtual bool loop()=0
Main control loop.
Base class for solution control classes.
virtual label applyToField(const word &fieldName, const bool useRegEx=true) const
Return index of field in residualControl_ if present.
label nNonOrthCorr_
Maximum number of non-orthogonal correctors.
void storePrevIter() const
Store previous iteration field for vol<Type>Fields.
void maxTypeResidual(const word &fieldName, ITstream &data, scalar &firstRes, scalar &lastRes) const
dynamicFvMesh & mesh
const dictionary & dict() const
Return the solution dictionary.
bool correctNonOrthogonal()
Non-orthogonal corrector loop.
A class for handling words, derived from string.
Definition: word.H:59
scalar maxResidual(const word &fieldName, ITstream &data, scalar &lastRes) const
bool transonic_
Flag to indicate to solve using transonic algorithm.
const word algorithmName_
The dictionary name, e.g. SIMPLE, PIMPLE.
bool momentumPredictor() const
Flag to indicate to solve for momentum.
virtual bool criteriaSatisfied()=0
Return true if all convergence checks are satisfied.
virtual void read()
Read controls from fvSolution dictionary.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
bool finalNonOrthogonalIter() const
Helper function to identify final non-orthogonal iteration.
label nNonOrthCorr() const
Maximum number of non-orthogonal correctors.
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
label corr_
Current corrector loop index.
virtual void storePrevIterFields() const
Store previous iteration fields.
label corr() const
Current corrector loop index.
virtual ~solutionControl()
Destructor.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label corrNonOrtho_
Current non-orthogonal corrector loop index.
bool momentumPredictor_
Flag to indicate to solve for momentum.
TypeName("solutionControl")
Run-time type information.
bool transonic() const
Flag to indicate to solve using transonic algorithm.
label corrNonOrtho() const
Current non-orthogonal corrector index.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
bool consistent_
Flag to indicate to relax pressure using the.
Input token stream.
Definition: ITstream.H:49
Namespace for OpenFOAM.