fvOption.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 | Copyright (C) 2011-2017 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::option
26 
27 Description
28  Finite volume options abstract base class. Provides a base set of
29  controls, e.g.:
30  \verbatim
31  type scalarExplicitSource // source type
32  active on; // on/off switch
33  \endverbatim
34 
35 Note
36  On evaluation, source/sink options are to be added to the equation R.H.S.
37 
38 SourceFiles
39  fvOption.C
40  fvOptionIO.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef fvOption_H
45 #define fvOption_H
46 
47 #include "fvMatricesFwd.H"
48 #include "volFieldsFwd.H"
49 #include "dictionary.H"
50 #include "Switch.H"
51 #include "runTimeSelectionTables.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 class fvMesh;
59 
60 namespace fv
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class option Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class option
68 {
69 protected:
70 
71  // Protected data
72 
73  //- Source name
74  const word name_;
75 
76  //- Model type
77  const word modelType_;
78 
79  //- Reference to the mesh database
80  const fvMesh& mesh_;
81 
82  //- Top level source dictionary
84 
85  //- Dictionary containing source coefficients
87 
88  //- Source active flag
90 
91  //- Field names to apply source to - populated by derived models
93 
94  //- Applied flag list - corresponds to each fieldNames_ entry
96 
97 
98 public:
99 
100  //- Runtime type information
101  TypeName("option");
102 
103 
104  // Declare run-time constructor selection table
105 
107  (
108  autoPtr,
109  option,
110  dictionary,
111  (
112  const word& name,
113  const word& modelType,
114  const dictionary& dict,
115  const fvMesh& mesh
116  ),
117  (name, modelType, dict, mesh)
118  );
119 
120 
121  // Constructors
122 
123  //- Construct from components
124  option
125  (
126  const word& name,
127  const word& modelType,
128  const dictionary& dict,
129  const fvMesh& mesh
130  );
131 
132  //- Return clone
133  autoPtr<option> clone() const
134  {
136  return autoPtr<option>(nullptr);
137  }
138 
139  //- Return pointer to new fvOption object created
140  // on the freestore from an Istream
141  class iNew
142  {
143  //- Reference to the mesh
144  const fvMesh& mesh_;
145 
146  const word& name_;
147 
148  public:
149 
151  (
152  const fvMesh& mesh,
153  const word& name
154  )
155  :
156  mesh_(mesh),
157  name_(name)
158  {}
161  {
162  //const word name(is);
163  const dictionary dict(is);
164 
165  return autoPtr<option>
166  (
167  option::New(name_, dict, mesh_)
168  );
169  }
170  };
171 
172 
173  // Selectors
174 
175  //- Return a reference to the selected fvOption model
176  static autoPtr<option> New
177  (
178  const word& name,
179  const dictionary& dict,
180  const fvMesh& mesh
181  );
182 
183 
184  //- Destructor
185  virtual ~option();
186 
187 
188  // Member Functions
189 
190  // Access
191 
192  //- Return const access to the source name
193  inline const word& name() const;
194 
195  //- Return const access to the mesh database
196  inline const fvMesh& mesh() const;
197 
198  //- Return dictionary
199  inline const dictionary& coeffs() const;
200 
201  //- Return const access to the source active flag
202  inline bool active() const;
203 
204  //- Set the applied flag to true for field index fieldi
205  inline void setApplied(const label fieldi);
206 
207 
208  // Edit
209 
210  //- Return access to the source active flag
211  inline Switch& active();
212 
213 
214  // Checks
215 
216  //- Is the source active?
217  virtual bool isActive();
218 
219  //- Return index of field name if found in fieldNames list
220  virtual label applyToField(const word& fieldName) const;
221 
222  //- Check that the source has been applied
223  virtual void checkApplied() const;
224 
225 
226  // Evaluation
227 
228  // Explicit and implicit sources
229 
230  virtual void addSup
231  (
232  fvMatrix<scalar>& eqn,
233  const label fieldi
234  );
235 
236  virtual void addSup
237  (
238  fvMatrix<vector>& eqn,
239  const label fieldi
240  );
241 
242  virtual void addSup
243  (
245  const label fieldi
246  );
247 
248  virtual void addSup
249  (
251  const label fieldi
252  );
253 
254  virtual void addSup
255  (
256  fvMatrix<tensor>& eqn,
257  const label fieldi
258  );
259 
260 
261  // Explicit and implicit sources for compressible equations
262 
263  virtual void addSup
264  (
265  const volScalarField& rho,
266  fvMatrix<scalar>& eqn,
267  const label fieldi
268  );
269 
270  virtual void addSup
271  (
272  const volScalarField& rho,
273  fvMatrix<vector>& eqn,
274  const label fieldi
275  );
276 
277  virtual void addSup
278  (
279  const volScalarField& rho,
281  const label fieldi
282  );
283 
284  virtual void addSup
285  (
286  const volScalarField& rho,
288  const label fieldi
289  );
290 
291  virtual void addSup
292  (
293  const volScalarField& rho,
294  fvMatrix<tensor>& eqn,
295  const label fieldi
296  );
297 
298 
299  // Explicit and implicit sources for phase equations
300 
301  virtual void addSup
302  (
303  const volScalarField& alpha,
304  const volScalarField& rho,
305  fvMatrix<scalar>& eqn,
306  const label fieldi
307  );
308 
309  virtual void addSup
310  (
311  const volScalarField& alpha,
312  const volScalarField& rho,
313  fvMatrix<vector>& eqn,
314  const label fieldi
315  );
316 
317  virtual void addSup
318  (
319  const volScalarField& alpha,
320  const volScalarField& rho,
322  const label fieldi
323  );
324 
325  virtual void addSup
326  (
327  const volScalarField& alpha,
328  const volScalarField& rho,
330  const label fieldi
331  );
332 
333  virtual void addSup
334  (
335  const volScalarField& alpha,
336  const volScalarField& rho,
337  fvMatrix<tensor>& eqn,
338  const label fieldi
339  );
340 
341 
342  // Constraints
343 
344  virtual void constrain
345  (
346  fvMatrix<scalar>& eqn,
347  const label fieldi
348  );
349 
350  virtual void constrain
351  (
352  fvMatrix<vector>& eqn,
353  const label fieldi
354  );
355 
356  virtual void constrain
357  (
359  const label fieldi
360  );
361 
362  virtual void constrain
363  (
365  const label fieldi
366  );
367 
368  virtual void constrain
369  (
370  fvMatrix<tensor>& eqn,
371  const label fieldi
372  );
373 
374 
375  // Correction
376 
377  virtual void correct(volScalarField& field);
378  virtual void correct(volVectorField& field);
379  virtual void correct(volSphericalTensorField& field);
380  virtual void correct(volSymmTensorField& field);
381  virtual void correct(volTensorField& field);
382 
383 
384  // IO
385 
386  //- Write the source header information
387  virtual void writeHeader(Ostream&) const;
388 
389  //- Write the source footer information
390  virtual void writeFooter(Ostream&) const;
391 
392  //- Write the source properties
393  virtual void writeData(Ostream&) const;
394 
395  //- Read source dictionary
396  virtual bool read(const dictionary& dict);
397 };
398 
399 
400 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
401 
402 } // End namespace fv
403 } // End namespace Foam
404 
405 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
406 
407 #include "fvOptionI.H"
408 
409 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
410 
411 #endif
412 
413 // ************************************************************************* //
Switch active_
Source active flag.
Definition: fvOption.H:88
dictionary dict
virtual void correct(volScalarField &field)
Definition: fvOption.C:306
virtual ~option()
Destructor.
Definition: fvOption.C:101
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
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:91
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:79
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
Definition: Switch.H:60
void setApplied(const label fieldi)
Set the applied flag to true for field index fieldi.
Definition: fvOptionI.H:52
dictionary dict_
Top level source dictionary.
Definition: fvOption.H:82
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvOptionI.H:34
static autoPtr< option > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvOption model.
Definition: fvOption.C:67
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:134
iNew(const fvMesh &mesh, const word &name)
Definition: fvOption.H:150
const word name_
Source name.
Definition: fvOption.H:73
autoPtr< option > clone() const
Return clone.
Definition: fvOption.H:132
A class for handling words, derived from string.
Definition: word.H:59
const word modelType_
Model type.
Definition: fvOption.H:76
labelList fv(nPoints)
virtual void writeFooter(Ostream &) const
Write the source footer information.
Definition: fvOptionIO.C:37
virtual void checkApplied() const
Check that the source has been applied.
Definition: fvOption.C:119
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvOptionIO.C:53
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
declareRunTimeSelectionTable(autoPtr, option, dictionary,(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh),(name, modelType, dict, mesh))
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
bool active() const
Return const access to the source active flag.
Definition: fvOptionI.H:46
const dictionary & coeffs() const
Return dictionary.
Definition: fvOptionI.H:40
virtual void writeData(Ostream &) const
Write the source properties.
Definition: fvOptionIO.C:43
Forward declarations of fvMatrix specializations.
virtual void constrain(fvMatrix< scalar > &eqn, const label fieldi)
Definition: fvOption.C:278
Return pointer to new fvOption object created.
Definition: fvOption.H:140
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void writeHeader(Ostream &) const
Write the source header information.
Definition: fvOptionIO.C:30
autoPtr< option > operator()(Istream &is) const
Definition: fvOption.H:159
option(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvOption.C:44
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: fvOption.H:94
virtual bool isActive()
Is the source active?
Definition: fvOption.C:107
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Macros to ease declaration of run-time selection tables.
virtual label applyToField(const word &fieldName) const
Return index of field name if found in fieldNames list.
Definition: fvOption.C:113
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
dictionary coeffs_
Dictionary containing source coefficients.
Definition: fvOption.H:85
TypeName("option")
Runtime type information.
Namespace for OpenFOAM.
Finite volume options abstract base class. Provides a base set of controls, e.g.: ...
Definition: fvOption.H:66