compressibleTwoPhaseVoFMixture.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) 2013-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 
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
33 }
34 
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 (
40  const fvMesh& mesh
41 )
42 :
44 
45  totalInternalEnergy_
46  (
47  lookupOrDefault<Switch>("totalInternalEnergy", true)
48  ),
49 
50  p_
51  (
52  IOobject
53  (
54  "p",
55  mesh.time().name(),
56  mesh,
57  IOobject::MUST_READ,
58  IOobject::AUTO_WRITE
59  ),
60  mesh
61  ),
62  T_
63  (
64  IOobject
65  (
66  "T",
67  mesh.time().name(),
68  mesh,
69  IOobject::MUST_READ,
70  IOobject::AUTO_WRITE
71  ),
72  mesh
73  ),
74 
75  thermo1_(nullptr),
76  thermo2_(nullptr),
77 
78  rho_
79  (
80  IOobject
81  (
82  "rho",
83  mesh.time().name(),
84  mesh,
85  IOobject::NO_READ,
86  IOobject::AUTO_WRITE
87  ),
88  mesh,
89  dimensionedScalar("rho", dimDensity, 0)
90  ),
91 
92  nu_
93  (
94  IOobject
95  (
96  "nu",
97  mesh.time().name(),
98  mesh
99  ),
100  mesh,
102  calculatedFvPatchScalarField::typeName
103  )
104 {
105  {
106  volScalarField T1
107  (
108  IOobject
109  (
111  mesh.time().name(),
112  mesh
113  ),
114  T_,
115  calculatedFvPatchScalarField::typeName
116  );
117  T1.write();
118  }
119 
120  {
121  volScalarField T2
122  (
123  IOobject
124  (
126  mesh.time().name(),
127  mesh
128  ),
129  T_,
130  calculatedFvPatchScalarField::typeName
131  );
132  T2.write();
133  }
134 
135  // Note: we're writing files to be read in immediately afterwards.
136  // Avoid any thread-writing problems.
137  // fileHandler().flush();
138 
139  thermo1_ = rhoFluidThermo::New(mesh, phase1Name());
140  thermo2_ = rhoFluidThermo::New(mesh, phase2Name());
141 
142  // thermo1_->validate(phase1Name(), "e");
143  // thermo2_->validate(phase2Name(), "e");
144 
145  correct();
146 }
147 
148 
149 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
150 
152 {}
153 
154 
155 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
156 
158 {
159  thermo1_->T() = T_;
160  thermo1_->he() = thermo1_->he(p_, T_);
161  thermo1_->correct();
162 
163  thermo2_->T() = T_;
164  thermo2_->he() = thermo2_->he(p_, T_);
165  thermo2_->correct();
166 }
167 
168 
170 {
171  const volScalarField alphaRho1(alpha1()*thermo1_->rho());
172  const volScalarField alphaRho2(alpha2()*thermo2_->rho());
173 
174  rho_ = alpha1()*thermo1_->rho() + alpha2()*thermo2_->rho();
175  nu_ = (alpha1()*thermo1_->mu() + alpha2()*thermo2_->mu())/rho_;
176 }
177 
178 
181 {
182  return
183  (
184  alpha1()*thermo1_->psi()/thermo1_->rho()
185  + alpha2()*thermo2_->psi()/thermo2_->rho()
186  );
187 }
188 
189 
191 {
193  {
194  totalInternalEnergy_ =
195  lookupOrDefault<Switch>("totalInternalEnergy", true);
196 
197  return true;
198  }
199  else
200  {
201  return false;
202  }
203 }
204 
205 
206 // ************************************************************************* //
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static word groupName(Name name, const word &group)
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
Class to represent a mixture of two rhoFluidThermo-based phases.
virtual void correctThermo()
Correct the thermodynamics of each phase.
virtual void correct()
Update mixture properties.
compressibleTwoPhaseVoFMixture(const fvMesh &mesh)
Construct from a mesh.
virtual tmp< volScalarField > psiByRho() const
Return the mixture compressibility/density.
virtual bool read()
Read base phaseProperties dictionary.
const word & name() const
Return const reference to name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:420
virtual bool write(const bool write=true) const
Write using setting from DB.
static autoPtr< rhoFluidThermo > New(const fvMesh &, const word &phaseName=word::null)
Standard selection based on fvMesh.
A class for managing temporary objects.
Definition: tmp.H:55
const word & phase2Name() const
const word & phase1Name() const
Class to represent a VoF mixture.
virtual bool read()=0
Read base phaseProperties dictionary.
const fvMesh & mesh() const
Access the mesh.
Definition: twoPhases.H:71
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Namespace for OpenFOAM.
const dimensionSet dimKinematicViscosity
const dimensionSet dimDensity
defineTypeNameAndDebug(combustionModel, 0)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.