IntegrationScheme.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::IntegrationScheme
26 
27 Description
28  Top level model for Integration schemes
29 
30 SourceFiles
31  IntegrationScheme.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef IntegrationScheme_H
36 #define IntegrationScheme_H
37 
38 #include "autoPtr.H"
39 #include "runTimeSelectionTables.H"
40 #include "dictionary.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class IntegrationScheme Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 template<class Type>
53 {
54 
55 public:
56 
57  //- Helper class to supply results of integration
58  class integrationResult
59  {
60  //- Integration value
61  Type value_;
62 
63  //- Average value across integration step
64  Type average_;
65 
66 
67  public:
68 
69  //- Constructor
71  :
72  value_(pTraits<Type>::zero),
73  average_(pTraits<Type>::zero)
74  {}
75 
76 
77  // Member functions
78 
79  // Access
80 
81  //- Return const access to the value
82  Type value() const
83  {
84  return value_;
85  }
86 
87  //- Return const access to the average
88  Type average() const
89  {
90  return average_;
91  }
92 
93 
94  // Edit
95 
96  //- Return access to the value for changing
97  Type& value()
98  {
99  return value_;
100  }
101 
102  //- Return access to the average for changing
103  Type& average()
104  {
105  return average_;
106  }
107  };
108 
109 
110 private:
111 
112  // Private data
113 
114  //- Name of the Integration variable
115  const word& phiName_;
116 
117  //- Reference to the dictionary
118  const dictionary& dict_;
119 
120 
121  // Private Member Functions
122 
123  //- Disallow default bitwise assignment
124  void operator=(const IntegrationScheme&);
125 
126 
127 public:
128 
129  //- Runtime type information
130  TypeName("integrationScheme");
131 
132 
133  //- Declare runtime constructor selection table
134 
136  (
137  autoPtr,
139  dictionary,
140  (
141  const word& phiName,
142  const dictionary& dict
143  ),
144  (phiName, dict)
145  );
146 
147 
148  // Constructors
149 
150  //- Construct from components
151  IntegrationScheme(const word& phiName, const dictionary& dict);
152 
153  //- Copy constructor
155 
156  //- Construct and return clone
157  virtual autoPtr<IntegrationScheme<Type> > clone() const = 0;
158 
159 
160  // Selectors
161 
162  //- Return a reference to the selected radiation model
164  (
165  const word& phiName,
166  const dictionary& dict
167  );
168 
169 
170  //- Destructor
171  virtual ~IntegrationScheme();
172 
173 
174  // Member Functions
175 
176  //- Perform the Integration
178  (
179  const Type& phi,
180  const scalar dt,
181  const Type& alphaBeta,
182  const scalar beta
183  ) const = 0;
184 };
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 #define makeIntegrationScheme(Type) \
194  \
195  defineNamedTemplateTypeNameAndDebug(IntegrationScheme<Type>, 0); \
196  \
197  defineTemplateRunTimeSelectionTable \
198  ( \
199  IntegrationScheme<Type>, \
200  dictionary \
201  );
202 
204 #define makeIntegrationSchemeType(SS, Type) \
205  \
206  defineNamedTemplateTypeNameAndDebug(SS<Type>, 0); \
207  \
208  IntegrationScheme<Type>::adddictionaryConstructorToTable<SS<Type> > \
209  add##SS##Type##ConstructorToTable_;
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 #ifdef NoRepository
215 # include "IntegrationScheme.C"
216 #endif
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
Top level model for Integration schemes.
virtual integrationResult integrate(const Type &phi, const scalar dt, const Type &alphaBeta, const scalar beta) const =0
Perform the Integration.
virtual ~IntegrationScheme()
Destructor.
virtual autoPtr< IntegrationScheme< Type > > clone() const =0
Construct and return clone.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
Macros to ease declaration of run-time selection tables.
Helper class to supply results of integration.
A class for handling words, derived from string.
Definition: word.H:59
TypeName("integrationScheme")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
dictionary dict
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:47
static autoPtr< IntegrationScheme > New(const word &phiName, const dictionary &dict)
Return a reference to the selected radiation model.
IntegrationScheme(const word &phiName, const dictionary &dict)
Construct from components.
surfaceScalarField & phi
Type average() const
Return const access to the average.
Traits class for primitives.
Definition: pTraits.H:50
Type value() const
Return const access to the value.
declareRunTimeSelectionTable(autoPtr, IntegrationScheme, dictionary,( const word &phiName, const dictionary &dict ),(phiName, dict))
Declare runtime constructor selection table.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117