SemiImplicitSource.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2020-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::fv::SemiImplicitSource
29
30Group
31 grpFvOptionsSources
32
33Description
34 Applies semi-implicit source within a specified region for \c Type,
35 where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
36 The source rate coefficients are specified
37 as pairs of Su-Sp coefficients, i.e.:
38
39 \f[
40 S(x) = S_u + S_p x
41 \f]
42
43 where
44 \vartable
45 S(x) | net source for field 'x'
46 S_u | explicit source contribution
47 S_p | linearised implicit contribution
48 \endvartable
49
50Usage
51 Minimal example by using \c constant/fvOptions:
52 \verbatim
53 <Type>SemiImplicitSource1
54 {
55 // Mandatory entries (unmodifiable)
56 type <Type>SemiImplicitSource;
57
58 // Mandatory entries (runtime modifiable)
59 volumeMode <volumeModeType>;
60
61 // Specification of sources (OpenFOAM-2206 and newer)
62 sources
63 {
64 // Specified as explicit(Su)/implicit(Sp) tuple:
65 k (30.7 0);
66 epsilon (1.5 0);
67
68 // Specified as Function1 or exprField
69 k
70 {
71 // Time-ramp from 0 to 30.7 at time 5
72 explicit table ((0 0) (5 30.7));
73 implicit none;
74 }
75 epsilon
76 {
77 explicit
78 {
79 type exprField:
80 expression "(mag(pos()) < 0.1) ? 1.5 : 0";
81 }
82 }
83 }
84
85 // Traditional specification of sources (OpenFOAM-2112 and older)
86 injectionRateSuSp
87 {
88 // Specified as explicit(Su)/implicit(Sp) tuple:
89 k (30.7 0);
90 epsilon (1.5 0);
91
92 // Specified as Function1
93 k
94 {
95 // Time-ramp from 0 to 30.7 at time 5
96 Su table ((0 0) (5 30.7));
97 Sp 0;
98 }
99 epsilon
100 {
101 Su 1.5;
102 Sp 0;
103 }
104 }
105
106 // Mandatory/Optional (inherited) entries
107 ...
108 }
109 \endverbatim
110
111 where the entries mean:
112 \table
113 Property | Description | Type | Reqd | Dflt
114 type | Type name: <Type>SemiImplicitSource <!--
115 --> | word | yes | -
116 volumeMode | Volume mode type | word | yes | -
117 sources | Explicit/implicit sources | dict | cndtnl | -
118 injectionRateSuSp | Explicit/implicit sources | dict | cndtnl | -
119 \endtable
120
121 The inherited entries are elaborated in:
122 - \link fvOption.H \endlink
123 - \link cellSetOption.H \endlink
124
125 Options for the \c volumeMode entry:
126 \verbatim
127 absolute | Values are given as <quantity>
128 specific | Values are given as <quantity>/m3
129 \endverbatim
130
131Note
132 Missing explicit/implicit, Su/Sp entries are equivalent to constant values
133 of zero. However, at one entry must be supplied for the source terms.
134
135Note
136 To use the \c exprField (expression fields) handling, the \em sources
137 dictionary form must be used.
138
139See also
140 - Foam::fvOption
141
142SourceFiles
143 SemiImplicitSource.C
144
145\*---------------------------------------------------------------------------*/
146
147#ifndef Foam_SemiImplicitSource_H
148#define Foam_SemiImplicitSource_H
149
150#include "cellSetOption.H"
151#include "Enum.H"
152#include "Function1.H"
153#include "HashPtrTable.H"
154#include "volumeExprDriver.H"
155
156// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157
158namespace Foam
159{
160namespace fv
161{
162
163/*---------------------------------------------------------------------------*\
164 Class SemiImplicitSource Declaration
165\*---------------------------------------------------------------------------*/
166
167template<class Type>
168class SemiImplicitSource
169:
170 public fv::cellSetOption
171{
172public:
173
174 // Public Enumerations
175
176 //- Options for the volume mode type
177 enum volumeModeType
178 {
181 };
182
183 //- Names for volumeModeType
184 static const Enum<volumeModeType> volumeModeTypeNames_;
185
186
187private:
188
189 // Private Data
190
191 //- Volume mode
192 volumeModeType volumeMode_;
193
194 //- Volume normalisation
195 scalar VDash_;
196
197 //- Explicit source contributions
198 HashPtrTable<Function1<Type>> Su_;
199
200 //- Linearised implicit contributions
201 HashPtrTable<Function1<scalar>> Sp_;
202
203 //- Expression to evaluate for explicit source contribution
204 HashTable<expressions::exprString> valueExprSu_;
205
206 //- Expression to evaluate for linearised implicit contribution
207 HashTable<expressions::exprString> valueExprSp_;
208
209 //- Expression driver for explicit sources
210 HashPtrTable<expressions::volumeExprDriver> driverSu_;
212 //- Expression driver for implicit sources
214
215
216 // Private Member Functions
217
218 //- Set the source coefficients from "sources" (explicit/implicit)
219 //- or from "injectionRateSuSp" (Su/Sp)
220 void setFieldCoeffs
221 (
223 const word& keyExplicit,
224 const word& keyImplicit
225 );
226
228public:
229
230 //- Runtime type information
231 TypeName("SemiImplicitSource");
232
233
234 // Constructors
235
236 //- Construct from components
238 (
239 const word& name,
240 const word& modelType,
241 const dictionary& dict,
242 const fvMesh& mesh
243 );
244
245
246 // Member Functions
247
248 // Access
249
250 //- The volume mode
252 {
253 return volumeMode_;
254 }
255
256
257 // Edit
258
259 //- Modifiable access to the volume mode
261 {
262 return volumeMode_;
263 }
264
265
266 // Evaluation
267
268 //- Add explicit contribution to incompressible equation
269 virtual void addSup
270 (
271 fvMatrix<Type>& eqn,
272 const label fieldi
273 );
275 //- Add explicit contribution to compressible equation
276 virtual void addSup
277 (
278 const volScalarField& rho,
279 fvMatrix<Type>& eqn,
280 const label fieldi
281 );
282
283
284 // IO
285
286 //- Read source dictionary
287 virtual bool read(const dictionary& dict);
288};
289
290
291// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292
293} // End namespace fv
294} // End namespace Foam
295
296// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
297
298#ifdef NoRepository
299 #include "SemiImplicitSource.C"
300#endif
301
302// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304#endif
305
306// ************************************************************************* //
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
Definition: HashPtrTable.H:68
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Applies semi-implicit source within a specified region for Type, where <Type>=Scalar/Vector/Spherical...
volumeModeType & volumeMode() noexcept
Modifiable access to the volume mode.
volumeModeType volumeMode() const noexcept
The volume mode.
virtual void addSup(fvMatrix< Type > &eqn, const label fieldi)
Add explicit contribution to incompressible equation.
static const Enum< volumeModeType > volumeModeTypeNames_
Names for volumeModeType.
virtual bool read(const dictionary &dict)
Read source dictionary.
TypeName("SemiImplicitSource")
Runtime type information.
volumeModeType
Options for the volume mode type.
Intermediate abstract class for handling cell-set options for the derived fvOptions.
const word & name() const noexcept
Return const access to the source name.
Definition: fvOptionI.H:31
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
const direction noexcept
Definition: Scalar.H:223
labelList fv(nPoints)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73