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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::Function1Types::PolynomialEntry
28 
29 Description
30  PolynomialEntry container data entry for scalars. Items are stored in a
31  list of Tuple2's. Data is input in the form,
32  e.g. for an entry <entryName> that describes y = x^2 + 2x^3
33 
34  \verbatim
35  <entryName> polynomial
36  (
37  (1 2)
38  (2 3)
39  );
40  \endverbatim
41 
42 SourceFiles
43  PolynomialEntry.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef PolynomialEntry_H
48 #define PolynomialEntry_H
49 
50 #include "Function1.H"
51 #include "Tuple2.H"
52 #include "Function1Fwd.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 namespace Function1Types
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class Polynomial Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class Type>
66 class Polynomial
67 :
68  public Function1<Type>
69 {
70  // Private Data
71 
72  //- Polynomial coefficients - list of prefactor, exponent
73  List<Tuple2<Type, Type>> coeffs_;
74 
75  //- Flag to indicate whether poly can be integrated
76  bool canIntegrate_;
77 
78 
79  // Private Member Functions
80 
81  //- No copy assignment
82  void operator=(const Polynomial<Type>&) = delete;
83 
84 
85 public:
86 
87  //- Runtime type information
88  TypeName("polynomial");
89 
90 
91  // Constructors
92 
93  //- Construct from entry name and dictionary
94  Polynomial(const word& entryName, const dictionary& dict);
95 
96  //- Construct from components
98  (
99  const word& entryName,
100  const List<Tuple2<Type, Type>>& coeffs
101  );
102 
103  //- Copy constructor
104  explicit Polynomial(const Polynomial& poly);
105 
106  //- Construct and return a clone
107  virtual tmp<Function1<Type>> clone() const
108  {
109  return tmp<Function1<Type>>(new Polynomial<Type>(*this));
110  }
111 
112 
113  //- Destructor
114  virtual ~Polynomial() = default;
115 
116 
117  // Member Functions
118 
119  //- Convert time
120  virtual void convertTimeBase(const Time& t);
121 
122  //- Return Polynomial value
123  virtual Type value(const scalar x) const;
124 
125  //- Integrate between two (scalar) values
126  virtual Type integrate(const scalar x1, const scalar x2) const;
127 
128 
129  //- Write in dictionary format
130  virtual void writeData(Ostream& os) const;
131 };
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 } // End namespace Function1Types
137 } // End namespace Foam
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 #ifdef NoRepository
142  #include "PolynomialEntry.C"
143 #endif
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Function1Types::Polynomial::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: PolynomialEntry.C:200
Tuple2.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Function1Types::Polynomial::integrate
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: PolynomialEntry.C:163
Foam::Function1::entryName
const word & entryName
Definition: Function1.H:133
Function1.H
Foam::Function1::dict
const word const dictionary & dict
Definition: Function1.H:135
PolynomialEntry.C
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:86
Foam::Function1Types::Polynomial::Polynomial
Polynomial(const word &entryName, const dictionary &dict)
Construct from entry name and dictionary.
Definition: PolynomialEntry.C:35
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Function1Types::Polynomial
Definition: PolynomialEntry.H:65
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::Function1Types::Polynomial::value
virtual Type value(const scalar x) const
Return Polynomial value.
Definition: PolynomialEntry.C:145
x
x
Definition: LISASMDCalcMethod2.H:52
Function1Fwd.H
Foam::Function1Types::Polynomial::TypeName
TypeName("polynomial")
Runtime type information.
Foam::Function1Types::Polynomial::clone
virtual tmp< Function1< Type > > clone() const
Construct and return a clone.
Definition: PolynomialEntry.H:106
Foam::Function1Types::Polynomial::convertTimeBase
virtual void convertTimeBase(const Time &t)
Convert time.
Definition: PolynomialEntry.C:130
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:57
Foam::Function1Types::Polynomial::~Polynomial
virtual ~Polynomial()=default
Destructor.