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