compressibleVoF.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-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 \*---------------------------------------------------------------------------*/
25 
26 #include "compressibleVoF.H"
27 #include "localEulerDdtScheme.H"
28 #include "fvcDdt.H"
29 #include "fvcDiv.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace solvers
37 {
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 :
49  (
50  mesh,
52  ),
53 
54  mixture_
55  (
57  ),
58 
59  p(mixture_.p()),
60 
61  vDot
62  (
63  IOobject
64  (
65  "vDot",
66  runTime.name(),
67  mesh,
68  IOobject::READ_IF_PRESENT,
69  IOobject::AUTO_WRITE
70  ),
71  alpha1*fvc::div(phi)
72  ),
73 
74  pressureReference_
75  (
76  p,
77  p_rgh,
78  pimple.dict(),
79  false
80  ),
81 
82  alphaRhoPhi1
83  (
84  IOobject::groupName("alphaRhoPhi", alpha1.group()),
85  fvc::interpolate(mixture_.thermo1().rho())*alphaPhi1
86  ),
87 
88  alphaRhoPhi2
89  (
90  IOobject::groupName("alphaRhoPhi", alpha2.group()),
91  fvc::interpolate(mixture_.thermo2().rho())*alphaPhi2
92  ),
93 
94  K("K", 0.5*magSqr(U)),
95 
96  momentumTransport
97  (
98  rho,
99  U,
100  phi,
101  rhoPhi,
102  alphaPhi1,
103  alphaPhi2,
104  alphaRhoPhi1,
105  alphaRhoPhi2,
106  mixture_
107  ),
108 
109  thermophysicalTransport(momentumTransport),
110 
111  mixture(mixture_)
112 {
113  if (correctPhi || mesh.topoChanging())
114  {
115  rAU = new volScalarField
116  (
117  IOobject
118  (
119  "rAU",
120  runTime.name(),
121  mesh,
124  ),
125  mesh,
127  );
128  }
129 }
130 
131 
132 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
133 
135 {}
136 
137 
138 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
139 
141 {
143 
144  const volScalarField& rho1 = mixture_.thermo1().rho();
145  const volScalarField& rho2 = mixture_.thermo2().rho();
146 
147  alphaRhoPhi1 = fvc::interpolate(rho1)*alphaPhi1;
148  alphaRhoPhi2 = fvc::interpolate(rho2)*alphaPhi2;
149 
150  rhoPhi = alphaRhoPhi1 + alphaRhoPhi2;
151 
152  contErr1 =
153  (
154  fvc::ddt(alpha1, rho1)()() + fvc::div(alphaRhoPhi1)()()
155  - (fvModels().source(alpha1, rho1)&rho1)()
156  );
157 
158  contErr2 =
159  (
160  fvc::ddt(alpha2, rho2)()() + fvc::div(alphaRhoPhi2)()()
161  - (fvModels().source(alpha2, rho2)&rho2)()
162  );
163 
164  if (pimple.predictTransport())
165  {
166  momentumTransport.predict();
167  }
168 
169  if (pimple.predictTransport())
170  {
171  thermophysicalTransport.predict();
172  }
173 }
174 
175 
177 {
178  if (pimple.correctTransport())
179  {
180  momentumTransport.correct();
181  thermophysicalTransport.correct();
182  }
183 }
184 
185 
186 // ************************************************************************* //
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
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Class to represent a mixture of two rhoFluidThermo-based phases.
const word & name() const
Return const reference to name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
bool topoChanging() const
Does the mesh topology change?
Definition: fvMesh.C:598
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
const Time & runTime
Time.
Definition: solver.H:104
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
autoPtr< volScalarField > rAU
Inverse momentum equation diagonal.
Definition: VoFSolver.H:129
Solver module for 2 compressible, non-isothermal immiscible fluids using a VOF (volume of fluid) phas...
virtual void prePredictor()
Called at the start of the PIMPLE loop.
virtual void postCorrector()
Correct the momentum and thermophysical transport modelling.
compressibleVoF(fvMesh &mesh)
Construct from region mesh.
virtual ~compressibleVoF()
Destructor.
bool correctPhi
Switch to correct the flux after mesh change.
Definition: fluidSolver.H:101
virtual void prePredictor()
Called at the start of the PIMPLE loop.
Solver module base-class for 2 immiscible fluids using a VOF (volume of fluid) phase-fraction based i...
Class to represent a VoF mixture.
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
pimpleControl pimple(mesh)
Calculate the first temporal derivative.
Calculate the divergence of the given field.
Info<< "Creating thermophysical transport model\n"<< endl;turbulenceThermophysicalTransportModels::unityLewisEddyDiffusivity< RASThermophysicalTransportModel< ThermophysicalTransportModel< compressibleMomentumTransportModel, fluidThermo > >> thermophysicalTransport(turbulence(), thermo, true)
K
Definition: pEqn.H:75
U
Definition: pEqn.H:72
const char *const group
Group name for atomic constants.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< VolField< Type > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
addToRunTimeSelectionTable(solver, compressibleMultiphaseVoF, fvMesh)
defineTypeNameAndDebug(compressibleMultiphaseVoF, 0)
Namespace for OpenFOAM.
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:129
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
const dimensionSet dimTime
const dimensionSet dimDensity
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:64
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dictionary dict
volScalarField & p