All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  //- Return true if the solver's dependencies have been modified
96  virtual bool dependenciesModified() const;
97 
98  //- Read controls
99  virtual bool read();
100 
101  //- Switch to correct the flux after mesh change
102  bool correctPhi;
103 
104  //- Current maximum Courant number for time-step control
105  scalar CoNum_;
106 
107  //- Check mesh Courant numbers for moving mesh cases
108  void meshCourantNo() const;
109 
110  //- Correct the cached Courant numbers
111  void correctCoNum(const surfaceScalarField& phi);
112 
113  //- Correct the cached Courant numbers
114  void correctCoNum
115  (
116  const volScalarField& rho,
117  const surfaceScalarField& phi
118  );
119 
120  //- Calculate and print the continuity errors
121  void continuityErrors
122  (
123  const surfaceScalarField& phi
124  );
125 
126  //- Calculate and print the continuity errors
127  void continuityErrors
128  (
129  const volScalarField& rho,
130  const volScalarField& thermoRho,
131  const surfaceScalarField& phi
132  );
133 
134 
135 public:
136 
137  // Public Data
138 
139  //- Current maximum Courant number for time-step control
140  const scalar& CoNum;
141 
142 
143 public:
144 
145  //- Runtime type information
146  TypeName("fluidSolver");
147 
148 
149  // Constructors
150 
151  //- Construct from region mesh
153 
154  //- Disallow default bitwise copy construction
155  fluidSolver(const fluidSolver&) = delete;
156 
157 
158  //- Destructor
159  virtual ~fluidSolver();
160 
161 
162  // Member Functions
163 
164  //- Return the current maximum time-step for stable solution
165  virtual scalar maxDeltaT() const;
166 
167 
168  // Member Operators
169 
170  //- Disallow default bitwise assignment
171  void operator=(const fluidSolver&) = delete;
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace solvers
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
Generic GeometricField class.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
Base solver module for fluid solvers.
Definition: fluidSolver.H:62
fluidSolver(fvMesh &mesh)
Construct from region mesh.
Definition: fluidSolver.C:207
bool correctPhi
Switch to correct the flux after mesh change.
Definition: fluidSolver.H:101
void continuityErrors(const surfaceScalarField &phi)
Calculate and print the continuity errors.
Definition: fluidSolver.C:146
virtual bool dependenciesModified() const
Return true if the solver's dependencies have been modified.
Definition: fluidSolver.C:45
virtual scalar maxDeltaT() const
Return the current maximum time-step for stable solution.
Definition: fluidSolver.C:229
void meshCourantNo() const
Check mesh Courant numbers for moving mesh cases.
Definition: fluidSolver.C:78
virtual ~fluidSolver()
Destructor.
Definition: fluidSolver.C:223
const scalar & CoNum
Current maximum Courant number for time-step control.
Definition: fluidSolver.H:139
scalar CoNum_
Current maximum Courant number for time-step control.
Definition: fluidSolver.H:104
void operator=(const fluidSolver &)=delete
Disallow default bitwise assignment.
virtual bool read()
Read controls.
Definition: fluidSolver.C:51
TypeName("fluidSolver")
Runtime type information.
Namespace for OpenFOAM.