massSource.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 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::massSource
26 
27 Description
28  This fvModel applies a mass source to the continuity equation and to all
29  field equations.
30 
31 Usage
32  Example usage:
33  \verbatim
34  massSource
35  {
36  type massSource;
37 
38  selectionMode cellSet;
39  cellSet massSource;
40 
41  massFlowRate 1e-4;
42 
43  fieldValues
44  {
45  U (10 0 0);
46  T 300;
47  k 0.375;
48  epsilon 14.855;
49  }
50  }
51  \endverbatim
52 
53  Values should be provided for all solved for fields. Warnings will be
54  issued if values are not provided for fields for which transport equations
55  are solved. Warnings will also be issued if values are provided for fields
56  which are not solved for.
57 
58 SourceFiles
59  massSource.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef massSource_H
64 #define massSource_H
65 
66 #include "fvModel.H"
67 #include "fvCellSet.H"
68 #include "HashPtrTable.H"
69 #include "objectFunction1.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 namespace fv
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class massSource Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 class massSource
83 :
84  public fvModel
85 {
86  // Private Data
87 
88  //- The set of cells the fvConstraint applies to
89  fvCellSet set_;
90 
91  //- Name of the phase
92  word phaseName_;
93 
94  //- Name of the density field
95  word rhoName_;
96 
97  //- Name of the energy field
98  word heName_;
99 
100  //- Name of the temperature field
101  word TName_;
102 
103  //- Mass source
104  autoPtr<Function1<scalar>> massFlowRate_;
105 
106  //- Field values
107  HashPtrTable<objectFunction1> fieldValues_;
108 
109 
110  // Private Member Functions
111 
112  //- Non-virtual read
113  void readCoeffs();
114 
115  //- Read field values for a given primitive type
116  template<class Type>
117  void readFieldValues();
118 
119 
120  // Sources
121 
122  //- Add a source term to an equation
123  template<class Type>
124  void addGeneralSupType
125  (
126  fvMatrix<Type>& eqn,
127  const word& fieldName
128  ) const;
129 
130  //- Add a source term to an equation
131  template<class Type>
132  void addSupType(fvMatrix<Type>& eqn, const word& fieldName) const;
133 
134  //- Add a source term to a scalar equation
135  void addSupType(fvMatrix<scalar>& eqn, const word& fieldName) const;
136 
137  //- Add a source term to a compressible equation
138  template<class Type>
139  void addSupType
140  (
141  const volScalarField& rho,
142  fvMatrix<Type>& eqn,
143  const word& fieldName
144  ) const;
145 
146  //- Add a source term to a phase equation
147  template<class Type>
148  void addSupType
149  (
150  const volScalarField& alpha,
151  const volScalarField& rho,
152  fvMatrix<Type>& eqn,
153  const word& fieldName
154  ) const;
155 
156 
157 public:
158 
159  //- Runtime type information
160  TypeName("massSource");
161 
162 
163  // Constructors
164 
165  //- Construct from explicit source name and mesh
166  massSource
167  (
168  const word& name,
169  const word& modelType,
170  const dictionary& dict,
171  const fvMesh& mesh
172  );
173 
174  //- Disallow default bitwise copy construction
175  massSource(const massSource&) = delete;
176 
177 
178  // Member Functions
179 
180  // Access
181 
182  //- Return the name of the density field
183  const word& rhoName() const
184  {
185  return rhoName_;
186  }
187 
188 
189  // Checks
190 
191  //- Return true if the fvModel adds a source term to the given
192  // field's transport equation
193  virtual bool addsSupToField(const word& fieldName) const;
194 
195  //- Return the list of fields for which the fvModel adds source term
196  // to the transport equation
197  virtual wordList addSupFields() const;
198 
199 
200  // Sources
201 
202  //- Add a source term to an equation
204 
205  //- Add a source term to a compressible equation
207 
208  //- Add a source term to a phase equation
210 
211 
212  // Mesh motion
213 
214  //- Update for mesh changes
215  virtual void updateMesh(const mapPolyMesh&);
216 
217 
218  // IO
219 
220  //- Read source dictionary
221  virtual bool read(const dictionary& dict);
222 
223 
224  // Member Operators
225 
226  //- Disallow default bitwise assignment
227  void operator=(const massSource&) = delete;
228 };
229 
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 } // End namespace fv
234 } // End namespace Foam
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
dictionary dict
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:28
const word & rhoName() const
Return the name of the density field.
Definition: massSource.H:182
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define DEFINE_FV_MODEL_ADD_SUP(Type, nullArg)
Definition: fvModelM.H:26
Cell-set fvConstraint abstract base class. Provides a base set of controls regarding the location whe...
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
#define DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP(Type, nullArg)
Definition: fvModelM.H:62
TypeName("massSource")
Runtime type information.
Finite volume model abstract base class.
Definition: fvModel.H:55
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:50
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
void operator=(const massSource &)=delete
Disallow default bitwise assignment.
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP)
Add a source term to an equation.
A class for handling words, derived from string.
Definition: word.H:59
#define DEFINE_FV_MODEL_ADD_RHO_SUP(Type, nullArg)
Definition: fvModelM.H:43
labelList fv(nPoints)
massSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: massSource.C:230
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: massSource.C:275
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Definition: massSource.C:252
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
Definition: massSource.C:297
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: massSource.C:303
This fvModel applies a mass source to the continuity equation and to all field equations.
Definition: massSource.H:81
Namespace for OpenFOAM.