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