massTransfer.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-2024 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::massTransfer
26 
27 Description
28  Base class for mass transfers between phases
29 
30 SourceFiles
31  massTransfer.C
32  massTransferI.H
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef massTransfer_H
37 #define massTransfer_H
38 
39 #include "fvSpecificSource.H"
40 #include "Function1.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace fv
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class massTransfer Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class massTransfer
54 :
55  public fvSpecificSource
56 {
57 private:
58 
59  // Private Data
60 
61  //- Names of the phases
62  const Pair<word> phaseNames_;
63 
64  //- Names of the volume fraction fields
65  const Pair<word> alphaNames_;
66 
67  //- Names of the density fields
68  const Pair<word> rhoNames_;
69 
70 
71  // Private Member Functions
72 
73  //- Non-virtual read
74  void readCoeffs(const dictionary& dict);
75 
76 
77 protected:
78 
79  // Protected Member Functions
80 
81  //- Lookup the phase names
82  const Pair<word> lookupPhaseNames(const dictionary& dict) const;
83 
84  //- Lookup the phase field names
86  (
87  const dictionary& dict,
88  const word& name
89  ) const;
90 
91  //- Get the index of the name in the given pair, or -1
92  static inline label index(const Pair<word>& names, const word& name);
93 
94  //- Get the sign associated with the name in the given pair; i.e., -1
95  // if it is the first name, +1 if the second, and zero if neither
96  static inline label sign(const Pair<word>& names, const word& name);
97 
98  //- Return the density
100 
101  //- Return the corresponding field in the other phase, or a null
102  // reference if no such field exists
103  template<class Type>
104  const VolField<Type>& otherField(const VolField<Type>& field) const;
105 
106 
107  // Sources
108 
109  //- Add a source term to an equation
110  template<class Type>
111  void addSupType
112  (
113  const VolField<Type>& field,
114  fvMatrix<Type>& eqn
115  ) const;
116 
117  //- Add a source term to a scalar equation
118  void addSupType
119  (
120  const volScalarField& alphaOrField,
121  fvMatrix<scalar>& eqn
122  ) const;
123 
124  //- Add a source term to a compressible equation
125  template<class Type>
126  void addSupType
127  (
128  const volScalarField& alphaOrRho,
129  const VolField<Type>& field,
130  fvMatrix<Type>& eqn
131  ) const;
132 
133  //- Add a source term to a compressible scalar equation
134  void addSupType
135  (
136  const volScalarField& alphaOrRho,
137  const volScalarField& rhoOrField,
138  fvMatrix<scalar>& eqn
139  ) const;
140 
141  //- Add a source term to a phase equation
142  template<class Type>
143  void addSupType
144  (
145  const volScalarField& alpha,
146  const volScalarField& rho,
147  const VolField<Type>& field,
148  fvMatrix<Type>& eqn
149  ) const;
150 
151 
152 public:
153 
154  //- Runtime type information
155  TypeName("massTransfer");
156 
157 
158  // Constructors
159 
160  //- Construct from explicit source name and mesh
162  (
163  const word& name,
164  const word& modelType,
165  const fvMesh& mesh,
166  const dictionary& dict
167  );
168 
169 
170  // Member Functions
171 
172  // Checks
173 
174  //- Return true if the fvModel adds a source term to the given
175  // field's transport equation
176  virtual bool addsSupToField(const word& fieldName) const;
177 
178 
179  // Access
180 
181  //- Return the names of the phases
182  inline const Pair<word>& phaseNames() const;
183 
184  //- Return the names of the volume fraction fields
185  inline const Pair<word>& alphaNames() const;
186 
187  //- Return the names of the density fields
188  inline const Pair<word>& rhoNames() const;
189 
190 
191  // Sources
192 
193  //- Return the mass transfer rate
194  virtual tmp<DimensionedField<scalar, volMesh>> mDot() const = 0;
195 
196  //- Return the source value
198  (
199  const word& fieldName
200  ) const;
201 
202  //- Add a source term to a field-less proxy equation
203  virtual void addSup(fvMatrix<scalar>& eqn) const;
204 
205  //- Add a source term to an equation
207 
208  //- Add a source term to a compressible equation
210 
211  //- Add a source term to a phase equation
213 
214 
215  //- Read source dictionary
216  virtual bool read(const dictionary& dict);
217 };
218 
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 } // End namespace fv
223 } // End namespace Foam
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #include "massTransferI.H"
228 
229 #ifdef NoRepository
230  #include "massTransferTemplates.C"
231 #endif
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #endif
236 
237 // ************************************************************************* //
Generic GeometricField class.
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:96
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
static const word & fieldName()
Return the name of the field associated with a source term. Special.
Definition: fvModelI.H:49
Base class for sources which are specified as a specific value (e.g., mass flow rate per unit volume)...
Base class for mass transfers between phases.
Definition: massTransfer.H:55
void addSupType(const VolField< Type > &field, fvMatrix< Type > &eqn) const
Add a source term to an equation.
TypeName("massTransfer")
Runtime type information.
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
Add a source term to an equation.
const Pair< word > lookupPhaseNames(const dictionary &dict) const
Lookup the phase names.
Definition: massTransfer.C:63
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: massTransfer.C:249
const Pair< word > & phaseNames() const
Return the names of the phases.
Definition: massTransferI.H:52
tmp< volScalarField::Internal > rho(const label i) const
Return the density.
Definition: massTransfer.C:92
massTransfer(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: massTransfer.C:189
const Pair< word > lookupPhaseFieldNames(const dictionary &dict, const word &name) const
Lookup the phase field names.
Definition: massTransfer.C:73
const Pair< word > & alphaNames() const
Return the names of the volume fraction fields.
Definition: massTransferI.H:58
static label sign(const Pair< word > &names, const word &name)
Get the sign associated with the name in the given pair; i.e., -1.
Definition: massTransferI.H:41
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: massTransfer.C:225
const Pair< word > & rhoNames() const
Return the names of the density fields.
Definition: massTransferI.H:64
virtual tmp< DimensionedField< scalar, volMesh > > mDot() const =0
Return the mass transfer rate.
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Definition: massTransfer.C:207
virtual tmp< DimensionedField< scalar, volMesh > > S(const word &fieldName) const
Return the source value.
Definition: massTransfer.C:219
static label index(const Pair< word > &names, const word &name)
Get the index of the name in the given pair, or -1.
Definition: massTransferI.H:31
const VolField< Type > & otherField(const VolField< Type > &field) const
Return the corresponding field in the other phase, or a null.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
#define DEFINE_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP(Type, nullArg)
Definition: fvModelM.H:62
#define DEFINE_FV_MODEL_ADD_RHO_FIELD_SUP(Type, nullArg)
Definition: fvModelM.H:43
#define DEFINE_FV_MODEL_ADD_FIELD_SUP(Type, nullArg)
Definition: fvModelM.H:26
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