multiphaseEulerCavitation.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) 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 #include "fvmSup.H"
28 #include "multiphaseEuler.H"
29 #include "cavitationModel.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
46 void Foam::fv::multiphaseEulerCavitation::readCoeffs
47 (
48  const dictionary& dict
49 )
50 {
51  cavitationModel_.reset
52  (
54  (
55  dict,
56  interface_,
57  interface_.index(liquid_)
58  ).ptr()
59  );
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
66 (
67  const word& name,
68  const word& modelType,
69  const fvMesh& mesh,
70  const dictionary& dict
71 )
72 :
73  phaseChange(name, modelType, mesh, dict, wordList()),
74  fluid_(mesh().lookupObject<phaseSystem>(phaseSystem::propertiesName)),
75  liquid_(fluid_.phases()[phaseNames().first()]),
76  vapour_(fluid_.phases()[phaseNames().second()]),
77  interface_(liquid_, vapour_),
78  p_rgh_
79  (
80  mesh().lookupObject<solvers::multiphaseEuler>(solver::typeName).p_rgh
81  )
82 {
83  readCoeffs(coeffs(dict));
84 }
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
91 {
92  // Put all the latent heat into the liquid
93  return
95  (
96  name() + ":Lfraction",
97  mesh(),
98  dimensionedScalar(dimless, scalar(0))
99  );
100 }
101 
102 
105 {
107  (
108  cavitationModel_->mDot12P()
109  );
110 
111  const volScalarField::Internal& p = liquid_.fluidThermo().p();
112  const volScalarField::Internal pSat1(cavitationModel_->pSat1());
113  const volScalarField::Internal pSat2(cavitationModel_->pSat2());
114 
115  return
117  (
118  name() + ":mDot",
119  coeffs[0]*(p - pSat1) - coeffs[1]*(p - pSat2)
120  );
121 }
122 
123 
125 (
126  const volScalarField& alpha,
127  const volScalarField& rho,
128  fvMatrix<scalar>& eqn
129 ) const
130 {
131  // Pressure equation (i.e., continuity, linearised in the pressure)
132  if
133  (
134  (&alpha == &liquid_ || &alpha == &vapour_)
135  && (&rho == &liquid_.rho() || &rho == &vapour_.rho())
136  && &eqn.psi() == &p_rgh_
137  )
138  {
140  (
141  cavitationModel_->mDot12P()
142  );
143 
144  eqn += correction(fvm::Sp(coeffs[0] - coeffs[1], eqn.psi()));
145  }
146 
147  // Let the base class add the actual source
149 }
150 
151 
153 {
154  if (phaseChange::read(dict))
155  {
156  readCoeffs(coeffs(dict));
157  return true;
158  }
159  else
160  {
161  return false;
162  }
163 }
164 
165 
166 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static tmp< DimensionedField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Mesh &mesh, const dimensionSet &, const PrimitiveField< Type > &)
Return a temporary field constructed from name, mesh,.
Generic GeometricField class.
An ordered pair of two objects of type <Type> with first() and second() elements.
Definition: Pair.H:66
static autoPtr< cavitationModel > New(const dictionary &dict, const compressibleTwoPhases &phases, const label liquidIndex=-1)
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
VolField< Type > & psi()
Definition: fvMatrix.H:289
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Finite volume model abstract base class.
Definition: fvModel.H:60
static const dictionary & coeffs(const word &modelType, const dictionary &)
Return the coefficients sub-dictionary for a given model type.
Definition: fvModelI.H:31
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: massTransfer.C:225
Model for cavitation phase change between two phases.
virtual tmp< DimensionedField< scalar, volMesh > > Lfraction() const
Return the fraction of the latent heat that is transferred into.
virtual tmp< DimensionedField< scalar, volMesh > > mDot() const
Return the mass transfer rate.
virtual bool read(const dictionary &dict)
Read source dictionary.
void addSup(const volScalarField &alpha, const volScalarField &rho, const volScalarField &heOrYi, fvMatrix< scalar > &eqn) const
Use phaseChange's source functions.
Definition: phaseChange.C:551
multiphaseEulerCavitation(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Base class for phase change models.
Definition: phaseChange.H:61
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: phaseChange.C:624
label index(const phaseModel &phase) const
Return the index of the given phase. Generates a FatalError if.
Class to represent a system of phases.
Definition: phaseSystem.H:74
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Calculate the matrix for implicit and explicit sources.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
addToRunTimeSelectionTable(fvConstraint, bound, dictionary)
defineTypeNameAndDebug(bound, 0)
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
Namespace for OpenFOAM.
const dimensionSet dimless
labelList second(const UList< labelPair > &p)
Definition: patchToPatch.C:49
labelList first(const UList< labelPair > &p)
Definition: patchToPatch.C:39
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
labelList fv(nPoints)
dictionary dict
volScalarField & p