initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / functions / Polynomial / Polynomial.H
blob9d787f6c1ba3e3d06f709cd516de8882dd73e58e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::Polynomial
28 Description
29     Polynomial templated on size (order):
31         poly = logCoeff*log(x) + sum(coeff_[i]*x^i)
33     where 0 <= i <= n
35     - integer powers, starting at zero
36     - evaluate(x) to evaluate the poly for a given value
37     - integrate(x1, x2) between two scalar values
38     - integrate() to return a new, intergated coeff polynomial
39       - increases the size (order)
40     - integrateMinus1() to return a new, integrated coeff polynomial where
41       the base poly starts at order -1
43 SourceFiles
44     Polynomial.C
46 \*---------------------------------------------------------------------------*/
48 #ifndef Polynomial_H
49 #define Polynomial_H
51 #include "word.H"
52 #include "scalar.H"
53 #include "Ostream.H"
54 #include "VectorSpace.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 namespace Foam
61 // Forward declaration of classes
62 template<int PolySize>
63 class Polynomial;
65 // Forward declaration of friend functions
66 template<int PolySize>
67 Ostream& operator<<
69     Ostream&,
70     const Polynomial<PolySize>&
74 /*---------------------------------------------------------------------------*\
75                         Class Polynomial Declaration
76 \*---------------------------------------------------------------------------*/
78 template<int PolySize>
79 class Polynomial
81     public VectorSpace<Polynomial<PolySize>, scalar, PolySize>
83     // Private data
85         //- Include the log term? - only activated using integrateMinus1()
86         bool logActive_;
88         //- Log coefficient - only activated using integrateMinus1()
89         scalar logCoeff_;
92 public:
94     typedef Polynomial<PolySize> polyType;
96     typedef Polynomial<PolySize+1> intPolyType;
99     // Constructors
101         //- Construct null
102         Polynomial();
104         //- Construct from name and Istream
105         Polynomial(const word& name, Istream& is);
107         //- Copy constructor
108         Polynomial(const Polynomial& poly);
111     // Member Functions
113         // Access
115             //- Return access to the log term active flag
116             bool& logActive();
118             //- Return access to the log coefficient
119             scalar& logCoeff();
122         // Evaluation
124             //- Return polynomial value
125             scalar evaluate(const scalar x) const;
127             //- Return integrated polynomial coefficients
128             //  argument becomes zeroth element (constant of integration)
129             intPolyType integrate(const scalar intConstant = 0.0);
131             //- Return integrated polynomial coefficients when lowest order
132             //  is -1. Argument added to zeroth element
133             polyType integrateMinus1(const scalar intConstant = 0.0);
135             //- Integrate between two values
136             scalar integrateLimits(const scalar x1, const scalar x2) const;
139     //- Ostream Operator
140     friend Ostream& operator<< <PolySize>
141     (
142         Ostream&,
143         const Polynomial&
144     );
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 } // End namespace Foam
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 #ifdef NoRepository
155 #   include "Polynomial.C"
156 #   include "PolynomialIO.C"
157 #endif
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 #endif
163 // ************************************************************************* //