/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  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::BetaFunction

Description

SourceFiles
    BetaFunctionI.H
    BetaFunction.C
    BetaFunctionIO.C

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

#ifndef BetaFunction_H
#define BetaFunction_H

#include "scalar.H"
#include "Switch.H"
#include "scalarField.H"

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

namespace Foam
{

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

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


/*---------------------------------------------------------------------------*\
                         Class BetaFunction Declaration
\*---------------------------------------------------------------------------*/

namespace CMC
{

class BetaFunction
{
    // Private data

        //- Mean mixture fraction
        scalar mf_;

        //- Mixture fraction variance
        scalar mfVar_;

        //- Beta pdf parameter alpha
        scalar a_;

        //- Beta pdf parameter beta
        scalar b_;

        //- Flag beta pdf special case: forced-delta function 
        Switch fdelta_;

        //- delta function at pure oxidizer stream
        Switch delta0_;

        //- delta function at pure fuel stream
        Switch delta1_;


    // Private Member Functions

        //- Calculate alpha and beta and set special case flags
        void _setParameters();

        //- Limit too large value of beta pdf parameters
        void _limitAB();

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

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


public:

    // Static data members

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


    // Constructors

        //- Construct from components
        BetaFunction(const scalar mf, const scalar mfVar);

        //- Construct from Istream
        BetaFunction(Istream&);

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


    //- Destructor
    ~BetaFunction();


    // Member Functions

        scalarField etaFunc(const UList<scalar>& eta) const
        {
            return pow(eta, a_-1.0)*pow(1.0-eta, b_-1.0);
        }

        scalar etaFunc(const scalar eta) const
        {
            return Foam::pow(eta, a_-1.0)*Foam::pow(1.0-eta, b_-1.0);
        }


        // Access

            Switch fdelta() const {return fdelta_;}

            Switch delta0() const {return delta0_;}

            Switch delta1() const {return delta1_;}

            scalar mf() const {return mf_;}

            scalar mfVar() const {return mfVar_;}

            scalar alpha() const {return a_;}

            scalar beta() const {return b_;}

        // Check

        // Edit

        // Write


    // Member Operators

        // void operator=(const BetaFunction&);


    // Friend Functions

    // Friend Operators

    // IOstream Operators

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


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

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

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

#include "BetaFunctionI.H"

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

#endif

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