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();
75 
76 
77 protected:
78 
79  // Protected Member Functions
80 
81  //- Lookup the phase names
82  const Pair<word> lookupPhaseNames() const;
83 
84  //- Lookup the phase field names
85  const Pair<word> lookupPhaseFieldNames(const word& name) const;
86 
87  //- Get the index of the name in the given pair, or -1
88  static inline label index(const Pair<word>& names, const word& name);
89 
90  //- Get the sign associated with the name in the given pair; i.e., -1
91  // if it is the first name, +1 if the second, and zero if neither
92  static inline label sign(const Pair<word>& names, const word& name);
93 
94  //- Return the density
96 
97  //- Return the corresponding field in the other phase, or a null
98  // reference if no such field exists
99  template<class Type>
100  const VolField<Type>& otherField(const VolField<Type>& field) const;
101 
102 
103  // Sources
104 
105  //- Add a source term to an equation
106  template<class Type>
107  void addSupType
108  (
109  const VolField<Type>& field,
110  fvMatrix<Type>& eqn
111  ) const;
112 
113  //- Add a source term to a scalar equation
114  void addSupType
115  (
116  const volScalarField& alphaOrField,
117  fvMatrix<scalar>& eqn
118  ) const;
119 
120  //- Add a source term to a compressible equation
121  template<class Type>
122  void addSupType
123  (
124  const volScalarField& alphaOrRho,
125  const VolField<Type>& field,
126  fvMatrix<Type>& eqn
127  ) const;
128 
129  //- Add a source term to a compressible scalar equation
130  void addSupType
131  (
132  const volScalarField& alphaOrRho,
133  const volScalarField& rhoOrField,
134  fvMatrix<scalar>& eqn
135  ) const;
136 
137  //- Add a source term to a phase equation
138  template<class Type>
139  void addSupType
140  (
141  const volScalarField& alpha,
142  const volScalarField& rho,
143  const VolField<Type>& field,
144  fvMatrix<Type>& eqn
145  ) const;
146 
147 
148 public:
149 
150  //- Runtime type information
151  TypeName("massTransfer");
152 
153 
154  // Constructors
155 
156  //- Construct from explicit source name and mesh
158  (
159  const word& name,
160  const word& modelType,
161  const fvMesh& mesh,
162  const dictionary& dict
163  );
164 
165 
166  // Member Functions
167 
168  // Checks
169 
170  //- Return true if the fvModel adds a source term to the given
171  // field's transport equation
172  virtual bool addsSupToField(const word& fieldName) const;
173 
174 
175  // Access
176 
177  //- Return the names of the phases
178  inline const Pair<word>& phaseNames() const;
179 
180  //- Return the names of the volume fraction fields
181  inline const Pair<word>& alphaNames() const;
182 
183  //- Return the names of the density fields
184  inline const Pair<word>& rhoNames() const;
185 
186 
187  // Sources
188 
189  //- Return the mass transfer rate
190  virtual tmp<DimensionedField<scalar, volMesh>> mDot() const = 0;
191 
192  //- Return the source value
194  (
195  const word& fieldName
196  ) const;
197 
198  //- Add a source term to a field-less proxy equation
199  virtual void addSup(fvMatrix<scalar>& eqn) const;
200 
201  //- Add a source term to an equation
203 
204  //- Add a source term to a compressible equation
206 
207  //- Add a source term to a phase equation
209 
210 
211  //- Read source dictionary
212  virtual bool read(const dictionary& dict);
213 };
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 } // End namespace fv
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #include "massTransferI.H"
224 
225 #ifdef NoRepository
226  #include "massTransferTemplates.C"
227 #endif
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #endif
232 
233 // ************************************************************************* //
Generic GeometricField class.
A list of keyword definitions, which are a keyword followed by any number of values (e....
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:99
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:53
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:47
static const word & fieldName()
Return the name of the field associated with a source term. Special.
Definition: fvModelI.H:39
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.
const Pair< word > lookupPhaseFieldNames(const word &name) const
Lookup the phase field names.
Definition: massTransfer.C:69
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_FIELD_SUP)
Add a source term to an equation.
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: massTransfer.C:242
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:85
massTransfer(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: massTransfer.C:182
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:218
const Pair< word > & rhoNames() const
Return the names of the density fields.
Definition: massTransferI.H:64
const Pair< word > lookupPhaseNames() const
Lookup the phase names.
Definition: massTransfer.C:62
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:200
virtual tmp< DimensionedField< scalar, volMesh > > S(const word &fieldName) const
Return the source value.
Definition: massTransfer.C:212
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