Polynomial1.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-2020 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  Arbitrary order polynomial Function1.
29 
30  The coefficients and exponents of the terms in the polynomial are specified
31  as a list of Tuple2's e.g. for the polynomial y = x^2 + 2x^3
32 
33  \verbatim
34  <name> polynomial
35  (
36  (1 2)
37  (2 3)
38  );
39  \endverbatim
40 
41 SourceFiles
42  Polynomial1.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Polynomial1_H
47 #define Polynomial1_H
48 
49 #include "Function1.H"
50 #include "Tuple2.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 integrald
74  bool canIntegrate_;
75 
76 
77 public:
78 
79  //- Runtime type information
80  TypeName("polynomial");
81 
82 
83  // Constructors
84 
85  //- Construct from name and dictionary
86  Polynomial(const word& name, const dictionary& dict);
87 
88  //- Construct from components
90  (
91  const word& name,
92  const List<Tuple2<Type, Type>>&
93  );
94 
95  //- Copy constructor
96  Polynomial(const Polynomial& poly);
97 
98 
99  //- Destructor
100  virtual ~Polynomial();
101 
102 
103  // Member Functions
104 
105  // Evaluation
106 
107  //- Return Polynomial value as a function of scalar x
108  virtual Type value(const scalar x) const;
109 
110  //- Integrate between two scalar fields
111  virtual Type integral(const scalar x1, const scalar x2) const;
112 
113 
114  //- Write in dictionary format
115  virtual void write(Ostream& os) const;
116 
117 
118  // Member Operators
119 
120  //- Disallow default bitwise assignment
121  void operator=(const Polynomial<Type>&) = delete;
122 };
123 
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 } // End namespace Function1s
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #ifdef NoRepository
133  #include "Polynomial1.C"
134 #endif
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 #endif
139 
140 // ************************************************************************* //
const word const dictionary & dict
Definition: Function1.H:84
Arbitrary order polynomial Function1.
Definition: Polynomial1.H:63
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:156
const word & name() const
Return the name of the entry.
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
Polynomial(const word &name, const dictionary &dict)
Construct from name and dictionary.
Definition: Polynomial1.C:32
virtual ~Polynomial()
Destructor.
Definition: Polynomial1.C:139
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two scalar fields.
Definition: Polynomial1.C:164
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:54
virtual void write(Ostream &os) const
Write in dictionary format.
Definition: Polynomial1.C:201
TypeName("polynomial")
Runtime type information.
Namespace for OpenFOAM.
virtual Type value(const scalar x) const
Return Polynomial value as a function of scalar x.
Definition: Polynomial1.C:146