incompressibleFluid.C
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-2026 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 \*---------------------------------------------------------------------------*/
25 
26 #include "incompressibleFluid.H"
27 #include "localEulerDdtScheme.H"
28 #include "linear.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace solvers
36 {
39 }
40 }
41 
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
46 {
47  basicFluidSolver::correctCoNum(phi);
48 }
49 
50 
52 {
54 }
55 
56 
57 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
58 
60 :
62 
63  p_
64  (
65  IOobject
66  (
67  "p",
68  runTime.name(),
69  mesh,
70  IOobject::MUST_READ,
71  IOobject::AUTO_WRITE
72  ),
73  mesh,
74  dimensions::kinematicPressure
75  ),
76 
78 
79  U_
80  (
81  IOobject
82  (
83  "U",
84  runTime.name(),
85  mesh,
86  IOobject::MUST_READ,
87  IOobject::AUTO_WRITE
88  ),
89  mesh,
90  dimensions::velocity
91  ),
92 
93  phi_
94  (
95  IOobject
96  (
97  "phi",
98  runTime.name(),
99  mesh,
100  IOobject::READ_IF_PRESENT,
101  IOobject::AUTO_WRITE
102  ),
103  linearInterpolate(U_) & mesh.Sf()
104  ),
105 
107 
108  momentumTransport
109  (
110  incompressible::momentumTransportModel::New
111  (
112  U_,
113  phi_,
114  viscosity
115  )
116  ),
117 
118  MRF(MRFZones::New(mesh)),
119 
120  p(p_),
121  U(U_),
122  phi(phi_)
123 {
125 
126  momentumTransport->validate();
127 
128  if (transient())
129  {
130  correctCoNum();
131  }
132  else if (LTS)
133  {
134  Info<< "Using LTS" << endl;
135 
137  (
138  new volScalarField
139  (
140  IOobject
141  (
143  runTime.name(),
144  mesh,
147  ),
148  mesh,
151  )
152  );
153  }
154 }
155 
156 
157 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
158 
160 {}
161 
162 
163 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
164 
166 {
167  if ((mesh.dynamic() || MRF.size()) && !Uf.valid())
168  {
169  Info<< "Constructing face momentum Uf" << endl;
170 
171  // Ensure the U BCs are up-to-date before constructing Uf
172  U_.correctBoundaryConditions();
173 
174  Uf = new surfaceVectorField
175  (
176  IOobject
177  (
178  "Uf",
179  runTime.name(),
180  mesh,
183  ),
185  );
186  }
187 
189 
190  if (transient())
191  {
192  correctCoNum();
193  }
194  else if (LTS)
195  {
196  setRDeltaT();
197  }
198 
199  // Update the mesh for topology change, mesh to mesh mapping
200  mesh_.update();
201 }
202 
203 
205 {}
206 
207 
209 {
210  momentumTransport->predict();
211 }
212 
213 
215 {}
216 
217 
219 {}
220 
221 
223 {
224  while (pimple.correct())
225  {
226  correctPressure();
227  }
228 
229  tUEqn.clear();
230 }
231 
232 
234 {
235  viscosity->correct();
236  momentumTransport->correct();
237 }
238 
239 
241 {}
242 
243 
245 {}
246 
247 
248 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const word & name() const
Return name.
Definition: IOobject.H:307
MRF zones DemandDrivenMeshObject read from MRFProperties dictionary.
Definition: MRFZones.H:76
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
const word & name() const
Return const reference to name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1795
bool dynamic() const
Is this mesh dynamic?
Definition: fvMesh.C:697
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModels.C:258
void setFluxRequired(const word &name) const
Definition: fvSchemes.C:434
static word rDeltaTName
Name of the reciprocal local time-step field.
Abstract base class for momentum transport models (RAS, LES and laminar).
Provides controls for the pressure reference in closed-volume simulations.
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
bool LTS
Switch for local time step transient operation.
Definition: solver.H:70
const Time & runTime
Time.
Definition: solver.H:104
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
Base solver module for fluid solvers.
void continuityErrors(const surfaceScalarField &phi)
Calculate and print the continuity errors.
Solver module for steady or transient turbulent flow of incompressible isothermal fluids with optiona...
virtual void thermophysicalPredictor()
Construct and solve the energy equation,.
const surfaceScalarField & phi
Reference to the volumetric-flux field.
virtual void momentumTransportCorrector()
Correct the momentum transport.
virtual void prePredictor()
Called at the start of the PIMPLE loop.
virtual void postSolve()
Called after the PIMPLE loop at the end of the time-step.
virtual void momentumTransportPredictor()
Predict the momentum transport.
tmp< volScalarField > trDeltaT
Optional LTS reciprocal time-step field.
autoPtr< incompressible::momentumTransportModel > momentumTransport
Pointer to the momentum transport model.
virtual void pressureCorrector()
Construct and solve the pressure equation in the PISO loop.
virtual void thermophysicalTransportCorrector()
Correct the thermophysical transport.
void continuityErrors()
Calculate and print the continuity errors.
void correctCoNum()
Correct the cached Courant numbers.
virtual void preSolve()
Called at the start of the time-step, before the PIMPLE loop.
const volScalarField & p
Reference to the pressure field.
virtual void thermophysicalTransportPredictor()
Predict thermophysical transport.
incompressibleFluid(fvMesh &mesh)
Construct from region mesh.
A class for managing temporary objects.
Definition: tmp.H:55
An abstract base class for Newtonian viscosity models.
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
tmp< fvVectorMatrix > tUEqn(fvm::div(phi, U)+MRF.DDt(rho, U)+turbulence->divDevTau(U)==fvModels.source(rho, U))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
const Foam::MRFZones & MRF(Foam::MRFZones::New(mesh))
pimpleControl pimple(mesh)
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
U
Definition: pEqn.H:72
const dimensionSet velocity
const dimensionSet dimless
const dimensionSet kinematicPressure
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
addToRunTimeSelectionTable(solver, compressibleMultiphaseVoF, fvMesh)
defineTypeNameAndDebug(basicFluidSolver, 0)
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
messageStream Info
tmp< SurfaceField< Type > > linearInterpolate(const VolField< Type > &vf)
Definition: linear.H:108
const dimensionSet & dimTime
Definition: dimensions.C:277
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
SurfaceField< vector > surfaceVectorField
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dictionary dict
volScalarField & p