PolynomialEntry.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-2016 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::Function1Types::PolynomialEntry
26 
27 Description
28  PolynomialEntry container data entry for scalars. Items are stored in a
29  list of Tuple2's. Data is input in the form,
30  e.g. for an entry <entryName> that describes y = x^2 + 2x^3
31 
32  \verbatim
33  <entryName> polynomial
34  (
35  (1 2)
36  (2 3)
37  );
38  \endverbatim
39 
40 SourceFiles
41  PolynomialEntry.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef PolynomialEntry_H
46 #define PolynomialEntry_H
47 
48 #include "Function1.H"
49 #include "Tuple2.H"
50 #include "Function1Fwd.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 namespace Function1Types
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class Polynomial Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class Type>
64 class Polynomial
65 :
66  public Function1<Type>
67 {
68  // Private data
69 
70  //- Polynomial coefficients - list of prefactor, exponent
71  List<Tuple2<Type, Type>> coeffs_;
72 
73  //- Flag to indicate whether poly can be integrated
74  bool canIntegrate_;
75 
76 
77  // Private Member Functions
78 
79  //- Disallow default bitwise assignment
80  void operator=(const Polynomial<Type>&);
81 
82 
83 public:
84 
85  //- Runtime type information
86  TypeName("polynomial");
87 
88 
89  // Constructors
90 
91  Polynomial(const word& entryName, const dictionary& dict);
92 
93  //- Construct from components
95  (
96  const word& entryName,
97  const List<Tuple2<Type, Type>>&
98  );
99 
100  //- Copy constructor
101  Polynomial(const Polynomial& poly);
102 
103  //- Construct and return a clone
104  virtual tmp<Function1<Type>> clone() const
105  {
106  return tmp<Function1<Type>>(new Polynomial(*this));
107  }
108 
109 
110  //- Destructor
111  virtual ~Polynomial();
112 
113 
114  // Member Functions
115 
116  // Manipulation
117 
118  //- Convert time
119  virtual void convertTimeBase(const Time& t);
120 
121 
122  // Evaluation
123 
124  //- Return Polynomial value
125  Type value(const scalar x) const;
126 
127  //- Integrate between two (scalar) values
128  Type integrate(const scalar x1, const scalar x2) const;
129 
130 
131  //- Write in dictionary format
132  virtual void writeData(Ostream& os) const;
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Function1Types
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #ifdef NoRepository
144  #include "PolynomialEntry.C"
145 #endif
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #endif
150 
151 // ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:53
const word const dictionary & dict
Definition: Function1.H:88
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
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
Type value(const scalar x) const
Return Polynomial value.
const word & entryName
Definition: Function1.H:88
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Polynomial(const word &entryName, const dictionary &dict)
A class for handling words, derived from string.
Definition: word.H:59
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void writeData(Ostream &os) const
Write in dictionary format.
TypeName("polynomial")
Runtime type information.
A class for managing temporary objects.
Definition: PtrList.H:54
virtual void convertTimeBase(const Time &t)
Convert time.
virtual ~Polynomial()
Destructor.
Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Namespace for OpenFOAM.