correctorConvergenceControl.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018-2026 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::correctorConvergenceControl
26 
27 Description
28  Corrector convergence control class. Provides methods to check the
29  convergence of an inner iteration loop (e.g., pimple) against both absolute
30  and relative residual tolerances.
31 
32 SourceFiles
33  correctorConvergenceControl.C
34  correctorConvergenceControlTemplates.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef correctorConvergenceControl_H
39 #define correctorConvergenceControl_H
40 
41 #include "fvMesh.H"
42 #include "solutionControl.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class correctorConvergenceControl Declaration
51 \*---------------------------------------------------------------------------*/
52 
54 {
55 public:
56 
57  //- Residual correction data structure
58  struct corrResidualData
59  {
61  scalar absTol;
62  scalar relTol;
63  };
64 
65 
66 protected:
67 
68  // Protected data
69 
70  //- Reference to the solution control
72 
73  //- Name of the corrector loop
74  const word loopName_;
75 
76 
77  // Protected Member Functions
78 
79  //- Get the number of solves that have happened for this variable in
80  // this time-step
81  static void getNSolves
82  (
83  const fvMesh& mesh,
84  const word& fieldName,
85  label& n
86  );
87 
88 
89  // Protected Static Template Functions
90 
91  //- Get the number of solves that have happened for this variable in
92  // this time-step
93  template<class Type>
94  static void getNTypeSolves
95  (
96  const fvMesh& mesh,
97  const word& fieldName,
98  label& n
99  );
100 
101 
102 public:
103 
104  // Static Data Members
105 
106  //- Run-time type information
107  TypeName("correctorConvergenceControl");
108 
109 
110  // Constructors
111 
112  //- Construct from a solution control and the loop name
114  (
115  const solutionControl& control,
116  const word& loopName
117  );
118 
119 
120  //- Destructor
122 
123 
124  // Member Functions
125 
126  // Evolution
127 
128  //- Return true if corrector residual controls are present
129  virtual bool hasCorrResidualControls() const = 0;
130 
131  //- Return true if all correction convergence checks are satisfied
132  virtual bool corrCriteriaSatisfied() const = 0;
133 
134  //- Reset the solve index in the correction residual control data
135  virtual void resetCorrSolveIndex() = 0;
136 
137  //- Update the solve index in the correction residual control data
138  virtual void updateCorrSolveIndex() = 0;
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #ifdef NoRepository
150 #endif
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
label n
Corrector convergence control class. Provides methods to check the convergence of an inner iteration ...
virtual bool hasCorrResidualControls() const =0
Return true if corrector residual controls are present.
correctorConvergenceControl(const solutionControl &control, const word &loopName)
Construct from a solution control and the loop name.
const solutionControl & control_
Reference to the solution control.
static void getNSolves(const fvMesh &mesh, const word &fieldName, label &n)
Get the number of solves that have happened for this variable in.
TypeName("correctorConvergenceControl")
Run-time type information.
virtual void updateCorrSolveIndex()=0
Update the solve index in the correction residual control data.
static void getNTypeSolves(const fvMesh &mesh, const word &fieldName, label &n)
Get the number of solves that have happened for this variable in.
virtual bool corrCriteriaSatisfied() const =0
Return true if all correction convergence checks are satisfied.
const word loopName_
Name of the corrector loop.
virtual void resetCorrSolveIndex()=0
Reset the solve index in the correction residual control data.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Solution control class.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:77
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
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