semiImplicitSource.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) 2011-2020 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::semiImplicitSource
26 
27 Description
28  Semi-implicit source, described using an input dictionary. The injection
29  rate coefficients are specified as pairs of Su-Sp coefficients, i.e.
30 
31  \f[
32  S(x) = S_u + S_p x
33  \f]
34 
35  where
36  \vartable
37  S(x) | net source for field 'x'
38  S_u | explicit source contribution
39  S_p | linearised implicit contribution
40  \endvartable
41 
42  Example tabulated heat source specification for internal energy:
43  \verbatim
44  volumeMode absolute; // specific
45  sources
46  {
47  e
48  {
49  explicit table ((0 0) (1.5 $power));
50  implicit 0;
51  }
52  }
53  \endverbatim
54 
55  Example coded heat source specification for enthalpy:
56  \verbatim
57  volumeMode absolute; // specific
58  sources
59  {
60  h
61  {
62  explicit
63  {
64  type coded;
65  name heatInjection;
66  code
67  #{
68  // Power amplitude
69  const scalar powerAmplitude = 1000;
70 
71  // x is the current time
72  return mag(powerAmplitude*sin(x));
73  #};
74  }
75  implicit 0;
76  }
77  }
78  \endverbatim
79 
80  Valid options for the \c volumeMode entry include:
81  - absolute: values are given as <quantity>
82  - specific: values are given as <quantity>/m3
83 
84 See also
85  Foam::fvOption
86 
87 SourceFiles
88  semiImplicitSource.C
89 
90 \*---------------------------------------------------------------------------*/
91 
92 #ifndef semiImplicitSource_H
93 #define semiImplicitSource_H
94 
95 #include "cellSetOption.H"
96 #include "Function1.H"
97 #include "objectFunction1.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 namespace fv
104 {
105 
106 /*---------------------------------------------------------------------------*\
107  Class semiImplicitSource Declaration
108 \*---------------------------------------------------------------------------*/
109 
110 class semiImplicitSource
111 :
112  public cellSetOption
113 {
114 public:
115 
116  // Public data
117 
118  //- Enumeration for volume types
119  enum class volumeMode
120  {
122  specific
123  };
124 
125  //- Property type names
127 
128 
129 private:
131  // Private member data
132 
133  //- Volume mode
134  volumeMode volumeMode_;
135 
136  //- Volume normalisation
137  scalar VDash_;
138 
139  //- Explicit parts of the sources
140  PtrList<objectFunction1> fieldSu_;
141 
142  //- Implicit parts of the sources
143  PtrList<Function1<scalar>> fieldSp_;
144 
145 
146  // Private Member Functions
147 
148  //- Add divergence terms to an equation
149  template <class Type>
150  void addSupType(fvMatrix<Type>&, const label);
151 
152  //- Add divergence terms to an equation
153  template <class Type>
154  void addSupType(const volScalarField&, fvMatrix<Type>&, const label);
155 
156 
157 public:
158 
159  //- Runtime type information
160  TypeName("semiImplicitSource");
161 
162 
163  // Constructors
164 
165  //- Construct from components
167  (
168  const word& name,
169  const word& modelType,
170  const dictionary& dict,
171  const fvMesh& mesh
172  );
173 
174  //- Destructor
175  virtual ~semiImplicitSource();
176 
177 
178  // Member Functions
179 
180  // Evaluation
181 
182  // Explicit and implicit sources
183 
184  virtual void addSup
185  (
186  fvMatrix<scalar>& eqn,
187  const label fieldi
188  );
189 
190  virtual void addSup
191  (
192  fvMatrix<vector>& eqn,
193  const label fieldi
194  );
195 
196  virtual void addSup
197  (
199  const label fieldi
200  );
201 
202  virtual void addSup
203  (
205  const label fieldi
206  );
207 
208  virtual void addSup
209  (
210  fvMatrix<tensor>& eqn,
211  const label fieldi
212  );
213 
214 
215  // Explicit and implicit sources for compressible equations
216 
217  virtual void addSup
218  (
219  const volScalarField& rho,
220  fvMatrix<scalar>& eqn,
221  const label fieldi
222  );
223 
224  virtual void addSup
225  (
226  const volScalarField& rho,
227  fvMatrix<vector>& eqn,
228  const label fieldi
229  );
230 
231  virtual void addSup
232  (
233  const volScalarField& rho,
235  const label fieldi
236  );
237 
238  virtual void addSup
239  (
240  const volScalarField& rho,
242  const label fieldi
243  );
244 
245  virtual void addSup
246  (
247  const volScalarField& rho,
248  fvMatrix<tensor>& eqn,
249  const label fieldi
250  );
251 
252 
253  // Explicit and implicit sources for phase equations
254 
255  virtual void addSup
256  (
257  const volScalarField& alpha,
258  const volScalarField& rho,
259  fvMatrix<scalar>& eqn,
260  const label fieldi
261  );
262 
263  virtual void addSup
264  (
265  const volScalarField& alpha,
266  const volScalarField& rho,
267  fvMatrix<vector>& eqn,
268  const label fieldi
269  );
270 
271  virtual void addSup
272  (
273  const volScalarField& alpha,
274  const volScalarField& rho,
276  const label fieldi
277  );
278 
279  virtual void addSup
280  (
281  const volScalarField& alpha,
282  const volScalarField& rho,
284  const label fieldi
285  );
286 
287  virtual void addSup
288  (
289  const volScalarField& alpha,
290  const volScalarField& rho,
291  fvMatrix<tensor>& eqn,
292  const label fieldi
293  );
294 
295 
296  // IO
297 
298  //- Read source dictionary
299  virtual bool read(const dictionary& dict);
300 };
301 
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 } // End namespace fv
306 } // End namespace Foam
307 
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #endif
312 
313 // ************************************************************************* //
dictionary dict
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
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
semiImplicitSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
virtual bool read(const dictionary &dict)
Read source dictionary.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
const word & name() const
Return const access to the source name.
Definition: fvOptionI.H:28
TypeName("semiImplicitSource")
Runtime type information.
static const NamedEnum< volumeMode, 2 > volumeModeNames_
Property type names.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
volumeMode
Enumeration for volume types.
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
virtual ~semiImplicitSource()
Destructor.
Namespace for OpenFOAM.