multiphaseEuler.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-2025 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 "multiphaseEuler.H"
27 #include "localEulerDdtScheme.H"
28 #include "surfaceFields.H"
29 #include "fvcDiv.H"
30 #include "fvcSurfaceIntegrate.H"
31 #include "fvcMeshPhi.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace solvers
39 {
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
49 {
51 
53  pimple.dict().lookupOrDefault<bool>("momentumPredictor", false);
54 
55  faceMomentum =
56  pimple.dict().lookupOrDefault<Switch>("faceMomentum", false);
57 
59  pimple.dict().lookupOrDefault<Switch>("dragCorrection", false);
60 
62  pimple.dict().lookupOrDefault<int>("nEnergyCorrectors", 1);
63 
65 
66  return true;
67 }
68 
69 
70 void Foam::solvers::multiphaseEuler::correctCoNum()
71 {
72  scalarField sumPhi
73  (
74  fvc::surfaceSum(mag(phi))().primitiveField()
75  );
76 
77  forAll(movingPhases, movingPhasei)
78  {
79  sumPhi = max
80  (
81  sumPhi,
82  fvc::surfaceSum(mag(movingPhases[movingPhasei].phi()))()
83  .primitiveField()
84  );
85  }
86 
87  CoNum_ = 0.5*gMax(sumPhi/mesh.V().primitiveField())*runTime.deltaTValue();
88 
89  const scalar meanCoNum =
90  0.5
91  *(gSum(sumPhi)/gSum(mesh.V().primitiveField()))
92  *runTime.deltaTValue();
93 
94  Info<< "Courant Number mean: " << meanCoNum
95  << " max: " << CoNum << endl;
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
100 
102 :
104 
105  predictMomentum
106  (
107  pimple.dict().lookupOrDefault<Switch>("momentumPredictor", false)
108  ),
109 
110  faceMomentum
111  (
112  pimple.dict().lookupOrDefault<Switch>("faceMomentum", false)
113  ),
114 
115  dragCorrection
116  (
117  pimple.dict().lookupOrDefault<Switch>("dragCorrection", false)
118  ),
119 
120  nEnergyCorrectors
121  (
122  pimple.dict().lookupOrDefault<int>("nEnergyCorrectors", 1)
123  ),
124 
125  trDeltaT
126  (
127  LTS
128  ? new volScalarField
129  (
130  IOobject
131  (
132  fv::localEulerDdt::rDeltaTName,
133  runTime.name(),
134  mesh,
135  IOobject::READ_IF_PRESENT,
136  IOobject::AUTO_WRITE
137  ),
138  mesh,
140  extrapolatedCalculatedFvPatchScalarField::typeName
141  )
142  : nullptr
143  ),
144 
145  buoyancy(mesh),
146 
147  fluid_(mesh),
148 
149  phases_(fluid_.phases()),
150 
151  movingPhases_(fluid_.movingPhases()),
152 
153  phi_(fluid_.phi()),
154 
155  momentumTransferSystem_(fluid_),
156 
157  heatTransferSystem_(fluid_),
158 
159  populationBalanceSystem_(fluid_),
160 
161  p_(movingPhases_[0].fluidThermo().p()),
162 
163  p_rgh_(buoyancy.p_rgh),
164 
166  (
167  p_,
168  p_rgh_,
169  pimple.dict(),
170  fluid_.incompressible()
171  ),
172 
173  MRF(fluid_.MRF()),
174 
175  fluid(fluid_),
176  phases(phases_),
177  movingPhases(movingPhases_),
178  momentumTransfer(momentumTransferSystem_),
179  heatTransfer(heatTransferSystem_),
180  p(p_),
181  p_rgh(p_rgh_),
182  phi(phi_)
183 {
184  // Read the controls
185  read();
186 
188 
189  if (transient())
190  {
191  correctCoNum();
192  }
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
197 
199 {}
200 
201 
202 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
203 
205 {
206  if (transient())
207  {
208  correctCoNum();
209  }
210  else if (LTS)
211  {
212  setRDeltaT();
213  }
214 
215  // Store divU from the previous mesh so that it can be
216  // mapped and used in correctPhi to ensure the corrected phi
217  // has the same divergence
218  if (correctPhi || mesh.topoChanging())
219  {
220  // Construct and register divU for mapping
221  divU = new volScalarField
222  (
223  "divU0",
224  fvc::div(fvc::absolute(phi, movingPhases[0].U()))
225  );
226  }
227 
229 
230  // Update the mesh for topology change, mesh to mesh mapping
231  mesh_.update();
232 }
233 
234 
236 {
237  if (pimple.thermophysics() || pimple.flow())
238  {
239  alphaControls.correct(CoNum);
240 
241  fluid_.solve(alphaControls, rAs, momentumTransferSystem_);
242  populationBalanceSystem_.solve();
243 
244  fluid_.correct();
245  populationBalanceSystem_.correct();
246 
247  fluid_.correctContinuityError(populationBalanceSystem_.dmdts());
248  }
249 }
250 
251 
253 {
254  fluid_.predictMomentumTransport();
255 }
256 
257 
259 {
260  // Moved inside the nEnergyCorrectors loop in thermophysicalPredictor()
261  // fluid_.predictThermophysicalTransport();
262 }
263 
264 
266 {
267  fluid_.correctMomentumTransport();
268 }
269 
270 
272 {
273  fluid_.correctThermophysicalTransport();
274 }
275 
276 
278 {
279  divU.clear();
280 }
281 
282 
283 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
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
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
T lookupOrDefault(const word &, const T &) const
Find and return a T, if not found return the given default.
Base-class for fluid thermodynamic properties.
Definition: fluidThermo.H:56
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const DimensionedField< scalar, fvMesh > & V() const
Return cell volumes.
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1792
const fvSolution & solution() const
Return the fvSolution.
Definition: fvMesh.C:1803
bool topoChanging() const
Does the mesh topology change?
Definition: fvMesh.C:683
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModels.C:261
void setFluxRequired(const word &name) const
Definition: fvSchemes.C:434
static const dictionary & dict(const fvMesh &mesh, const word &algorithmName="PIMPLE")
Return the solution dictionary.
Provides controls for the pressure reference in closed-volume simulations.
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:238
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
pimpleNoLoopControl pimple
PIMPLE inner-loop controls.
Definition: solver.H:107
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
Base solver module for fluid solvers.
virtual bool read()
Read controls.
Buoyancy related data for the Foam::solvers::isothermalFluid solver module when solving buoyant cases...
Definition: buoyancy.H:70
Solver module for steady or transient turbulent flow of compressible fluids with heat-transfer for HV...
Definition: fluid.H:70
Solver module for a system of any number of compressible fluid phases with a common pressure,...
virtual void momentumTransportCorrector()
Correct the momentum transport.
virtual void prePredictor()
Called at the start of the PIMPLE loop.
const volScalarField & p_rgh
Reference to the buoyant pressure for buoyant cases.
virtual void postSolve()
Called after the PIMPLE loop at the end of the time-step.
virtual void momentumTransportPredictor()
Predict the momentum transport.
int nEnergyCorrectors
Number of energy correctors.
Switch predictMomentum
Momentum equation predictor switch.
virtual void thermophysicalTransportCorrector()
Correct the thermophysical transport.
Switch faceMomentum
Cell/face momentum equation switch.
Switch dragCorrection
Cell/face drag correction for cell momentum corrector.
virtual void preSolve()
Called at the start of the time-step, before the PIMPLE loop.
phaseSystem::alphaControl alphaControls
virtual ~multiphaseEuler()
Destructor.
virtual void thermophysicalTransportPredictor()
Predict thermophysical transport.
multiphaseEuler(fvMesh &mesh)
Construct from region mesh.
virtual bool read()
Read controls.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
scalar CoNum
scalar meanCoNum
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)
Calculate the divergence of the given field.
Calculate the mesh motion flux and convert fluxes from absolute to relative and back.
Surface integrate surfaceField creating a volField. Surface sum a surfaceField creating a volField.
U
Definition: pEqn.H:72
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< VolInternalField< Type > > surfaceSum(const SurfaceField< Type > &ssf)
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:202
addToRunTimeSelectionTable(solver, compressibleMultiphaseVoF, fvMesh)
defineTypeNameAndDebug(basicFluidSolver, 0)
Namespace for OpenFOAM.
const dimensionSet & dimless
Definition: dimensions.C:138
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
Type gSum(const UList< Type > &f, const label comm)
const dimensionSet & dimTime
Definition: dimensions.C:142
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
Type gMax(const UList< Type > &f, const label comm)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
correctPhi
labelList fv(nPoints)
dictionary dict
volScalarField & p
void read(const dictionary &dict)
Read the alpha and MULES controls from dict.
Definition: phaseSystem.C:421
Foam::surfaceFields.