fluidSolver.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::solvers::fluidSolver
26 
27 Description
28  Base solver module for fluid solvers.
29 
30  Provides Courant number time-step control and continuity checking.
31 
32  Reference:
33  \verbatim
34  Greenshields, C. J., & Weller, H. G. (2022).
35  Notes on Computational Fluid Dynamics: General Principles.
36  CFD Direct Ltd.: Reading, UK.
37  \endverbatim
38 
39 SourceFiles
40  fluidSolver.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef fluidSolver_H
45 #define fluidSolver_H
46 
47 #include "solver.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace solvers
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class fluidSolver Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class fluidSolver
61 :
62  public solver
63 {
64  // Control parameters
65 
66  //- Maximum allowed Courant number
67  scalar maxCo;
68 
69  //- Maximum time-step
70  scalar maxDeltaT_;
71 
72  //- Switch to check the mesh Courant number after mesh change
73  bool checkMeshCourantNo;
74 
75 
76  // Continuity properties
77 
78  //- Current cumulative continuity error
79  scalar cumulativeContErr;
80 
81 
82  // Private Member Functions
83 
84  //- Correct the cached Courant numbers
85  template<class RhoType>
86  inline void correctCoNum
87  (
88  const RhoType& rho,
89  const surfaceScalarField& phi
90  );
91 
92 
93 protected:
94 
95  //- Switch to correct the flux after mesh change
96  bool correctPhi;
97 
98  //- Current maximum Courant number for time-step control
99  scalar CoNum;
100 
101  //- Read controls
102  void readControls();
103 
104  //- Check mesh Courant numbers for moving mesh cases
105  void meshCourantNo() const;
106 
107  //- Correct the cached Courant numbers
108  void correctCoNum(const surfaceScalarField& phi);
109 
110  //- Correct the cached Courant numbers
111  void correctCoNum
112  (
113  const volScalarField& rho,
114  const surfaceScalarField& phi
115  );
116 
117  //- Calculate and print the continuity errors
118  void continuityErrors
119  (
120  const surfaceScalarField& phi
121  );
122 
123  //- Calculate and print the continuity errors
124  void continuityErrors
125  (
126  const volScalarField& rho,
127  const volScalarField& thermoRho,
128  const surfaceScalarField& phi
129  );
130 
131 
132 public:
133 
134  //- Runtime type information
135  TypeName("fluidSolver");
136 
137 
138  // Constructors
139 
140  //- Construct from region mesh
142 
143  //- Disallow default bitwise copy construction
144  fluidSolver(const fluidSolver&) = delete;
145 
146 
147  //- Destructor
148  virtual ~fluidSolver();
149 
150 
151  // Member Functions
152 
153  //- Return the current maximum time-step for stable solution
154  virtual scalar maxDeltaT() const;
155 
156 
157  // Member Operators
158 
159  //- Disallow default bitwise assignment
160  void operator=(const fluidSolver&) = delete;
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace solvers
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
Generic GeometricField class.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
Abstract base class for run-time selectable region solvers.
Definition: solver.H:55
const fvMesh & mesh
Region mesh.
Definition: solver.H:94
Base solver module for fluid solvers.
Definition: fluidSolver.H:62
fluidSolver(fvMesh &mesh)
Construct from region mesh.
Definition: fluidSolver.C:192
bool correctPhi
Switch to correct the flux after mesh change.
Definition: fluidSolver.H:95
void continuityErrors(const surfaceScalarField &phi)
Calculate and print the continuity errors.
Definition: fluidSolver.C:131
virtual scalar maxDeltaT() const
Return the current maximum time-step for stable solution.
Definition: fluidSolver.C:211
void meshCourantNo() const
Check mesh Courant numbers for moving mesh cases.
Definition: fluidSolver.C:67
virtual ~fluidSolver()
Destructor.
Definition: fluidSolver.C:205
void operator=(const fluidSolver &)=delete
Disallow default bitwise assignment.
void readControls()
Read controls.
Definition: fluidSolver.C:45
scalar CoNum
Current maximum Courant number for time-step control.
Definition: fluidSolver.H:98
TypeName("fluidSolver")
Runtime type information.
Namespace for OpenFOAM.