phaseChange.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-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 Class
25  Foam::fv::phaseChange
26 
27 Description
28  Base class for phase change models
29 
30 SourceFiles
31  phaseChange.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef phaseChange_H
36 #define phaseChange_H
37 
38 #include "hashedWordList.H"
39 #include "massTransfer.H"
40 #include "ThermoRefPair.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 class basicThermo;
48 class fluidThermo;
49 class multicomponentThermo;
50 class fluidMulticomponentThermo;
51 
52 namespace fv
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class phaseChange Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class phaseChange
60 :
61  public massTransfer
62 {
63 private:
64 
65  // Private Data
66 
67  //- The thermo references
68  const ThermoRefPair<basicThermo> thermos_;
69 
70  //- Names of the energy fields
71  const Pair<word> heNames_;
72 
73  //- The names of the transferring species
74  hashedWordList species_;
75 
76  //- The indices of the transferring species in the two phases, or -1 if
77  // the phase is not multicomponent
78  List<labelPair> specieis_;
79 
80  //- Whether or not to linearise the energy source
81  bool energySemiImplicit_;
82 
83 
84  // Private Member Functions
85 
86  //- Non-virtual read
87  void readCoeffs(const dictionary& dict);
88 
89 
90 protected:
91 
92  // Protected Member Functions
93 
94  //- Read the names of the transferring specie
95  wordList readSpecie(const dictionary& dict, const bool required) const;
96 
97  //- Read the names of the transferring species
98  wordList readSpecies(const dictionary& dict, const bool required) const;
99 
100  //- Re-read the names of the transferring specie
101  void reReadSpecie(const dictionary& dict) const;
102 
103  //- Re-read the names of the transferring species
104  void reReadSpecies(const dictionary& dict) const;
105 
106  //- Set the names of the transferring species
107  void setSpecies
108  (
109  const word& name,
110  const word& modelType,
111  const wordList& species
112  );
113 
114  //- Set the names of the transferring species
115  void setSpecies(const wordList& species);
116 
117  //- Re-set the names of the transferring species
118  void reSetSpecies(const wordList& species);
119 
120  //- Access the pressure field
121  const volScalarField& p() const;
122 
123  //- Add a boundary field to the given internal field
125  (
127  );
128 
129  //- Remove the boundary field from the given geometric field
131  (
132  const tmp<volScalarField>& tvf
133  );
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("phaseChange");
140 
141 
142  // Constructors
143 
144  //- Construct from explicit source name and mesh
146  (
147  const word& name,
148  const word& modelType,
149  const fvMesh& mesh,
150  const dictionary& dict,
151  const wordList& species
152  );
153 
154 
155  // Member Functions
156 
157  // Access
158 
159  //- Return the thermo references
160  inline const ThermoRefPair<basicThermo>& thermos() const;
161 
162  //- Return the fluid thermo references
164  fluidThermos(const bool, const bool) const;
165 
166  //- Return the multicomponent thermo references
168  multicomponentThermos(const bool, const bool) const;
169 
170  //- Return the fluid multicomponent thermo references
172  fluidMulticomponentThermos(const bool, const bool) const;
173 
174  //- Return the names of the energy fields
175  inline const Pair<word>& heNames() const;
176 
177  //- Return the names of the transferring species. Empty if neither
178  // thermo is multicomponent.
179  inline const hashedWordList& species() const;
180 
181  //- Return the indices of the transferring specie in the two
182  // phases, or -1 if the phase is not multicomponent
183  const labelPair& specieis(const label mDoti = -1) const;
184 
185 
186  // Evaluation
187 
188  //- Return the temperature at which the phases are considered to be
189  // changing. By default this is considered to be the temperature
190  // of the "source" phase (i.e., the phase for which mDot is
191  // negative), but this can be overridden to account for heat
192  // transfer modelling or similar.
194 
195  //- Return the fraction of the latent heat that is transferred into
196  // the second phase. By default this is weighted by the phase
197  // thermal conductivities, but this can be overridden to account
198  // for heat transfer modelling or similar.
200 
201  //- Return the latent heat
203  (
204  const label mDoti = -1
205  ) const;
206 
207  //- Return the latent heat for a given changing temperature
209  (
211  const label mDoti = -1
212  ) const;
213 
214  //- Return the latent heat for a patch and a given changing
215  // temperature
217  (
218  const label patchi,
219  const scalarField& Tchange,
220  const label mDoti = -1
221  ) const;
222 
223 
224  // Sources
225 
226  //- Return the total phase change rate
228 
229  //- Return the mass transfer rate of a specie
231  (
232  const label mDoti
233  ) const;
234 
235  //- Override the energy equation to add the phase change heat, or
236  // the species equations to add the relevant mass sources
237  void addSup
238  (
239  const volScalarField& alpha,
240  const volScalarField& rho,
241  const volScalarField& heOrYi,
242  fvMatrix<scalar>& eqn
243  ) const;
244 
245 
246  //- Read source dictionary
247  virtual bool read(const dictionary& dict);
248 };
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace fv
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #include "phaseChangeI.H"
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic GeometricField class.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
Class containing a pair of thermo references. Handles down-casting to more specific thermo types by c...
Definition: ThermoRefPair.H:51
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
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:69
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:57
Base class for mass transfers between phases.
Definition: massTransfer.H:55
tmp< volScalarField::Internal > rho(const label i) const
Return the density.
Definition: massTransfer.C:92
Base class for phase change models.
Definition: phaseChange.H:61
void reReadSpecies(const dictionary &dict) const
Re-read the names of the transferring species.
Definition: phaseChange.C:118
const labelPair & specieis(const label mDoti=-1) const
Return the indices of the transferring specie in the two.
Definition: phaseChange.C:344
wordList readSpecie(const dictionary &dict, const bool required) const
Read the names of the transferring specie.
Definition: phaseChange.C:52
const ThermoRefPair< multicomponentThermo > multicomponentThermos(const bool, const bool) const
Return the multicomponent thermo references.
Definition: phaseChange.C:312
virtual tmp< DimensionedField< scalar, fvMesh > > Lfraction() const
Return the fraction of the latent heat that is transferred into.
Definition: phaseChange.C:401
const ThermoRefPair< fluidThermo > fluidThermos(const bool, const bool) const
Return the fluid thermo references.
Definition: phaseChange.C:295
void reReadSpecie(const dictionary &dict) const
Re-read the names of the transferring specie.
Definition: phaseChange.C:107
wordList readSpecies(const dictionary &dict, const bool required) const
Read the names of the transferring species.
Definition: phaseChange.C:74
static tmp< DimensionedField< scalar, fvMesh > > vfToVif(const tmp< volScalarField > &tvf)
Remove the boundary field from the given geometric field.
Definition: phaseChange.C:255
static tmp< volScalarField > vifToVf(const tmp< DimensionedField< scalar, fvMesh >> &tvif)
Add a boundary field to the given internal field.
Definition: phaseChange.C:232
virtual tmp< DimensionedField< scalar, fvMesh > > mDot() const
Return the total phase change rate.
Definition: phaseChange.C:476
TypeName("phaseChange")
Runtime type information.
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: phaseChange.C:602
void addSup(const volScalarField &alpha, const volScalarField &rho, const volScalarField &heOrYi, fvMatrix< scalar > &eqn) const
Override the energy equation to add the phase change heat, or.
Definition: phaseChange.C:529
void setSpecies(const word &name, const word &modelType, const wordList &species)
Set the names of the transferring species.
Definition: phaseChange.C:130
const ThermoRefPair< fluidMulticomponentThermo > fluidMulticomponentThermos(const bool, const bool) const
Return the fluid multicomponent thermo references.
Definition: phaseChange.C:329
void reSetSpecies(const wordList &species)
Re-set the names of the transferring species.
Definition: phaseChange.C:206
tmp< DimensionedField< scalar, fvMesh > > L(const label mDoti=-1) const
Return the latent heat.
Definition: phaseChange.C:411
const hashedWordList & species() const
Return the names of the transferring species. Empty if neither.
Definition: phaseChangeI.H:44
const volScalarField & p() const
Access the pressure field.
Definition: phaseChange.C:217
virtual tmp< DimensionedField< scalar, fvMesh > > Tchange() const
Return the temperature at which the phases are considered to be.
Definition: phaseChange.C:371
phaseChange(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict, const wordList &species)
Construct from explicit source name and mesh.
Definition: phaseChange.C:270
const ThermoRefPair< basicThermo > & thermos() const
Return the thermo references.
Definition: phaseChangeI.H:32
const Pair< word > & heNames() const
Return the names of the energy fields.
Definition: phaseChangeI.H:38
A wordList with hashed indices for faster lookup by name.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
label patchi
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
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
labelList fv(nPoints)
dictionary dict