volumeSource.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-2025 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::volumeSource
26 
27 Description
28  This fvModel applies a volume source to the continuity equation and to all
29  field equations. It can be applied to incompressible solvers, such as
30  incompressibleFluid and incompressibleVoF. For compressible solvers, use
31  the massSource model instead.
32 
33  If the volumetric flow rate is positive then user-supplied fixed property
34  values are introduced to the field equations. If the volumetric flow rate
35  is negative then properties are removed at their current value.
36 
37 Usage
38  Example usage:
39  \verbatim
40  volumeSource
41  {
42  type volumeSource;
43 
44  cellZone volumeSource;
45 
46  volumetricFlowRate 1e-4;
47 
48  fieldValues
49  {
50  U (10 0 0);
51  k 0.375;
52  epsilon 14.855;
53  }
54  }
55  \endverbatim
56 
57  If the volumetric flow rate is positive then values should be provided for
58  all solved for fields. Warnings will be issued if values are not provided
59  for fields for which transport equations are solved. Warnings will also be
60  issued if values are provided for fields which are not solved for.
61 
62 SourceFiles
63  volumeSource.C
64 
65 See also
66  Foam::fv::massSource
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #ifndef volumeSource_H
71 #define volumeSource_H
72 
73 #include "fvTotalSource.H"
74 #include "fvCellZone.H"
75 #include "Function1.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 namespace fv
82 {
83 
84 /*---------------------------------------------------------------------------*\
85  Class volumeSource Declaration
86 \*---------------------------------------------------------------------------*/
87 
88 class volumeSource
89 :
90  public fvTotalSource
91 {
92 private:
93 
94  // Private Data
95 
96  //- Name of the volume fraction field (if any)
97  word alphaName_;
98 
99  //- The set of cells the source applies to
100  autoPtr<fvCellZone> setPtr_;
101 
102  //- Volumetric flow rate
103  autoPtr<Function1<scalar>> volumetricFlowRate_;
104 
105 
106  // Private Member Functions
107 
108  //- Non-virtual read
109  void readCoeffs(const dictionary& dict);
110 
111 
112  // Sources
113 
114  //- Add a source term to an equation
115  template<class Type>
116  void addSupType
117  (
118  const VolField<Type>& field,
119  fvMatrix<Type>& eqn
120  ) const;
121 
122  //- Add a source term to a scalar equation
123  void addSupType
124  (
125  const volScalarField& alphaOrField,
126  fvMatrix<scalar>& eqn
127  ) const;
128 
129  //- Add a source term to a compressible equation
130  template<class Type>
131  void addSupType
132  (
133  const volScalarField& alphaOrRho,
134  const VolField<Type>& field,
135  fvMatrix<Type>& eqn
136  ) const;
137 
138  //- Add a source term to a phase equation
139  template<class Type>
140  void addSupType
141  (
142  const volScalarField& alpha,
143  const volScalarField& rho,
144  const VolField<Type>& field,
145  fvMatrix<Type>& eqn
146  ) const;
147 
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("volumeSource");
153 
154 
155  // Constructors
156 
157  //- Construct from explicit source name and mesh
159  (
160  const word& name,
161  const word& modelType,
162  const fvMesh& mesh,
163  const dictionary& dict
164  );
165 
166 
167  // Member Functions
168 
169  // Access
170 
171  //- Return the cellZone that the source applies to
172  virtual const cellZone& zone() const;
173 
174  //- Return the volume of cells that the source applies to
175  virtual scalar V() const;
176 
177 
178  // Sources
179 
180  //- Return the source value
181  virtual dimensionedScalar S() const;
182 
183  //- Add a source term to a field-less proxy equation
184  virtual void addSup(fvMatrix<scalar>& eqn) const;
185 
186  //- Add a source term to an equation
188 
189  //- Add a source term to a compressible equation
191 
192  //- Add a source term to a phase equation
194 
195 
196  // Mesh changes
197 
198  //- Update for mesh motion
199  virtual bool movePoints();
200 
201  //- Update topology using the given map
202  virtual void topoChange(const polyTopoChangeMap&);
203 
204  //- Update from another mesh using the given map
205  virtual void mapMesh(const polyMeshMap&);
206 
207  //- Redistribute or update using the given distribution map
208  virtual void distribute(const polyDistributionMap&);
209 
210 
211  // IO
212 
213  //- Read source dictionary
214  virtual bool read(const dictionary& dict);
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace fv
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
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
Named list of cell indices representing a sub-set of the mesh.
Definition: cellZone.H:61
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
Base class for sources which are specified as a total value (e.g., volume or mass flow rate),...
Definition: fvTotalSource.H:54
This fvModel applies a volume source to the continuity equation and to all field equations....
Definition: volumeSource.H:90
virtual const cellZone & zone() const
Return the cellZone that the source applies to.
Definition: volumeSource.C:233
virtual scalar V() const
Return the volume of cells that the source applies to.
Definition: volumeSource.C:239
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: volumeSource.C:286
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: volumeSource.C:298
virtual bool movePoints()
Add a source term to an equation.
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: volumeSource.C:304
TypeName("volumeSource")
Runtime type information.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: volumeSource.C:292
volumeSource(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: volumeSource.C:215
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: volumeSource.C:256
virtual dimensionedScalar S() const
Return the source value.
Definition: volumeSource.C:245
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
labelList fv(nPoints)
dictionary dict