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-2026 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 Data
93 
94  //- Name of the volume fraction field (if any)
95  word alphaName_;
96 
97  //- The set of cells the source applies to
98  mutable fvCellZone zone_;
99 
100  //- Volumetric flow rate
101  autoPtr<Function1<scalar>> volumetricFlowRate_;
102 
103 
104  // Private Member Functions
105 
106  //- Non-virtual read
107  void readCoeffs(const dictionary& dict);
108 
109 
110  // Sources
111 
112  //- Add a source term to an equation
113  template<class Type>
114  void addSupType
115  (
116  const VolField<Type>& field,
117  fvMatrix<Type>& eqn
118  ) const;
119 
120  //- Add a source term to a scalar equation
121  void addSupType
122  (
123  const volScalarField& alphaOrField,
124  fvMatrix<scalar>& eqn
125  ) const;
126 
127  //- Add a source term to a compressible equation
128  template<class Type>
129  void addSupType
130  (
131  const volScalarField& alphaOrRho,
132  const VolField<Type>& field,
133  fvMatrix<Type>& eqn
134  ) const;
135 
136  //- Add a source term to a phase equation
137  template<class Type>
138  void addSupType
139  (
140  const volScalarField& alpha,
141  const volScalarField& rho,
142  const VolField<Type>& field,
143  fvMatrix<Type>& eqn
144  ) const;
145 
146 
147 public:
148 
149  //- Runtime type information
150  TypeName("volumeSource");
151 
152 
153  // Constructors
154 
155  //- Construct from explicit source name and mesh
157  (
158  const word& name,
159  const word& modelType,
160  const fvMesh& mesh,
161  const dictionary& dict
162  );
163 
164 
165  // Member Functions
166 
167  // Access
168 
169  //- Return the cellZone that the source applies to
170  virtual const cellZone& zone() const;
171 
172  //- Return the volume of cells that the source applies to
173  virtual scalar V() const;
174 
175 
176  // Sources
177 
178  //- Return the source value
179  virtual dimensionedScalar S() const;
180 
181  //- Add a source term to a field-less proxy equation
182  virtual void addSup(fvMatrix<scalar>& eqn) const;
183 
184  //- Add a source term to an equation
186 
187  //- Add a source term to a compressible equation
189 
190  //- Add a source term to a phase equation
192 
193 
194  // Mesh changes
195 
196  //- Update for mesh motion
197  virtual bool movePoints();
198 
199  //- Update topology using the given map
200  virtual void topoChange(const polyTopoChangeMap&);
201 
202  //- Update from another mesh using the given map
203  virtual void mapMesh(const polyMeshMap&);
204 
205  //- Redistribute or update using the given distribution map
206  virtual void distribute(const polyDistributionMap&);
207 
208 
209  // IO
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 #endif
224 
225 // ************************************************************************* //
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
cellZone selection or generation class with caching of zone volume
Definition: fvCellZone.H:94
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:98
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:63
#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
rho
Definition: pEqn.H:1
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(makeDimensionedPointFieldFunctions)
labelList fv(nPoints)
dictionary dict