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