incompressibleDenseParticleFluid.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) 2023-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 
27 #include "surfaceInterpolate.H"
28 #include "fvMatrix.H"
29 #include "fvcFlux.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace solvers
38 {
41  (
42  solver,
44  fvMesh
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
53 {
54  basicFluidSolver::correctCoNum(phic);
55 }
56 
57 
59 {
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65 
68 (
69  fvMesh& mesh
70 )
71 :
73 
74  continuousPhaseName
75  (
77  (
78  IOobject
79  (
80  "physicalProperties",
81  runTime.constant(),
82  mesh,
83  IOobject::MUST_READ
84  )
85  ).lookup("continuousPhaseName")
86  ),
87 
88  p_
89  (
90  IOobject
91  (
92  "p",
93  runTime.name(),
94  mesh,
95  IOobject::MUST_READ,
96  IOobject::AUTO_WRITE
97  ),
98  mesh,
99  dimensions::kinematicPressure
100  ),
101 
103 
104  g
105  (
106  IOobject
107  (
108  "g",
109  runTime.constant(),
110  mesh,
111  IOobject::MUST_READ,
112  IOobject::NO_WRITE
113  ),
114  dimensions::acceleration
115  ),
116 
117  Uc_
118  (
119  IOobject
120  (
121  IOobject::groupName("U", continuousPhaseName),
122  runTime.name(),
123  mesh,
124  IOobject::MUST_READ,
125  IOobject::AUTO_WRITE
126  ),
127  mesh,
128  dimensions::velocity
129  ),
130 
131  phic_
132  (
133  IOobject
134  (
135  IOobject::groupName("phi", continuousPhaseName),
136  runTime.name(),
137  mesh,
138  IOobject::READ_IF_PRESENT,
139  IOobject::AUTO_WRITE
140  ),
141  linearInterpolate(Uc_) & mesh.Sf()
142  ),
143 
145 
146  rhoc
147  (
148  IOobject
149  (
150  IOobject::groupName("rho", continuousPhaseName),
151  runTime.name(),
152  mesh
153  ),
154  mesh,
156  (
157  IOobject::groupName("rho", continuousPhaseName),
158  dimDensity,
160  (
161  IOobject::groupName("rho", continuousPhaseName)
162  )
163  )
164  ),
165 
166  muc
167  (
168  IOobject
169  (
170  IOobject::groupName("mu", continuousPhaseName),
171  runTime.name(),
172  mesh
173  ),
174  rhoc*viscosity->nu()
175  ),
176 
177  alphac_
178  (
179  IOobject
180  (
181  IOobject::groupName("alpha", continuousPhaseName),
182  runTime.name(),
183  mesh,
184  IOobject::READ_IF_PRESENT,
185  IOobject::AUTO_WRITE
186  ),
187  mesh,
189  ),
190 
191  alphacMin
192  (
193  1 - mesh.solution().solverDict(alphac_.name()).lookup<scalar>("max")
194  ),
195 
196  alphacf("alphacf", fvc::interpolate(alphac_)),
197 
198  alphaPhic
199  (
200  IOobject::groupName("alphaPhi", continuousPhaseName),
201  alphacf*phic_
202  ),
203 
204  momentumTransport
205  (
206  phaseIncompressible::momentumTransportModel::New
207  (
208  alphac_,
209  Uc_,
210  alphaPhic,
211  phic_,
212  viscosity
213  )
214  ),
215 
216  clouds
217  (
218  parcelClouds::New(mesh, rhoc, Uc_, muc, g)
219  ),
220 
221  p(p_),
222  Uc(Uc_),
223  phic(phic_),
224  alphac(alphac_)
225 {
227 
228  momentumTransport->validate();
229 
230  // Update alphac from the particle locations
231  alphac_ = max(1 - clouds.alpha(), alphacMin);
235 
236  correctCoNum();
237 }
238 
239 
240 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
241 
244 {}
245 
246 
247 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
248 
250 {
251  if (mesh.dynamic() && !Ucf.valid())
252  {
253  Info<< "Constructing face momentum Ucf" << endl;
254 
255  // Ensure the U BCs are up-to-date before constructing Ucf
256  Uc_.correctBoundaryConditions();
257 
258  Ucf = new surfaceVectorField
259  (
260  IOobject
261  (
262  "Ucf",
263  runTime.name(),
264  mesh,
267  ),
268  fvc::interpolate(Uc)
269  );
270  }
271 
272  // Store the particle positions
273  if (mesh.topoChanging() || mesh.distributing())
274  {
275  clouds.storeGlobalPositions();
276  }
277 
279 
280  correctCoNum();
281 
282  // Update the mesh for topology change, mesh to mesh mapping
283  mesh_.update();
284 }
285 
286 
288 {
289  if (pimple.firstIter())
290  {
291  clouds.evolve();
292 
293  // Update continuous phase volume fraction field
294  alphac_ = max(1 - clouds.alpha(), alphacMin);
295  alphac_.correctBoundaryConditions();
296  alphacf = fvc::interpolate(alphac);
297 
298  // ... and continuous phase volumetric flux
299  alphaPhic = alphacf*phic;
300 
301  // Update the continuous phase dynamic viscosity
302  muc = rhoc*viscosity->nu();
303 
304  Fd = new volVectorField
305  (
306  IOobject
307  (
308  "Fd",
309  runTime.name(),
310  mesh
311  ),
312  mesh,
315  );
316 
317  Dc = new volScalarField
318  (
319  IOobject
320  (
321  "Dc",
322  runTime.name(),
323  mesh
324  ),
325  mesh,
328  );
329 
330  const fvVectorMatrix cloudSU(clouds.SU(Uc));
331 
332  Fd().primitiveFieldRef() = -cloudSU.source()/mesh.V()/rhoc;
333  Fd().correctBoundaryConditions();
334 
335  Dc().primitiveFieldRef() = -cloudSU.diag()/mesh.V()/rhoc;
336  Dc().correctBoundaryConditions();
337 
338  Dcf = fvc::interpolate(Dc()).ptr();
339 
340  phid =
341  (
342  fvc::flux(Fd())
343  /(Dcf() + dimensionedScalar(Dc().dimensions(), small))
344  ).ptr();
345  }
346 }
347 
348 
351 {
352  momentumTransport->predict();
353 }
354 
355 
358 {}
359 
360 
362 {}
363 
364 
366 {
367  while (pimple.correct())
368  {
369  correctPressure();
370  }
371 
372  tUcEqn.clear();
373 }
374 
375 
378 {
379  viscosity->correct();
380  momentumTransport->correct();
381 }
382 
383 
386 {}
387 
388 
390 {
391  Fd.clear();
392  Dc.clear();
393  Dcf.clear();
394  phid.clear();
395 }
396 
397 
398 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
void correctBoundaryConditions()
Correct boundary field.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
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 special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Field< Type > & source()
Definition: fvMatrix.H:307
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:1795
bool distributing() const
Does the mesh get redistributed?
Definition: fvMesh.C:691
bool dynamic() const
Is this mesh dynamic?
Definition: fvMesh.C:697
bool topoChanging() const
Does the mesh topology change?
Definition: fvMesh.C:685
virtual void preUpdateMesh()
Prepare for mesh update.
Definition: fvModels.C:258
void setFluxRequired(const word &name) const
Definition: fvSchemes.C:434
scalarField & diag()
Definition: lduMatrix.C:186
Abstract base class for momentum transport models (RAS, LES and laminar).
const tmp< volScalarField > alpha() const
Return the particle volume fraction field.
List of parcel clouds, with the same interface as an individual parcel cloud. Is a mesh object,...
Definition: parcelClouds.H:65
Provides controls for the pressure reference in closed-volume simulations.
Selector class for relaxation factors, solver type and solution.
Definition: solution.H:51
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.
void continuityErrors(const surfaceScalarField &phi)
Calculate and print the continuity errors.
Solver module for transient flow of incompressible isothermal fluids coupled with particle clouds inc...
virtual void thermophysicalPredictor()
Construct and solve the energy equation,.
autoPtr< phaseIncompressible::momentumTransportModel > momentumTransport
Pointer to the momentum transport model.
virtual void momentumTransportCorrector()
Correct the momentum transport.
surfaceScalarField alphacf
Interpolated continuous phase-fraction.
virtual void prePredictor()
Called at the start of the PIMPLE loop.
const volScalarField & alphac
Reference continuous phase-fraction.
virtual void postSolve()
Called after the PIMPLE loop at the end of the time-step.
virtual void momentumTransportPredictor()
Predict the momentum transport.
surfaceScalarField alphaPhic
Continuous phase volumetric-flux field.
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.
incompressibleDenseParticleFluid(fvMesh &mesh)
Construct from region mesh.
virtual void preSolve()
Called at the start of the time-step, before the PIMPLE loop.
const surfaceScalarField & phic
Reference to the continuous phase volumetric-flux field.
const volScalarField & p
Reference to the pressure field.
virtual void thermophysicalTransportPredictor()
Predict thermophysical transport.
An abstract base class for Newtonian viscosity models.
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
virtual tmp< volScalarField > nu() const =0
Return the laminar viscosity.
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
pimpleControl pimple(mesh)
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Calculate the face-flux of the given field.
const dimensionSet velocity
const dimensionSet dimless
const dimensionSet kinematicPressure
const dimensionSet acceleration
tmp< SurfaceField< typename innerProduct< vector, Type >::type > > flux(const VolField< Type > &vf)
Return the face-flux field obtained from the given volVectorField.
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)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
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
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
const dimensionSet & dimAcceleration
Definition: dimensions.C:287
const dimensionSet & dimDensity
Definition: dimensions.C:289
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)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict
volScalarField & p