zeroDimensionalMassSource.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::fv::zeroDimensionalMassSource
26 
27 Description
28  This fvModel applies a mass source to the continuity equation and to all
29  field equations, in a zero-dimensional case. Correction is made to account
30  for the mass that exits the domain due to expansion in space, so that the
31  model correctly applies a total mass flow rate.
32 
33  This model will write out additional fields, zeroDimensionalMassSource:m
34  and zeroDimensionalMassSource:factor. The zeroDimensionalMassSource:m field
35  is the total accumulated mass; the sum of the starting mass, plus all mass
36  added by models of this type. This may differ from the actual current mass
37  (= rho*V) within the zero-dimensional cell if pressure or density
38  constraints are being used. The zeroDimensionalMassSource:factor field is
39  the ratio between the current mass or volume and the total accumulated mass
40  or volume.
41 
42  If the mass flow rate is positive then user-supplied fixed property values
43  are introduced to the field equations. If the mass flow rate is negative
44  then properties are removed at their current value.
45 
46 Usage
47  Example usage:
48  \verbatim
49  zeroDimensionalMassSource
50  {
51  type zeroDimensionalMassSource;
52 
53  massFlowRate 1e-4;
54 
55  fieldValues
56  {
57  U (10 0 0);
58  T 300;
59  k 0.375;
60  epsilon 14.855;
61  }
62  }
63  \endverbatim
64 
65  If the mass flow rate is positive then values should be provided for all
66  solved for fields. Warnings will be issued if values are not provided for
67  fields for which transport equations are solved. Warnings will also be
68  issued if values are provided for fields which are not solved for.
69 
70 SourceFiles
71  zeroDimensionalMassSource.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef zeroDimensionalMassSource_H
76 #define zeroDimensionalMassSource_H
77 
78 #include "massSource.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace fv
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class zeroDimensionalMassSourceBase Declaration
89 \*---------------------------------------------------------------------------*/
90 
92 :
93  public massSourceBase
94 {
95 private:
96 
97  // Private Data
98 
99  //- Reference to the zero-dimensional mass
100  volScalarField& m0D_;
101 
102 
103  // Private Member Functions
104 
105  //- Calculate and return the zero-dimensional mass
106  tmp<volScalarField> calcM0D() const;
107 
108  //- Initialise and return a reference to the zero-dimensional mass
109  volScalarField& initM0D() const;
110 
111  //- Get a reference to the mass
112  const volScalarField& m() const;
113 
114  //- Return the zero-dimensional mass flow rate
115  virtual scalar zeroDimensionalMassFlowRate() const = 0;
116 
117  //- Return the mass flow rate
118  virtual scalar massFlowRate() const;
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("zeroDimensionalMassSourceBase");
125 
126 
127  // Constructors
128 
129  //- Construct from explicit source name and mesh
131  (
132  const word& name,
133  const word& modelType,
134  const fvMesh& mesh,
135  const dictionary& dict
136  );
137 
138 
139  // Member Functions
140 
141  //- Update the model
142  virtual void correct();
143 };
144 
145 
146 /*---------------------------------------------------------------------------*\
147  Class zeroDimensionalMassSource Declaration
148 \*---------------------------------------------------------------------------*/
149 
151 :
153 {
154 private:
155 
156  // Private Data
157 
158  //- Zero-dimensional mass flow rate
159  autoPtr<Function1<scalar>> zeroDimensionalMassFlowRate_;
160 
161 
162  // Private Member Functions
163 
164  //- Non-virtual read
165  void readCoeffs();
166 
167  //- Return the zero-dimensional mass flow rate
168  virtual scalar zeroDimensionalMassFlowRate() const;
169 
170 
171 public:
172 
173  //- Runtime type information
174  TypeName("zeroDimensionalMassSource");
175 
176 
177  // Constructors
178 
179  //- Construct from explicit source name and mesh
181  (
182  const word& name,
183  const word& modelType,
184  const fvMesh& mesh,
185  const dictionary& dict
186  );
187 
188 
189  // Member Functions
190 
191  // IO
192 
193  //- Read source dictionary
194  virtual bool read(const dictionary& dict);
195 };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace fv
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
Generic GeometricField class.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:28
zeroDimensionalMassSourceBase(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
TypeName("zeroDimensionalMassSourceBase")
Runtime type information.
This fvModel applies a mass source to the continuity equation and to all field equations,...
virtual bool read(const dictionary &dict)
Read source dictionary.
zeroDimensionalMassSource(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
TypeName("zeroDimensionalMassSource")
Runtime type information.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
labelList fv(nPoints)
dictionary dict