DataEntry.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-2013 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::DataEntry
26 
27 Description
28  Top level data entry class for use in dictionaries. Provides a mechanism
29  to specify a variable as a certain type, e.g. constant or table, and
30  provide functions to return the (interpolated) value, and integral between
31  limits.
32 
33 SourceFiles
34  DataEntry.C
35  DataEntryNew.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef DataEntry_H
40 #define DataEntry_H
41 
42 #include "dictionary.H"
43 #include "Field.H"
44 #include "dimensionedType.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 class Time;
51 
52 template<class Type>
53 class DataEntry;
54 
55 template<class Type>
56 Ostream& operator<<
57 (
58  Ostream&,
59  const DataEntry<Type>&
60 );
61 
62 /*---------------------------------------------------------------------------*\
63  Class DataEntry Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<class Type>
67 class DataEntry
68 :
69  public refCount
70 {
71  // Private Member Functions
72 
73  //- Disallow default bitwise assignment
74  void operator=(const DataEntry<Type>&);
75 
76 
77 protected:
78 
79  // Protected data
80 
81  //- Name of entry
82  const word name_;
83 
84 
85 public:
86 
87  //- Runtime type information
88  TypeName("DataEntry")
89 
90  //- Declare runtime constructor selection table
92  (
95  dictionary,
96  (
97  const word& entryName,
99  ),
101  );
102 
103 
104  // Constructor
105 
106  //- Construct from entry name
107  DataEntry(const word& entryName);
108 
109  //- Copy constructor
110  DataEntry(const DataEntry<Type>& de);
111 
112  //- Construct and return a clone
113  virtual tmp<DataEntry<Type> > clone() const
114  {
115  return tmp<DataEntry<Type> >(new DataEntry<Type>(*this));
116  }
117 
118 
119  //- Selector
121  (
122  const word& entryName,
123  const dictionary& dict
124  );
125 
126 
127  //- Destructor
128  virtual ~DataEntry();
129 
130 
131  // Member Functions
132 
133  // Access
134 
135  //- Return the name of the entry
136  const word& name() const;
137 
138 
139  // Manipulation
140 
141  //- Convert time
142  virtual void convertTimeBase(const Time& t);
143 
144 
145  // Evaluation
146 
147  //- Return value as a function of (scalar) independent variable
148  virtual Type value(const scalar x) const;
149 
150  //- Return value as a function of (scalar) independent variable
151  virtual tmp<Field<Type> > value(const scalarField& x) const;
152 
153  //- Integrate between two (scalar) values
154  virtual Type integrate(const scalar x1, const scalar x2) const;
155 
156  //- Integrate between two (scalar) values
157  virtual tmp<Field<Type> > integrate
158  (
159  const scalarField& x1,
160  const scalarField& x2
161  ) const;
162 
163  //- Return dimensioned type
164  virtual dimensioned<Type> dimValue(const scalar x) const;
165 
166  //- Return dimensioned type as a function of (scalar)
168  (
169  const scalarField& x
170  ) const;
171 
172  //- Integrate between two scalars and return a dimensioned type
174  (
175  const scalar x1,
176  const scalar x2
177  ) const;
178 
179  //- Integrate between two scalar fields and return a field of
180  // dimensioned type
182  (
183  const scalarField& x1,
184  const scalarField& x2
185  ) const;
186 
187 
188  // I/O
189 
190  //- Ostream Operator
191  friend Ostream& operator<< <Type>
192  (
193  Ostream& os,
194  const DataEntry<Type>& de
195  );
196 
197  //- Write in dictionary format
198  virtual void writeData(Ostream& os) const;
199 };
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #define makeDataEntry(Type) \
209  \
210  defineNamedTemplateTypeNameAndDebug(DataEntry<Type>, 0); \
211  \
212  defineTemplateRunTimeSelectionTable \
213  ( \
214  DataEntry<Type>, \
215  dictionary \
216  );
217 
218 
219 #define makeDataEntryType(SS, Type) \
220  \
221  defineNamedTemplateTypeNameAndDebug(SS<Type>, 0); \
222  \
223  DataEntry<Type>::adddictionaryConstructorToTable<SS<Type> > \
224  add##SS##Type##ConstructorToTable_;
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #ifdef NoRepository
230 # include "DataEntry.C"
231 # include "DataEntryNew.C"
232 #endif
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::DataEntry::name_
const word name_
Name of entry.
Definition: DataEntry.H:81
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:45
Foam::DataEntry::name
const word & name() const
Return the name of the entry.
Definition: DataEntry.C:57
Foam::DataEntry::~DataEntry
virtual ~DataEntry()
Destructor.
Definition: DataEntry.C:50
Foam::DataEntry::New
static autoPtr< DataEntry< Type > > New(const word &entryName, const dictionary &dict)
Selector.
Definition: DataEntryNew.C:32
Foam::DataEntry::dimIntegrate
virtual dimensioned< Type > dimIntegrate(const scalar x1, const scalar x2) const
Integrate between two scalars and return a dimensioned type.
Definition: DataEntry.C:135
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::DataEntry::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: DataEntryIO.C:50
Foam::DataEntry::operator=
void operator=(const DataEntry< Type > &)
Disallow default bitwise assignment.
Field.H
DataEntry.C
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::DataEntry::TypeName
TypeName("DataEntry") declareRunTimeSelectionTable(autoPtr
Runtime type information.
Foam::dimensioned< Type >
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
DataEntryNew.C
Foam::DataEntry::entryName
const word & entryName
Definition: DataEntry.H:96
Foam::DataEntry::dimValue
virtual dimensioned< Type > dimValue(const scalar x) const
Return dimensioned type.
Definition: DataEntry.C:125
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
Foam::DataEntry::convertTimeBase
virtual void convertTimeBase(const Time &t)
Convert time.
Definition: DataEntry.C:64
dictionary.H
declareRunTimeSelectionTable
#define declareRunTimeSelectionTable(autoPtr, baseType, argNames, argList, parList)
Definition: runTimeSelectionTables.H:49
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::DataEntry::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: DataEntry.C:80
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::DataEntry
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: DataEntry.H:52
Foam::DataEntry::dict
const word const dictionary & dict
Definition: DataEntry.H:98
Foam::DataEntry::value
virtual Type value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: DataEntry.C:71
Foam::DataEntry::clone
virtual tmp< DataEntry< Type > > clone() const
Construct and return a clone.
Definition: DataEntry.H:112
dimensionedType.H