PolynomialEntry.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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::Function1s::Polynomial
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 Function1s
57 {
58 
59 /*---------------------------------------------------------------------------*\
60  Class Polynomial Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 template<class Type>
64 class Polynomial
65 :
66  public FieldFunction1<Type, Polynomial<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 public:
78 
79  //- Runtime type information
80  TypeName("polynomial");
81 
82 
83  // Constructors
84 
85  Polynomial(const word& entryName, const dictionary& dict);
86 
87  //- Construct from components
89  (
90  const word& entryName,
91  const List<Tuple2<Type, Type>>&
92  );
93 
94  //- Copy constructor
95  Polynomial(const Polynomial& poly);
96 
97 
98  //- Destructor
99  virtual ~Polynomial();
100 
101 
102  // Member Functions
103 
104  // Evaluation
105 
106  //- Return Polynomial value
107  virtual Type value(const scalar x) const;
108 
109  //- Integrate between two (scalar) values
110  virtual Type integrate(const scalar x1, const scalar x2) const;
111 
112 
113  //- Write in dictionary format
114  virtual void writeData(Ostream& os) const;
115 
116 
117  // Member Operators
118 
119  //- Disallow default bitwise assignment
120  void operator=(const Polynomial<Type>&) = delete;
121 };
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 } // End namespace Function1s
127 } // End namespace Foam
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 #ifdef NoRepository
132  #include "PolynomialEntry.C"
133 #endif
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #endif
138 
139 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:84
PolynomialEntry container data entry for scalars. Items are stored in a list of Tuple2&#39;s. Data is input in the form, e.g. for an entry <entryName> that describes y = x^2 + 2x^3.
void operator=(const Polynomial< Type > &)=delete
Disallow default bitwise assignment.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
A 2-tuple for storing two objects of different types.
Definition: HashTable.H:65
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
virtual void writeData(Ostream &os) const
Write in dictionary format.
const word & entryName
Definition: Function1.H:84
virtual ~Polynomial()
Destructor.
A class for handling words, derived from string.
Definition: word.H:59
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Polynomial(const word &entryName, const dictionary &dict)
TypeName("polynomial")
Runtime type information.
Namespace for OpenFOAM.
virtual Type value(const scalar x) const
Return Polynomial value.