cavitationModel.H
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) 2021-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 Class
25  Foam::compressible::twoPhaseChangeModels::cavitationModel
26 
27 Description
28  Abstract base class for cavitation models
29 
30 SourceFiles
31  cavitationModel.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef cavitationModel_H
36 #define cavitationModel_H
37 
38 #include "compressibleTwoPhases.H"
39 #include "fvMatricesFwd.H"
40 #include "Pair.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 namespace compressible
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class cavitationModel
52 \*---------------------------------------------------------------------------*/
53 
54 class cavitationModel
55 {
56 protected:
57 
58  // Protected data
59 
60  //- Phases
62 
63  //- Index of the liquid
64  const bool liquidIndex_;
65 
66  //- The saturation pressure model
68 
69 
70  // Protected Member Functions
71 
72  //- Return the liquid density
73  inline const volScalarField::Internal& alphal() const
74  {
75  return phases_.alpha(liquidIndex_);
76  }
77 
78  //- Return the vapour density
79  inline const volScalarField::Internal& alphav() const
80  {
81  return phases_.alpha(!liquidIndex_);
82  }
83 
84  //- Return the liquid density
85  inline const volScalarField::Internal& rhol() const
86  {
87  return phases_.rho(liquidIndex_);
88  }
89 
90  //- Return the vapour density
91  inline const volScalarField::Internal& rhov() const
92  {
93  return phases_.rho(!liquidIndex_);
94  }
95 
96  //- Return the liquid thermo
97  inline const rhoFluidThermo& thermol() const
98  {
99  return phases_.thermo(liquidIndex_);
100  }
101 
102  //- Return the vapour thermo
103  inline const rhoFluidThermo& thermov() const
104  {
105  return phases_.thermo(!liquidIndex_);
106  }
107 
108  //- Return the saturation vapour pressure for the liquid
109  inline tmp<volScalarField::Internal> pSatl() const
110  {
111  return saturationModel_->pSat(thermol().T()());
112  }
113 
114  //- Return the saturation vapour pressure for the vapour
115  inline tmp<volScalarField::Internal> pSatv() const
116  {
117  return saturationModel_->pSat(thermov().T()());
118  }
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("cavitation");
125 
126 
127  // Declare run-time constructor selection table
128 
130  (
131  autoPtr,
133  dictionary,
134  (
135  const dictionary& dict,
136  const compressibleTwoPhases& phases,
137  const label liquidIndex
138  ),
139  (dict, phases, liquidIndex)
140  );
141 
142 
143  // Constructors
144 
145  //- Construct for phases
147  (
148  const dictionary& dict,
149  const compressibleTwoPhases& phases,
150  const label liquidIndex
151  );
152 
153 
154  // Selector
156  (
157  const dictionary& dict,
158  const compressibleTwoPhases& phases,
159  const label liquidIndex = -1
160  );
161 
162 
163  //- Destructor
164  virtual ~cavitationModel()
165  {}
166 
167 
168  // Member Functions
169 
170  //- Return the saturation vapour pressure for phase 1
171  inline tmp<volScalarField::Internal> pSat1() const
172  {
173  return liquidIndex_ ? pSatv() : pSatl();
174  }
175 
176  //- Return the saturation vapour pressure for phase 2
177  inline tmp<volScalarField::Internal> pSat2() const
178  {
179  return liquidIndex_ ? pSatl() : pSatv();
180  }
181 
182  //- Return the mass condensation and vaporisation rates as a
183  // coefficient to multiply alphav for the condensation rate and a
184  // coefficient to multiply alphal for the vaporisation rate
186 
187  //- Return the mass condensation and vaporisation rates as coefficients
188  // to multiply (p - pSat)
189  virtual Pair<tmp<volScalarField::Internal>> mDotcvP() const = 0;
190 
191  //- Return the mass transfer rates of the two phases as coefficients to
192  // multiply the volume fraction of the other phase
194  {
196  }
197 
198  //- Return the mass transfer rates of the two phases as coefficients to
199  // multiply (p - pSat)
201  {
202  return liquidIndex_ ? reverse(mDotcvP()) : mDotcvP();
203  }
204 
205  //- Correct the cavitation model
206  virtual void correct() = 0;
207 
208  //- Read the dictionary and update
209  virtual bool read(const dictionary& dict) = 0;
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace compressible
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An ordered pair of two objects of type <Type> with first() and second() elements.
Definition: Pair.H:66
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
const rhoFluidThermo & thermo(const bool index) const
Return the density of a given phase.
const volScalarField & rho(const bool index) const
Return the density of a given phase.
Pair< tmp< volScalarField::Internal > > mDot12P() const
Return the mass transfer rates of the two phases as coefficients to.
virtual Pair< tmp< volScalarField::Internal > > mDotcvP() const =0
Return the mass condensation and vaporisation rates as coefficients.
static autoPtr< cavitationModel > New(const dictionary &dict, const compressibleTwoPhases &phases, const label liquidIndex=-1)
const rhoFluidThermo & thermol() const
Return the liquid thermo.
virtual bool read(const dictionary &dict)=0
Read the dictionary and update.
cavitationModel(const dictionary &dict, const compressibleTwoPhases &phases, const label liquidIndex)
Construct for phases.
Pair< tmp< volScalarField::Internal > > mDot12Alpha() const
Return the mass transfer rates of the two phases as coefficients to.
const volScalarField::Internal & rhol() const
Return the liquid density.
const compressibleTwoPhases & phases_
Phases.
const volScalarField::Internal & alphav() const
Return the vapour density.
const volScalarField::Internal & rhov() const
Return the vapour density.
declareRunTimeSelectionTable(autoPtr, cavitationModel, dictionary,(const dictionary &dict, const compressibleTwoPhases &phases, const label liquidIndex),(dict, phases, liquidIndex))
tmp< volScalarField::Internal > pSatv() const
Return the saturation vapour pressure for the vapour.
autoPtr< saturationPressureModel > saturationModel_
The saturation pressure model.
const rhoFluidThermo & thermov() const
Return the vapour thermo.
tmp< volScalarField::Internal > pSatl() const
Return the saturation vapour pressure for the liquid.
virtual void correct()=0
Correct the cavitation model.
virtual Pair< tmp< volScalarField::Internal > > mDotcvAlphal() const =0
Return the mass condensation and vaporisation rates as a.
const bool liquidIndex_
Index of the liquid.
tmp< volScalarField::Internal > pSat2() const
Return the saturation vapour pressure for phase 2.
TypeName("cavitation")
Runtime type information.
const volScalarField::Internal & alphal() const
Return the liquid density.
tmp< volScalarField::Internal > pSat1() const
Return the saturation vapour pressure for phase 1.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Base-class for fluid thermodynamic properties based on density.
A class for managing temporary objects.
Definition: tmp.H:55
const volScalarField & alpha(const bool index) const
Return the volume-fraction of a given phase.
Definition: twoPhases.H:103
Forward declarations of fvMatrix specialisations.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
void reverse(UList< T > &, const label n)
Definition: UListI.H:334
dictionary dict