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-2022 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 "unknownTypeFunction1.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
108 
109 
110  // Private Member Functions
111 
112  //- Non-virtual read
113  void readCoeffs();
114 
115 
116  // Sources
117 
118  //- Add a source term to an equation
119  template<class Type>
120  void addGeneralSupType
121  (
122  fvMatrix<Type>& eqn,
123  const word& fieldName
124  ) const;
125 
126  //- Add a source term to an equation
127  template<class Type>
128  void addSupType(fvMatrix<Type>& eqn, const word& fieldName) const;
129 
130  //- Add a source term to a scalar equation
131  void addSupType(fvMatrix<scalar>& eqn, const word& fieldName) const;
132 
133  //- Add a source term to a compressible equation
134  template<class Type>
135  void addSupType
136  (
137  const volScalarField& rho,
138  fvMatrix<Type>& eqn,
139  const word& fieldName
140  ) const;
141 
142  //- Add a source term to a phase equation
143  template<class Type>
144  void addSupType
145  (
146  const volScalarField& alpha,
147  const volScalarField& rho,
148  fvMatrix<Type>& eqn,
149  const word& fieldName
150  ) const;
151 
152 
153 public:
154 
155  //- Runtime type information
156  TypeName("massSource");
157 
158 
159  // Constructors
160 
161  //- Construct from explicit source name and mesh
162  massSource
163  (
164  const word& name,
165  const word& modelType,
166  const dictionary& dict,
167  const fvMesh& mesh
168  );
169 
170  //- Disallow default bitwise copy construction
171  massSource(const massSource&) = delete;
172 
173 
174  // Member Functions
175 
176  // Access
177 
178  //- Return the name of the density field
179  const word& rhoName() const
180  {
181  return rhoName_;
182  }
183 
184 
185  // Checks
186 
187  //- Return true if the fvModel adds a source term to the given
188  // field's transport equation
189  virtual bool addsSupToField(const word& fieldName) const;
190 
191  //- Return the list of fields for which the fvModel adds source term
192  // to the transport equation
193  virtual wordList addSupFields() const;
194 
195 
196  // Sources
197 
198  //- Add a source term to an equation
200 
201  //- Add a source term to a compressible equation
203 
204  //- Add a source term to a phase equation
206 
207 
208  // Mesh changes
209 
210  //- Update for mesh motion
211  virtual bool movePoints();
212 
213  //- Update topology using the given map
214  virtual void topoChange(const polyTopoChangeMap&);
215 
216  //- Update from another mesh using the given map
217  virtual void mapMesh(const polyMeshMap&);
218 
219  //- Redistribute or update using the given distribution map
220  virtual void distribute(const polyDistributionMap&);
221 
222 
223  // IO
224 
225  //- Read source dictionary
226  virtual bool read(const dictionary& dict);
227 
228 
229  // Member Operators
230 
231  //- Disallow default bitwise assignment
232  void operator=(const massSource&) = delete;
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace fv
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
dictionary dict
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: massSource.C:277
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: massSource.C:283
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
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:178
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:57
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
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)
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
massSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: massSource.C:203
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:248
virtual bool addsSupToField(const word &fieldName) const
Return true if the fvModel adds a source term to the given.
Definition: massSource.C:225
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: massSource.C:289
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
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 movePoints()
Update for mesh motion.
Definition: massSource.C:270
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: massSource.C:295
This fvModel applies a mass source to the continuity equation and to all field equations.
Definition: massSource.H:81
Namespace for OpenFOAM.