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-2018 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 of the source specification:
43 
44  \verbatim
45  volumeMode absolute; // specific
46  injectionRateSuSp
47  {
48  k (30.7 0);
49  epsilon (1.5 0);
50  }
51  \endverbatim
52 
53  Valid options for the \c volumeMode entry include:
54  - absolute: values are given as <quantity>
55  - specific: values are given as <quantity>/m3
56 
57 See also
58  Foam::fvOption
59 
60 SourceFiles
61  SemiImplicitSource.C
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef SemiImplicitSource_H
66 #define SemiImplicitSource_H
67 
68 #include "Tuple2.H"
69 #include "cellSetOption.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 namespace fv
76 {
77 
78 // Forward declaration of classes
79 
80 template<class Type>
81 class SemiImplicitSource;
82 
83 
84 // Forward declaration of friend functions
85 
86 template<class Type>
87 Ostream& operator<<
88 (
89  Ostream&,
90  const SemiImplicitSource<Type>&
91 );
92 
93 
94 /*---------------------------------------------------------------------------*\
95  Class SemiImplicitSource Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 template<class Type>
100 :
101  public cellSetOption
102 {
103 public:
104 
105  // Public data
106 
107  //- Enumeration for volume types
108  enum volumeModeType
109  {
110  vmAbsolute,
111  vmSpecific
112  };
113 
114  //- Word list of volume mode type names
115  static const wordList volumeModeTypeNames_;
116 
117 
118 protected:
120  // Protected data
122  //- Volume mode
124 
125  //- Volume normalisation
126  scalar VDash_;
127 
128  //- Source field values
130 
131 
132  // Protected functions
133 
134  //- Helper function to convert from a word to a volumeModeType
135  volumeModeType wordToVolumeModeType(const word& vtName) const;
136 
137  //- Helper function to convert from a volumeModeType to a word
138  word volumeModeTypeToWord(const volumeModeType& vtType) const;
139 
140  //- Set the local field data
141  void setFieldData(const dictionary& dict);
142 
143 
144 public:
145 
146  //- Runtime type information
147  TypeName("SemiImplicitSource");
148 
149 
150  // Constructors
151 
152  //- Construct from components
154  (
155  const word& name,
156  const word& modelType,
157  const dictionary& dict,
158  const fvMesh& mesh
159  );
160 
161 
162  // Member Functions
163 
164  // Access
165 
166  //- Return const access to the volume mode
167  inline const volumeModeType& volumeMode() const;
168 
169  //- Return const access to the source field values
170  inline const List<Tuple2<Type, scalar>>& injectionRate() const;
171 
172 
173  // Edit
174 
175  //- Return access to the volume mode
176  inline volumeModeType& volumeMode();
177 
178  //- Return access to the source field values
180 
181 
182  // Evaluation
183 
184  //- Add explicit contribution to equation
185  virtual void addSup
186  (
187  fvMatrix<Type>& eqn,
188  const label fieldi
189  );
190 
191  //- Add explicit contribution to compressible equation
192  virtual void addSup
193  (
194  const volScalarField& rho,
195  fvMatrix<Type>& eqn,
196  const label fieldi
197  );
198 
199 
200  // IO
201 
202  //- Read source dictionary
203  virtual bool read(const dictionary& dict);
204 };
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 } // End namespace fv
210 } // End namespace Foam
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #ifdef NoRepository
215  #include "SemiImplicitSource.C"
216  #include "SemiImplicitSourceIO.C"
217 #endif
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #include "SemiImplicitSourceI.H"
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************************************************************* //
volumeModeType wordToVolumeModeType(const word &vtName) const
Helper function to convert from a word to a volumeModeType.
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
volumeModeType volumeMode_
Volume mode.
virtual bool read(const dictionary &dict)
Read source dictionary.
static const wordList volumeModeTypeNames_
Word list of volume mode type names.
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
TypeName("SemiImplicitSource")
Runtime type information.
List< Tuple2< Type, scalar > > injectionRate_
Source field values.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
scalar VDash_
Volume normalisation.
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
word volumeModeTypeToWord(const volumeModeType &vtType) const
Helper function to convert from a volumeModeType to a word.
const volumeModeType & volumeMode() const
Return const access to the volume mode.
volumeModeType
Enumeration for volume types.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void addSup(fvMatrix< Type > &eqn, const label fieldi)
Add explicit contribution to equation.
Cell-set options abtract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:69
Semi-implicit source, described using an input dictionary. The injection rate coefficients are specif...
SemiImplicitSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
void setFieldData(const dictionary &dict)
Set the local field data.
const List< Tuple2< Type, scalar > > & injectionRate() const
Return const access to the source field values.
Namespace for OpenFOAM.