/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2016 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
    Foam::CMC::BetaIntegrator

Description

SourceFiles
    BetaIntegratorI.H
    BetaIntegrator.C
    BetaIntegratorIO.C

\*---------------------------------------------------------------------------*/

#ifndef BetaIntegrator_H
#define BetaIntegrator_H

#include "scalarField.H"
#include "BetaFunction.H"
#include "BetaGrid.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// Forward declaration of classes
class Istream;
class Ostream;

// Forward declaration of friend functions and operators
namespace CMC
{
    class BetaIntegrator;
}
Istream& operator>>(Istream&, CMC::BetaIntegrator&);
Ostream& operator<<(Ostream&, const CMC::BetaIntegrator&);


/*---------------------------------------------------------------------------*\
                         Class BetaIntegrator Declaration
\*---------------------------------------------------------------------------*/

namespace CMC
{

class BetaIntegrator
{
    // Private data

        //- Quadrature points
        const scalarField &etaSpace_;

        //- Beta pdf numerators
        scalarField pdfNum_;

        //- Beta pdf denominator
        scalar pdfDen_;

        //- Description of data_
        BetaFunction bf_;

        //- Description of data_
        const BetaGrid &bg_;


    // Private Member Functions

        //- Calculate integral using Simpson's rule
        scalar simps(const scalar xl, const scalar xh, const label n, const UList<scalar>& fx) const;

        //- Calculate integral using Simpson's rule
        scalar sumSimps(const UList<scalar>& f) const;

        //- Disallow default bitwise copy construct
        BetaIntegrator(const BetaIntegrator&);

        //- Disallow default bitwise assignment
        void operator=(const BetaIntegrator&);


public:

    // Static data members

        //- Static data staticData
        // static const scalar staticData;


    // Constructors

        //- Construct from components
        BetaIntegrator(const BetaFunction& bf, const BetaGrid &bg);

        //- Construct as copy
        // BetaIntegrator(const BetaIntegrator&);


    //- Destructor
    ~BetaIntegrator();


    // Member Functions

        scalar betaIntegrate(const scalarField& f) const;

        // Access

        // Check

        // Edit

        // Write


    // Member Operators

        // void operator=(const BetaIntegrator&);


    // Friend Functions

    // Friend Operators

    // IOstream Operators

        friend Istream& ::Foam::operator>>(Istream&, BetaIntegrator&);
        friend Ostream& ::Foam::operator<<(Ostream&, const BetaIntegrator&);
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace CMC
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#include "BetaIntegratorI.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //
