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-2023 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  //- Construct and optionally solve the momentum equation
185  virtual void momentumPredictor() = 0;
186 
187  //- Construct and solve the thermophysical property equations,
188  // convert to temperature
189  // and update thermophysical and transport properties
190  virtual void thermophysicalPredictor() = 0;
191 
192  //- Construct and solve the pressure equation in the PISO loop
193  virtual void pressureCorrector() = 0;
194 
195  //- Correct the momentum and thermophysical transport modelling
196  virtual void postCorrector() = 0;
197 
198  //- Called after the PIMPLE loop at the end of the time-step
199  virtual void postSolve() = 0;
200 
201 
202  // Member Operators
203 
204  //- Disallow default bitwise assignment
205  void operator=(const solver&) = delete;
206 };
207 
208 
209 template<>
210 inline const word& regionName(const solver& region)
211 {
212  return regionName(region.mesh);
213 }
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace Foam
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 #endif
223 
224 // ************************************************************************* //
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:99
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 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
virtual void postCorrector()=0
Correct the momentum and thermophysical transport modelling.
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 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.
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:209