solver.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) 2022-2025 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::solver
26 
27 Description
28  Abstract base class for run-time selectable region solvers.
29 
30 SourceFiles
31  solver.C
32  solverNew.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef solver_H
37 #define solver_H
38 
39 #include "fvMesh.H"
40 #include "pimpleNoLoopControl.H"
41 #include "fvModels.H"
42 #include "fvConstraints.H"
43 #include "regionName.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class solver Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class solver
55 :
56  public regIOobject
57 {
58 protected:
59 
60  // Protected Data
61 
62  //- Region mesh
63  fvMesh& mesh_;
64 
65  //- Switch for steady-state
66  // Set automatically from the selected ddt scheme
67  bool steady;
68 
69  //- Switch for local time step transient operation
70  // Set automatically from the selected ddt scheme
71  bool LTS;
72 
73 
74 private:
75 
76  // Private Member Data
77 
78  //- Pointer to the demand driven fvModels MeshObject
79  mutable Foam::fvModels* fvModelsPtr;
80 
81  //- Pointer to the demand driven fvConstraints MeshObject
82  mutable Foam::fvConstraints* fvConstraintsPtr;
83 
84 
85  // Private Member Functions
86 
87  //- Dummy write for regIOobject
88  virtual bool writeData(Ostream&) const;
89 
90 
91 protected:
92 
93  //- Read controls
94  virtual bool read();
95 
96 
97 public:
98 
99  // Public Data
100 
101  //- Region mesh
102  const fvMesh& mesh;
103 
104  //- Time
105  const Time& runTime;
106 
107  //- PIMPLE inner-loop controls
109 
110  //- deltaT increase factor
111  static scalar deltaTFactor;
112 
113 
114  //- Runtime type information
115  TypeName("solver");
116 
117 
118  // Declare run-time constructor selection table
119 
121  (
122  autoPtr,
123  solver,
124  fvMesh,
125  (fvMesh& mesh),
126  (mesh)
127  );
128 
129 
130  // Constructors
131 
132  //- Construct from region mesh
133  solver(fvMesh& mesh);
134 
135  //- Disallow default bitwise copy construction
136  solver(const solver&) = delete;
137 
138 
139  // Selectors
140 
141  //- Select, construct and return the solver
142  static autoPtr<solver> New
143  (
144  const word& solverName,
145  fvMesh& mesh
146  );
147 
148  //- Load the specified solver library
149  static void load(const word& solverName);
150 
151 
152  //- Destructor
153  virtual ~solver();
154 
155 
156  // Member Functions
157 
158  bool transient() const
159  {
160  return !steady && !LTS;
161  }
162 
163  //- Return the fvModels that are created on demand
164  Foam::fvModels& fvModels() const;
165 
166  //- Return the fvConstraints that are created on demand
168 
169  //- Return the current maximum time-step for stable solution
170  virtual scalar maxDeltaT() const = 0;
171 
172  //- Called at the start of the time-step, before the PIMPLE loop
173  virtual void preSolve() = 0;
174 
175  //- Called at the start of the PIMPLE loop to move the mesh
176  virtual void moveMesh() = 0;
177 
178  //- Corrections that follow mesh motion
179  virtual void motionCorrector() = 0;
180 
181  //- Called at the start of the PIMPLE loop
182  virtual void prePredictor() = 0;
183 
184  //- Predict the momentum transport
185  virtual void momentumTransportPredictor() = 0;
186 
187  //- Predict thermophysical transport
188  virtual void thermophysicalTransportPredictor() = 0;
189 
190  //- Construct and optionally solve the momentum equation
191  virtual void momentumPredictor() = 0;
192 
193  //- Construct and solve the thermophysical property equations,
194  // convert to temperature
195  // and update thermophysical and transport properties
196  virtual void thermophysicalPredictor() = 0;
197 
198  //- Construct and solve the pressure equation in the PISO loop
199  virtual void pressureCorrector() = 0;
200 
201  //- Correct the momentum transport
202  virtual void momentumTransportCorrector() = 0;
203 
204  //- Correct the thermophysical transport
205  virtual void thermophysicalTransportCorrector() = 0;
206 
207  //- Called after the PIMPLE loop at the end of the time-step
208  virtual void postSolve() = 0;
209 
210 
211  // Member Operators
212 
213  //- Disallow default bitwise assignment
214  void operator=(const solver&) = delete;
215 };
216 
217 
218 template<>
219 inline const word& regionName(const solver& region)
220 {
221  return regionName(region.mesh);
222 }
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #endif
232 
233 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Finite volume constraints.
Definition: fvConstraints.H:67
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Finite volume models.
Definition: fvModels.H:65
Pimple no-loop control class. Implements various option flags, but leaves loop controls to the deriva...
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
virtual void momentumTransportCorrector()=0
Correct the momentum transport.
virtual void motionCorrector()=0
Corrections that follow mesh motion.
static scalar deltaTFactor
deltaT increase factor
Definition: solver.H:110
virtual void preSolve()=0
Called at the start of the time-step, before the PIMPLE loop.
virtual ~solver()
Destructor.
Definition: solver.C:90
bool steady
Switch for steady-state.
Definition: solver.H:66
virtual void thermophysicalPredictor()=0
Construct and solve the thermophysical property equations,.
bool LTS
Switch for local time step transient operation.
Definition: solver.H:70
Foam::fvModels & fvModels() const
Return the fvModels that are created on demand.
Definition: solver.C:96
pimpleNoLoopControl pimple
PIMPLE inner-loop controls.
Definition: solver.H:107
static autoPtr< solver > New(const word &solverName, fvMesh &mesh)
Select, construct and return the solver.
Definition: solverNew.C:37
solver(fvMesh &mesh)
Construct from region mesh.
Definition: solver.C:60
Foam::fvConstraints & fvConstraints() const
Return the fvConstraints that are created on demand.
Definition: solver.C:107
virtual void thermophysicalTransportCorrector()=0
Correct the thermophysical transport.
virtual void pressureCorrector()=0
Construct and solve the pressure equation in the PISO loop.
virtual void moveMesh()=0
Called at the start of the PIMPLE loop to move the mesh.
virtual void momentumPredictor()=0
Construct and optionally solve the momentum equation.
virtual scalar maxDeltaT() const =0
Return the current maximum time-step for stable solution.
declareRunTimeSelectionTable(autoPtr, solver, fvMesh,(fvMesh &mesh),(mesh))
const Time & runTime
Time.
Definition: solver.H:104
void operator=(const solver &)=delete
Disallow default bitwise assignment.
TypeName("solver")
Runtime type information.
virtual void prePredictor()=0
Called at the start of the PIMPLE loop.
static void load(const word &solverName)
Load the specified solver library.
Definition: solverNew.C:30
fvMesh & mesh_
Region mesh.
Definition: solver.H:62
virtual void postSolve()=0
Called after the PIMPLE loop at the end of the time-step.
virtual void thermophysicalTransportPredictor()=0
Predict thermophysical transport.
virtual void momentumTransportPredictor()=0
Predict the momentum transport.
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
virtual bool read()
Read controls.
Definition: solver.C:52
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
const word & regionName(const solver &region)
Definition: solver.H:218