FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

Polynomial.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::Polynomial
00026 
00027 Description
00028     Polynomial templated on size (order):
00029 
00030         poly = logCoeff*log(x) + sum(coeff_[i]*x^i)
00031 
00032     where 0 <= i <= n
00033 
00034     - integer powers, starting at zero
00035     - evaluate(x) to evaluate the poly for a given value
00036     - integrate(x1, x2) between two scalar values
00037     - integrate() to return a new, intergated coeff polynomial
00038       - increases the size (order)
00039     - integrateMinus1() to return a new, integrated coeff polynomial where
00040       the base poly starts at order -1
00041 
00042 SourceFiles
00043     Polynomial.C
00044 
00045 \*---------------------------------------------------------------------------*/
00046 
00047 #ifndef Polynomial_H
00048 #define Polynomial_H
00049 
00050 #include <OpenFOAM/word.H>
00051 #include <OpenFOAM/scalar.H>
00052 #include <OpenFOAM/Ostream.H>
00053 #include <OpenFOAM/VectorSpace.H>
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 namespace Foam
00058 {
00059 
00060 // Forward declaration of classes
00061 template<int PolySize>
00062 class Polynomial;
00063 
00064 // Forward declaration of friend functions
00065 template<int PolySize>
00066 Ostream& operator<<
00067 (
00068     Ostream&,
00069     const Polynomial<PolySize>&
00070 );
00071 
00072 
00073 /*---------------------------------------------------------------------------*\
00074                         Class Polynomial Declaration
00075 \*---------------------------------------------------------------------------*/
00076 
00077 template<int PolySize>
00078 class Polynomial
00079 :
00080     public VectorSpace<Polynomial<PolySize>, scalar, PolySize>
00081 {
00082     // Private data
00083 
00084         //- Include the log term? - only activated using integrateMinus1()
00085         bool logActive_;
00086 
00087         //- Log coefficient - only activated using integrateMinus1()
00088         scalar logCoeff_;
00089 
00090 
00091 public:
00092 
00093     typedef Polynomial<PolySize> polyType;
00094 
00095     typedef Polynomial<PolySize+1> intPolyType;
00096 
00097 
00098     // Constructors
00099 
00100         //- Construct null
00101         Polynomial();
00102 
00103         //- Construct from name and Istream
00104         Polynomial(const word& name, Istream& is);
00105 
00106         //- Copy constructor
00107         Polynomial(const Polynomial& poly);
00108 
00109 
00110     // Member Functions
00111 
00112         // Access
00113 
00114             //- Return access to the log term active flag
00115             bool& logActive();
00116 
00117             //- Return access to the log coefficient
00118             scalar& logCoeff();
00119 
00120 
00121         // Evaluation
00122 
00123             //- Return polynomial value
00124             scalar evaluate(const scalar x) const;
00125 
00126             //- Return integrated polynomial coefficients
00127             //  argument becomes zeroth element (constant of integration)
00128             intPolyType integrate(const scalar intConstant = 0.0);
00129 
00130             //- Return integrated polynomial coefficients when lowest order
00131             //  is -1. Argument added to zeroth element
00132             polyType integrateMinus1(const scalar intConstant = 0.0);
00133 
00134             //- Integrate between two values
00135             scalar integrateLimits(const scalar x1, const scalar x2) const;
00136 
00137 
00138     //- Ostream Operator
00139     friend Ostream& operator<< <PolySize>
00140     (
00141         Ostream&,
00142         const Polynomial&
00143     );
00144 };
00145 
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 } // End namespace Foam
00150 
00151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00152 
00153 #ifdef NoRepository
00154 #   include "Polynomial.C"
00155 #   include "PolynomialIO.C"
00156 #endif
00157 
00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00159 
00160 #endif
00161 
00162 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines