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-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::massSource
26 
27 Description
28  This fvModel applies a mass source to the continuity equation and to all
29  field equations. It can be applied to compressible solvers, such as fluid,
30  isothermalFluid, compressibleVoF and multiphaseEuler. For incompressible
31  solvers, use the volumeSource model instead.
32 
33  This model requires a corresponding field source to be specified for all
34  solved-for fields.
35 
36 Usage
37  Example usage for a constant mass flow rate applied to a cell set:
38  \verbatim
39  massSource
40  {
41  type massSource;
42 
43  cellZone massSource;
44 
45  massFlowRate 1e-4;
46  }
47  \endverbatim
48 
49  Example usage for a pulsing flow rate applied at a point:
50  \verbatim
51  massSource
52  {
53  type massSource;
54 
55  cellZone
56  {
57  type containsPoints;
58  points ((2.75 0.5 0));
59  }
60 
61  massFlowRate
62  {
63  type scale;
64  scale squarePulse;
65  start 0.2;
66  duration 2;
67  value 1e-4;
68  }
69  }
70  \endverbatim
71 
72 SourceFiles
73  massSource.C
74 
75 See also
76  Foam::fv::volumeSource
77 
78 \*---------------------------------------------------------------------------*/
79 
80 #ifndef massSource_H
81 #define massSource_H
82 
83 #include "massSourceBase.H"
84 #include "fvCellZone.H"
85 #include "Function1.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 namespace fv
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class massSource Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 class massSource
99 :
100  public massSourceBase
101 {
102  // Private Data
103 
104  //- The cellZone the source applies to
105  mutable fvCellZone zone_;
106 
107  //- Mass flow rate
108  autoPtr<Function1<scalar>> massFlowRate_;
109 
110 
111  // Private Member Functions
112 
113  //- Non-virtual read
114  void readCoeffs(const dictionary& dict);
115 
116 
117 public:
118 
119  //- Runtime type information
120  TypeName("massSource");
121 
122 
123  // Constructors
124 
125  //- Construct from explicit source name and mesh
126  massSource
127  (
128  const word& name,
129  const word& modelType,
130  const fvMesh& mesh,
131  const dictionary& dict
132  );
133 
134 
135  // Member Functions
136 
137  // Access
138 
139  //- Return the cellZone that the source applies to
140  virtual const cellZone& zone() const;
141 
142  //- Return the volume of cells that the source applies to
143  virtual scalar V() const;
144 
145 
146  // Sources
147 
148  //- Return the source value
149  virtual dimensionedScalar S() const;
150 
151 
152  // Mesh changes
153 
154  //- Update for mesh motion
155  virtual bool movePoints();
156 
157  //- Update topology using the given map
158  virtual void topoChange(const polyTopoChangeMap&);
159 
160  //- Update from another mesh using the given map
161  virtual void mapMesh(const polyMeshMap&);
162 
163  //- Redistribute or update using the given distribution map
164  virtual void distribute(const polyDistributionMap&);
165 
166 
167  //- Read source dictionary
168  virtual bool read(const dictionary& dict);
169 };
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 } // End namespace fv
175 } // End namespace Foam
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #endif
180 
181 // ************************************************************************* //
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
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 mass source models.
This fvModel applies a mass source to the continuity equation and to all field equations....
Definition: massSource.H:100
virtual bool movePoints()
Update for mesh motion.
Definition: massSource.C:104
virtual const cellZone & zone() const
Return the cellZone that the source applies to.
Definition: massSource.C:81
virtual scalar V() const
Return the volume of cells that the source applies to.
Definition: massSource.C:87
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: massSource.C:111
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: massSource.C:123
TypeName("massSource")
Runtime type information.
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: massSource.C:129
massSource(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from explicit source name and mesh.
Definition: massSource.C:64
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: massSource.C:117
virtual dimensionedScalar S() const
Return the source value.
Definition: massSource.C:93
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
Namespace for OpenFOAM.
labelList fv(nPoints)
dictionary dict