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-2021 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 fvModels 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::fvModel
86 
87 SourceFiles
88  semiImplicitSource.C
89 
90 \*---------------------------------------------------------------------------*/
91 
92 #ifndef semiImplicitSource_H
93 #define semiImplicitSource_H
94 
95 #include "fvModel.H"
96 #include "fvCellSet.H"
97 #include "HashPtrTable.H"
98 #include "objectFunction1.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 namespace Foam
103 {
104 namespace fv
105 {
106 
107 /*---------------------------------------------------------------------------*\
108  Class semiImplicitSource Declaration
109 \*---------------------------------------------------------------------------*/
110 
111 class semiImplicitSource
112 :
113  public fvModel
114 {
115 public:
116 
117  // Public data
118 
119  //- Enumeration for volume types
120  enum class volumeMode
121  {
123  specific
124  };
125 
126  //- Property type names
128 
129 
130 private:
132  // Private member data
133 
134  //- The set of cells the fvConstraint applies to
135  fvCellSet set_;
136 
137  //- Volume mode
138  volumeMode volumeMode_;
139 
140  //- Volume normalisation
141  scalar VDash_;
142 
143  //- Explicit parts of the sources
145 
146  //- Implicit parts of the sources
148 
149 
150  // Private Member Functions
151 
152  //- Non-virtual read
153  void readCoeffs();
154 
155 
156  // Sources
157 
158  //- Add a source term to an equation
159  template <class Type>
160  void addSupType(fvMatrix<Type>& eqn, const word& fieldName) const;
161 
162  //- Add a source term to a compressible equation
163  template <class Type>
164  void addSupType
165  (
166  const volScalarField& rho,
167  fvMatrix<Type>& eqn,
168  const word& fieldName
169  ) const;
170 
171  //- Add a source term to a phase equation
172  template <class Type>
173  void addSupType
174  (
175  const volScalarField& alpha,
176  const volScalarField& rho,
177  fvMatrix<Type>& eqn,
178  const word& fieldName
179  ) const;
180 
181 
182 public:
183 
184  //- Runtime type information
185  TypeName("semiImplicitSource");
186 
187 
188  // Constructors
189 
190  //- Construct from components
192  (
193  const word& name,
194  const word& modelType,
195  const dictionary& dict,
196  const fvMesh& mesh
197  );
198 
199  //- Destructor
200  virtual ~semiImplicitSource();
201 
202 
203  // Member Functions
204 
205  // Checks
206 
207  //- Return the list of fields for which the fvModel adds source term
208  // to the transport equation
209  virtual wordList addSupFields() const;
210 
211 
212  // Sources
213 
214  //- Add a source term to an equation
216 
217  //- Add a source term to a compressible equation
219 
220  //- Add a source term to a phase equation
222 
223 
224  // Mesh motion
225 
226  //- Update for mesh changes
227  virtual void updateMesh(const mapPolyMesh&);
228 
229 
230  // IO
231 
232  //- Read source dictionary
233  virtual bool read(const dictionary& dict);
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace fv
240 } // End namespace Foam
241 
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #endif
246 
247 // ************************************************************************* //
dictionary dict
FOR_ALL_FIELD_TYPES(DEFINE_FV_MODEL_ADD_SUP)
Add a source term to an equation.
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:28
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define DEFINE_FV_MODEL_ADD_SUP(Type, nullArg)
Definition: fvModelM.H:26
Cell-set fvConstraint abstract base class. Provides a base set of controls regarding the location whe...
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
#define DEFINE_FV_MODEL_ADD_ALPHA_RHO_SUP(Type, nullArg)
Definition: fvModelM.H:62
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:50
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
semiImplicitSource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual bool read(const dictionary &dict)
Read source dictionary.
A class for handling words, derived from string.
Definition: word.H:59
#define DEFINE_FV_MODEL_ADD_RHO_SUP(Type, nullArg)
Definition: fvModelM.H:43
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
TypeName("semiImplicitSource")
Runtime type information.
static const NamedEnum< volumeMode, 2 > volumeModeNames_
Property type names.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
volumeMode
Enumeration for volume types.
virtual ~semiImplicitSource()
Destructor.
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Namespace for OpenFOAM.