VoFSolver.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::VoFSolver
26 
27 Description
28  Base solver module base-class for the solution of immiscible fluids using
29  a VOF (volume of fluid) phase-fraction based interface capturing approach,
30  with optional mesh motion and mesh topology changes including adaptive
31  re-meshing.
32 
33  The momentum and other fluid properties are of the "mixture" and a single
34  momentum equation is solved.
35 
36  Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and
37  pseudo-transient and steady simulations.
38 
39  Optional fvModels and fvConstraints are provided to enhance the simulation
40  in many ways including adding various sources, Lagrangian
41  particles, surface film etc. and constraining or limiting the solution.
42 
43 SourceFiles
44  VoFSolver.C
45 
46 See also
47  Foam::solvers::fluidSolver
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef VoFSolver_H
52 #define VoFSolver_H
53 
54 #include "fluidSolver.H"
55 #include "VoFMixture.H"
56 #include "buoyancy.H"
57 #include "pressureReference.H"
58 #include "IOMRFZoneList.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 namespace solvers
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class VoFSolver Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 class VoFSolver
72 :
73  public fluidSolver
74 {
75 
76 protected:
77 
78  // Phase properties
79 
80  //- The compressible two-phase mixture
82 
84 
85  //- Name of the alpha convection scheme
86  const word divAlphaName;
87 
88  //- Phase-fraction flux Courant number
89  scalar alphaCoNum;
90 
91 
92  // Kinematic properties
93 
94  //- Velocity field
96 
97  //- Volumetric flux field
99 
100 
101  // Thermophysical properties
102 
103  //- Buoyancy force
105 
106  //- Reference to the buoyant pressure for buoyant cases
107  // otherwise to the pressure
109 
110  //- Reference to the mixture continuity density field
111  const volScalarField& rho;
112 
113 
114  // Kinematic properties
115 
116  //- Mass flux field
118 
119 
120  // Optional models
121 
122  //- MRF zone list
124 
125 
126  // Cached temporary fields
127 
128  //- Inverse momentum equation diagonal
129  // Used to correct phi following mesh changes
131 
132  //- Pointer to the surface momentum field
133  // used to recreate the flux after mesh-change
135 
136  //- Pointer to the momentum divergence field
137  // used in correctPhi to ensure the corrected phi has the
138  // same divergence
140 
141  //- Optional LTS reciprocal time-step field
143 
144  //- Cached momentum matrix
145  // shared between the momentum predictor and pressure corrector
147 
148 
149 
150 private:
151 
152  // Private Member Functions
153 
154  //- Set rDeltaT for LTS
155  void setRDeltaT();
156 
157 
158 protected:
159 
160  // Protected Member Functions
161 
162  //- Set or update the cached rAU
163  void setrAU(const fvVectorMatrix& UEqn);
164 
165  //- Clear the cached rAU is no longer needed
166  void clearrAU();
167 
168  //- Correct the cached Courant numbers
169  virtual void correctCoNum() = 0;
170 
171  //- Adjust the rDeltaT in the vicinity of the interface
172  virtual void setInterfaceRDeltaT(volScalarField& rDeltaT) = 0;
173 
174  //- Calculate and print the continuity errors
175  void continuityErrors();
176 
177  //- Return the pressure reference
178  virtual const Foam::pressureReference& pressureReference() const = 0;
179 
180  //- Is the flow incompressible?
181  virtual bool incompressible() const = 0;
182 
183  //- Is the flow divergent?
184  // i.e. compressible or include phase-fraction sources
185  virtual bool divergent() const = 0;
186 
187  //- Return the mixture compressibility/density
188  // Used by CorrectPhi for compressible mixtures following mesh change
189  virtual tmp<volScalarField> psiByRho() const = 0;
190 
191  //- Return the momentum equation stress term
193 
194  //- Correct the interface properties following mesh-change
195  // and phase-fraction update
196  virtual void correctInterface() = 0;
197 
198  //- Return the interface surface tension force for the momentum equation
199  virtual tmp<surfaceScalarField> surfaceTensionForce() const = 0;
200 
201 
202 public:
203 
204  // Public Data
205 
206  //- Reference to the VoF mixture
207  const VoFMixture& mixture;
208 
209  //- Reference to the velocity field
210  const volVectorField& U;
211 
212  //- Reference to the mass-flux field
213  const surfaceScalarField& phi;
214 
215 
216  //- Runtime type information
217  TypeName("VoFSolver");
218 
219 
220  // Constructors
221 
222  //- Construct from region mesh
224 
225  //- Disallow default bitwise copy construction
226  VoFSolver(const VoFSolver&) = delete;
227 
228 
229  //- Destructor
230  virtual ~VoFSolver();
231 
232 
233  // Member Functions
234 
235  //- Return the current maximum time-step for stable solution
236  virtual scalar maxDeltaT() const;
237 
238  //- Called at the start of the time-step, before the PIMPLE loop
239  virtual void preSolve();
240 
241  //- Called at the start of the PIMPLE loop to move the mesh
242  virtual void moveMesh();
243 
244  //- Corrections that follow mesh motion
245  virtual void motionCorrector();
246 
247  //- Called at the start of the PIMPLE loop
248  virtual void prePredictor() = 0;
249 
250  //- Construct and optionally solve the momentum equation
251  virtual void momentumPredictor();
252 
253  //- Construct and solve the energy equation,
254  // convert to temperature
255  // and update thermophysical and transport properties
256  virtual void thermophysicalPredictor() = 0;
257 
258  //- Construct and solve the pressure equation in the PISO loop
259  virtual void pressureCorrector() = 0;
260 
261  //- Called after the PIMPLE loop at the end of the time-step
262  virtual void postSolve();
263 
264 
265  // Member Operators
266 
267  //- Disallow default bitwise assignment
268  void operator=(const VoFSolver&) = delete;
269 };
270 
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 } // End namespace solvers
275 } // End namespace Foam
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #endif
280 
281 // ************************************************************************* //
Generic GeometricField class.
List of MRF zones with IO functionality. MRF zones are specified by a list of dictionary entries,...
Definition: IOMRFZoneList.H:68
Two-phase VoF mixture.
Definition: VoFMixture.H:52
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Provides controls for the pressure reference in closed-volume simulations.
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
Base solver module base-class for the solution of immiscible fluids using a VOF (volume of fluid) pha...
Definition: VoFSolver.H:73
const word divAlphaName
Name of the alpha convection scheme.
Definition: VoFSolver.H:85
volScalarField & p_rgh
Reference to the buoyant pressure for buoyant cases.
Definition: VoFSolver.H:107
const surfaceScalarField & phi
Reference to the mass-flux field.
Definition: VoFSolver.H:212
surfaceScalarField rhoPhi
Mass flux field.
Definition: VoFSolver.H:116
volVectorField U_
Velocity field.
Definition: VoFSolver.H:94
virtual void thermophysicalPredictor()=0
Construct and solve the energy equation,.
tmp< fvVectorMatrix > tUEqn
Cached momentum matrix.
Definition: VoFSolver.H:145
virtual void postSolve()
Called after the PIMPLE loop at the end of the time-step.
Definition: VoFSolver.C:254
autoPtr< VoFMixture > mixturePtr_
The compressible two-phase mixture.
Definition: VoFSolver.H:80
solvers::buoyancy buoyancy
Buoyancy force.
Definition: VoFSolver.H:103
const VoFMixture & mixture
Reference to the VoF mixture.
Definition: VoFSolver.H:206
autoPtr< surfaceVectorField > Uf
Pointer to the surface momentum field.
Definition: VoFSolver.H:133
tmp< volScalarField > trDeltaT
Optional LTS reciprocal time-step field.
Definition: VoFSolver.H:141
virtual void moveMesh()
Called at the start of the PIMPLE loop to move the mesh.
Definition: moveMesh.C:33
virtual scalar maxDeltaT() const
Return the current maximum time-step for stable solution.
Definition: VoFSolver.C:182
void operator=(const VoFSolver &)=delete
Disallow default bitwise assignment.
VoFSolver(fvMesh &mesh, autoPtr< VoFMixture >)
Construct from region mesh.
Definition: VoFSolver.C:84
autoPtr< volScalarField > rAU
Inverse momentum equation diagonal.
Definition: VoFSolver.H:129
autoPtr< volScalarField > divU
Pointer to the momentum divergence field.
Definition: VoFSolver.H:138
const volVectorField & U
Reference to the velocity field.
Definition: VoFSolver.H:209
virtual const Foam::pressureReference & pressureReference() const =0
Return the pressure reference.
virtual void setInterfaceRDeltaT(volScalarField &rDeltaT)=0
Adjust the rDeltaT in the vicinity of the interface.
virtual bool divergent() const =0
Is the flow divergent?
virtual void motionCorrector()
Corrections that follow mesh motion.
Definition: moveMesh.C:58
void clearrAU()
Clear the cached rAU is no longer needed.
Definition: VoFSolver.C:66
virtual void pressureCorrector()=0
Construct and solve the pressure equation in the PISO loop.
virtual tmp< surfaceScalarField > surfaceTensionForce() const =0
Return the interface surface tension force for the momentum equation.
IOMRFZoneList MRF
MRF zone list.
Definition: VoFSolver.H:122
virtual bool incompressible() const =0
Is the flow incompressible?
virtual void momentumPredictor()
Construct and optionally solve the momentum equation.
VoFMixture & mixture_
Definition: VoFSolver.H:82
surfaceScalarField phi_
Volumetric flux field.
Definition: VoFSolver.H:97
virtual tmp< volScalarField > psiByRho() const =0
Return the mixture compressibility/density.
virtual ~VoFSolver()
Destructor.
Definition: VoFSolver.C:176
virtual tmp< fvVectorMatrix > divDevTau(volVectorField &U)=0
Return the momentum equation stress term.
TypeName("VoFSolver")
Runtime type information.
const volScalarField & rho
Reference to the mixture continuity density field.
Definition: VoFSolver.H:110
virtual void prePredictor()=0
Called at the start of the PIMPLE loop.
Definition: VoFSolver.C:250
void continuityErrors()
Calculate and print the continuity errors.
Definition: VoFSolver.C:45
scalar alphaCoNum
Phase-fraction flux Courant number.
Definition: VoFSolver.H:88
virtual void preSolve()
Called at the start of the time-step, before the PIMPLE loop.
Definition: VoFSolver.C:198
virtual void correctCoNum()=0
Correct the cached Courant numbers.
Definition: VoFSolver.C:75
virtual void correctInterface()=0
Correct the interface properties following mesh-change.
void setrAU(const fvVectorMatrix &UEqn)
Set or update the cached rAU.
Definition: VoFSolver.C:53
Buoyancy related data for the Foam::solvers::isothermalFluid solver module when solving buoyant cases...
Definition: buoyancy.H:70
Base solver module for fluid solvers.
Definition: fluidSolver.H:62
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
fvVectorMatrix & UEqn
Definition: UEqn.H:11
Namespace for OpenFOAM.