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-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 
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  dimensions::pressure
62  ),
63  T_
64  (
65  IOobject
66  (
67  "T",
68  mesh.time().name(),
69  mesh,
70  IOobject::MUST_READ,
71  IOobject::AUTO_WRITE
72  ),
73  mesh,
74  dimensions::temperature
75  ),
76 
77  thermo1_(nullptr),
78  thermo2_(nullptr),
79 
80  rho_
81  (
82  IOobject
83  (
84  "rho",
85  mesh.time().name(),
86  mesh,
87  IOobject::NO_READ,
88  IOobject::AUTO_WRITE
89  ),
90  mesh,
91  dimensionedScalar("rho", dimDensity, 0)
92  ),
93 
94  nu_
95  (
96  IOobject
97  (
98  "nu",
99  mesh.time().name(),
100  mesh
101  ),
102  mesh,
104  calculatedFvPatchScalarField::typeName
105  )
106 {
107  {
108  volScalarField T1
109  (
110  IOobject
111  (
113  mesh.time().name(),
114  mesh
115  ),
116  T_,
118  );
119  T1.write();
120  }
121 
122  {
123  volScalarField T2
124  (
125  IOobject
126  (
128  mesh.time().name(),
129  mesh
130  ),
131  T_,
133  );
134  T2.write();
135  }
136 
137  // Note: we're writing files to be read in immediately afterwards.
138  // Avoid any thread-writing problems.
139  // fileHandler().flush();
140 
141  thermo1_ = rhoFluidThermo::New(mesh, phase1Name());
142  thermo2_ = rhoFluidThermo::New(mesh, phase2Name());
143 
144  // thermo1_->validate(phase1Name(), "e");
145  // thermo2_->validate(phase2Name(), "e");
146 
147  correct();
148 }
149 
150 
151 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
152 
154 {}
155 
156 
157 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
158 
160 {
161  thermo1_->T() = T_;
162  thermo1_->he() = thermo1_->he(p_, T_);
163  thermo1_->correct();
164 
165  thermo2_->T() = T_;
166  thermo2_->he() = thermo2_->he(p_, T_);
167  thermo2_->correct();
168 }
169 
170 
172 {
173  const volScalarField alphaRho1(alpha1()*thermo1_->rho());
174  const volScalarField alphaRho2(alpha2()*thermo2_->rho());
175 
176  rho_ = alpha1()*thermo1_->rho() + alpha2()*thermo2_->rho();
177  nu_ = (alpha1()*thermo1_->mu() + alpha2()*thermo2_->mu())/rho_;
178 }
179 
180 
183 {
184  return
185  (
186  alpha1()*thermo1_->psi()/thermo1_->rho()
187  + alpha2()*thermo2_->psi()/thermo2_->rho()
188  );
189 }
190 
191 
193 {
195  {
196  totalInternalEnergy_ =
197  lookupOrDefault<Switch>("totalInternalEnergy", true);
198 
199  return true;
200  }
201  else
202  {
203  return false;
204  }
205 }
206 
207 
208 // ************************************************************************* //
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:98
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
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
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const dimensionSet time
const dimensionSet pressure
const dimensionSet temperature
Namespace for OpenFOAM.
const dimensionSet & dimKinematicViscosity
Definition: dimensions.C:297
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
const dimensionSet & dimDensity
Definition: dimensions.C:289
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)