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 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class solver Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class solver
54 :
55  public regIOobject
56 {
57 protected:
58 
59  // Protected Data
60 
61  //- Region mesh
62  fvMesh& mesh_;
63 
64  //- Switch for steady-state
65  // Set automatically from the selected ddt scheme
66  bool steady;
67 
68  //- Switch for local time step transient operation
69  // Set automatically from the selected ddt scheme
70  bool LTS;
71 
72 
73 private:
74 
75  // Private Member Data
76 
77  //- Pointer to the demand driven fvModels MeshObject
78  mutable Foam::fvModels* fvModelsPtr;
79 
80  //- Pointer to the demand driven fvConstraints MeshObject
81  mutable Foam::fvConstraints* fvConstraintsPtr;
82 
83 
84  // Private Member Functions
85 
86  //- Dummy write for regIOobject
87  virtual bool writeData(Ostream&) const;
88 
89 
90 public:
91 
92  // Public Data
93 
94  //- Region mesh
95  const fvMesh& mesh;
96 
97  //- Time
98  const Time& runTime;
99 
100  //- PIMPLE inner-loop controls
102 
103  //- deltaT increase factor
104  static scalar deltaTFactor;
105 
106 
107  //- Runtime type information
108  TypeName("solver");
109 
110 
111  // Declare run-time constructor selection table
112 
114  (
115  autoPtr,
116  solver,
117  fvMesh,
118  (fvMesh& mesh),
119  (mesh)
120  );
121 
122 
123  // Constructors
124 
125  //- Construct from region mesh
126  solver(fvMesh& mesh);
127 
128  //- Disallow default bitwise copy construction
129  solver(const solver&) = delete;
130 
131 
132  // Selectors
133 
134  //- Select, construct and return the solver
135  static autoPtr<solver> New
136  (
137  const word& solverName,
138  fvMesh& mesh
139  );
140 
141  //- Load the specified solver library
142  static void load(const word& solverName);
143 
144 
145  //- Destructor
146  virtual ~solver();
147 
148 
149  // Member Functions
150 
151  bool transient() const
152  {
153  return !steady && !LTS;
154  }
155 
156  //- Return the fvModels that are created on demand
157  Foam::fvModels& fvModels() const;
158 
159  //- Return the fvConstraints that are created on demand
161 
162  //- Return the current maximum time-step for stable solution
163  virtual scalar maxDeltaT() const = 0;
164 
165  //- Called at the start of the time-step, before the PIMPLE loop
166  virtual void preSolve() = 0;
167 
168  //- Called at the start of the PIMPLE loop to move the mesh
169  virtual void moveMesh() = 0;
170 
171  //- Called at the start of the PIMPLE loop
172  virtual void prePredictor() = 0;
173 
174  //- Construct and optionally solve the momentum equation
175  virtual void momentumPredictor() = 0;
176 
177  //- Construct and solve the thermophysical property equations,
178  // convert to temperature
179  // and update thermophysical and transport properties
180  virtual void thermophysicalPredictor() = 0;
181 
182  //- Construct and solve the pressure equation in the PISO loop
183  virtual void pressureCorrector() = 0;
184 
185  //- Correct the momentum and thermophysical transport modelling
186  virtual void postCorrector() = 0;
187 
188  //- Called after the PIMPLE loop at the end of the time-step
189  virtual void postSolve() = 0;
190 
191 
192  // Member Operators
193 
194  //- Disallow default bitwise assignment
195  void operator=(const solver&) = delete;
196 };
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
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:62
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
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:55
static scalar deltaTFactor
deltaT increase factor
Definition: solver.H:103
virtual void preSolve()=0
Called at the start of the time-step, before the PIMPLE loop.
virtual ~solver()
Destructor.
Definition: solver.C:79
bool steady
Switch for steady-state.
Definition: solver.H:65
virtual void thermophysicalPredictor()=0
Construct and solve the thermophysical property equations,.
bool LTS
Switch for local time step transient operation.
Definition: solver.H:69
Foam::fvModels & fvModels() const
Return the fvModels that are created on demand.
Definition: solver.C:85
pimpleNoLoopControl pimple
PIMPLE inner-loop controls.
Definition: solver.H:100
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:52
Foam::fvConstraints & fvConstraints() const
Return the fvConstraints that are created on demand.
Definition: solver.C:96
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:97
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:61
virtual void postSolve()=0
Called after the PIMPLE loop at the end of the time-step.
const fvMesh & mesh
Region mesh.
Definition: solver.H:94
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.