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-2024 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  select cellSet;
45  cellSet volumeSource;
46 
47  volumetricFlowRate 1e-4;
48 
49  fieldValues
50  {
51  U (10 0 0);
52  k 0.375;
53  epsilon 14.855;
54  }
55  }
56  \endverbatim
57 
58  If the volumetric flow rate is positive then values should be provided for
59  all solved for fields. Warnings will be issued if values are not provided
60  for fields for which transport equations are solved. Warnings will also be
61  issued if values are provided for fields which are not solved for.
62 
63 SourceFiles
64  volumeSource.C
65 
66 See also
67  Foam::fv::massSource
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef volumeSource_H
72 #define volumeSource_H
73 
74 #include "fvTotalSource.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<fvCellSet> 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();
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 cells that the source applies to
172  virtual labelUList cells() const;
173 
174  //- Return the number of cells that the source applies to
175  virtual label nCells() const;
176 
177  //- Return the volume of cells that the source applies to
178  virtual scalar V() const;
179 
180 
181  // Sources
182 
183  //- Return the source value
184  virtual dimensionedScalar S() const;
185 
186  //- Add a source term to a field-less proxy equation
187  virtual void addSup(fvMatrix<scalar>& eqn) const;
188 
189  //- Add a source term to an equation
191 
192  //- Add a source term to a compressible equation
194 
195  //- Add a source term to a phase equation
197 
198 
199  // Mesh changes
200 
201  //- Update for mesh motion
202  virtual bool movePoints();
203 
204  //- Update topology using the given map
205  virtual void topoChange(const polyTopoChangeMap&);
206 
207  //- Update from another mesh using the given map
208  virtual void mapMesh(const polyMeshMap&);
209 
210  //- Redistribute or update using the given distribution map
211  virtual void distribute(const polyDistributionMap&);
212 
213 
214  // IO
215 
216  //- Read source dictionary
217  virtual bool read(const dictionary& dict);
218 };
219 
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 } // End namespace fv
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #endif
229 
230 // ************************************************************************* //
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: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:99
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:53
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:47
Base class for sources which are specified as a total value (e.g., volume or mass flow rate),...
Definition: fvTotalSource.H:55
This fvModel applies a volume source to the continuity equation and to all field equations....
Definition: volumeSource.H:90
virtual scalar V() const
Return the volume of cells that the source applies to.
Definition: volumeSource.C:245
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: volumeSource.C:292
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: volumeSource.C:304
virtual bool movePoints()
Add a source term to an equation.
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: volumeSource.C:310
virtual labelUList cells() const
Return the cells that the source applies to.
Definition: volumeSource.C:233
TypeName("volumeSource")
Runtime type information.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: volumeSource.C:298
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 label nCells() const
Return the number of cells that the source applies to.
Definition: volumeSource.C:239
virtual void addSup(fvMatrix< scalar > &eqn) const
Add a source term to a field-less proxy equation.
Definition: volumeSource.C:262
virtual dimensionedScalar S() const
Return the source value.
Definition: volumeSource.C:251
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
labelList fv(nPoints)
dictionary dict