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-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 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  ),
138  (dict, phases)
139  );
140 
141 
142  // Constructors
143 
144  //- Construct for phases
146  (
147  const dictionary& dict,
148  const compressibleTwoPhases& phases
149  );
150 
151 
152  // Selector
154  (
155  const dictionary& dict,
156  const compressibleTwoPhases& phases
157  );
158 
159 
160  //- Destructor
161  virtual ~cavitationModel()
162  {}
163 
164 
165  // Member Functions
166 
167  //- Return the saturation vapour pressure for phase 1
168  inline tmp<volScalarField::Internal> pSat1() const
169  {
170  return liquidIndex_ ? pSatv() : pSatl();
171  }
172 
173  //- Return the saturation vapour pressure for phase 2
174  inline tmp<volScalarField::Internal> pSat2() const
175  {
176  return liquidIndex_ ? pSatl() : pSatv();
177  }
178 
179  //- Return the mass condensation and vaporisation rates as a
180  // coefficient to multiply alphav for the condensation rate and a
181  // coefficient to multiply alphal for the vaporisation rate
183 
184  //- Return the mass condensation and vaporisation rates as coefficients
185  // to multiply (p - pSat)
186  virtual Pair<tmp<volScalarField::Internal>> mDotcvP() const = 0;
187 
188  //- Return the mass transfer rates of the two phases as coefficients to
189  // multiply the volume fraction of the other phase
191  {
193  }
194 
195  //- Return the mass transfer rates of the two phases as coefficients to
196  // multiply (p - pSat)
198  {
199  return liquidIndex_ ? reverse(mDotcvP()) : mDotcvP();
200  }
201 
202  //- Correct the cavitation model
203  virtual void correct() = 0;
204 
205  //- Read the dictionary and update
206  virtual bool read(const dictionary& dict) = 0;
207 };
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace compressible
213 } // End namespace Foam
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #endif
218 
219 // ************************************************************************* //
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 <T> with first() and second() elements.
Definition: Pair.H:65
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.
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)
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.
static autoPtr< cavitationModel > New(const dictionary &dict, const compressibleTwoPhases &phases)
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.
declareRunTimeSelectionTable(autoPtr, cavitationModel, dictionary,(const dictionary &dict, const compressibleTwoPhases &phases),(dict, phases))
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 keyword definitions, which are a keyword followed by any number of values (e....
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.
void reverse(UList< T > &, const label n)
Definition: UListI.H:334
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict