OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::Polynomial
00027 
00028 Description
00029     Polynomial templated on size (order):
00030 
00031         poly = logCoeff*log(x) + sum(coeff_[i]*x^i)
00032 
00033     where 0 <= i <= n
00034 
00035     - integer powers, starting at zero
00036     - evaluate(x) to evaluate the poly for a given value
00037     - integrate(x1, x2) between two scalar values
00038     - integrate() to return a new, intergated coeff polynomial
00039       - increases the size (order)
00040     - integrateMinus1() to return a new, integrated coeff polynomial where
00041       the base poly starts at order -1
00042 
00043 SourceFiles
00044     Polynomial.C
00045 
00046 \*---------------------------------------------------------------------------*/
00047 
00048 #ifndef Polynomial_H
00049 #define Polynomial_H
00050 
00051 #include "word.H"
00052 #include "scalar.H"
00053 #include "Ostream.H"
00054 #include "VectorSpace.H"
00055 
00056 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00057 
00058 namespace Foam
00059 {
00060 
00061 // Forward declaration of classes
00062 template<int PolySize>
00063 class Polynomial;
00064 
00065 // Forward declaration of friend functions
00066 template<int PolySize>
00067 Ostream& operator<<
00068 (
00069     Ostream&,
00070     const Polynomial<PolySize>&
00071 );
00072 
00073 
00074 /*---------------------------------------------------------------------------*\
00075                         Class Polynomial Declaration
00076 \*---------------------------------------------------------------------------*/
00077 
00078 template<int PolySize>
00079 class Polynomial
00080 :
00081     public VectorSpace<Polynomial<PolySize>, scalar, PolySize>
00082 {
00083     // Private data
00084 
00085         //- Include the log term? - only activated using integrateMinus1()
00086         bool logActive_;
00087 
00088         //- Log coefficient - only activated using integrateMinus1()
00089         scalar logCoeff_;
00090 
00091 
00092 public:
00093 
00094     typedef Polynomial<PolySize> polyType;
00095 
00096     typedef Polynomial<PolySize+1> intPolyType;
00097 
00098 
00099     // Constructors
00100 
00101         //- Construct null
00102         Polynomial();
00103 
00104         //- Construct from name and Istream
00105         Polynomial(const word& name, Istream& is);
00106 
00107         //- Copy constructor
00108         Polynomial(const Polynomial& poly);
00109 
00110 
00111     // Member Functions
00112 
00113         // Access
00114 
00115             //- Return access to the log term active flag
00116             bool& logActive();
00117 
00118             //- Return access to the log coefficient
00119             scalar& logCoeff();
00120 
00121 
00122         // Evaluation
00123 
00124             //- Return polynomial value
00125             scalar evaluate(const scalar x) const;
00126 
00127             //- Return integrated polynomial coefficients
00128             //  argument becomes zeroth element (constant of integration)
00129             intPolyType integrate(const scalar intConstant = 0.0);
00130 
00131             //- Return integrated polynomial coefficients when lowest order
00132             //  is -1. Argument added to zeroth element
00133             polyType integrateMinus1(const scalar intConstant = 0.0);
00134 
00135             //- Integrate between two values
00136             scalar integrateLimits(const scalar x1, const scalar x2) const;
00137 
00138 
00139     //- Ostream Operator
00140     friend Ostream& operator<< <PolySize>
00141     (
00142         Ostream&,
00143         const Polynomial&
00144     );
00145 };
00146 
00147 
00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00149 
00150 } // End namespace Foam
00151 
00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00153 
00154 #ifdef NoRepository
00155 #   include "Polynomial.C"
00156 #   include "PolynomialIO.C"
00157 #endif
00158 
00159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00160 
00161 #endif
00162 
00163 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd