/*---------------------------------------------------------------------------*\
  ==  == ====== ====   ====    |
                    \\     ||  | Multiphase Code Repository by HZDR
  ======   //   ||  || ===//   | Website: https://doi.org/10.14278/rodare.767
  ||  ||  //    ||  // || \\   | License: GPL-3.0-or-later
  ==  == ====== ====   ==  ==  |
-------------------------------------------------------------------------------
License
    This file is part of the Multiphase Code Repository by HZDR.

    Copyright (C) 2025 by Helmholtz-Zentrum Dresden-Rossendorf e.V. (HZDR),
    Website: https://hzdr.de

    Multiphase Code Repository by HZDR is based on the free software for
    computational fluid dynamics (CFD) from the OpenFOAM Foundation.
    Copyright (C) 2025 by OpenFOAM Foundation, Website: https://openfoam.org

    If you are interested in which files are original OpenFOAM Foundation
    files, which OpenFOAM Foundation files were modified, and which files were
    newly created, see FILES.md.

    Multiphase Code Repository by HZDR 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.

    Multiphase Code Repository by HZDR 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 the Multiphase Code Repository by HZDR. If not, see
    <http://www.gnu.org/licenses/>.

Class
    Foam::RASModels::SSGManceau

Description
    Implementation of the Elliptic Blending formulation of the Speziale,
    Sarkar and Gatski Reynolds-stress turbulence model. The model blends
    the SSG formulation in the bulk of the flow with the near-wall correct
    asymptotic behaviour of the pressure-strain and the turbulence
    dissipation rate. Blending is done with the parameter alphaRelax
    obtained for solving an elliptic relaxation equation.

Reference:
    \verbatim
        Manceau, R. (2015). Recent progress in the development of the
        Elliptic Blending Reynolds-stress model. International Journal
        of Heat and Fluid Flow 51, 195-220.
    \endverbatim

    \verbatim
        Speziale, C. G., Sarkar, S., & Gatski, T. B. (1991).
        Modelling the pressure–strain correlation of turbulence:
        an invariant dynamical systems approach.
        Journal of Fluid Mechanics, 227, 245-272.
    \endverbatim

    Including the generalised gradient diffusion model of
    Daly and Harlow:
    \verbatim
        Daly, B. J., & Harlow, F. H. (1970).
        Transport equations in turbulence.
        Physics of Fluids (1958-1988), 13(11), 2634-2649.
    \endverbatim

    The default model coefficients are:
    \verbatim
        SSGManceauCoeffs
        {
            Cmu             0.09;

            C1              3.4;
            C1s             1.8;
            C2              0.0;
            C3              0.8;
            C3s             1.3;
            C4              1.25;
            C5              0.4;

            Ceps1           1.44;
            Ceps2           1.83;
            Cs              0.21;
            Ceps            0.183;

            couplingFactor  0.0;
        }
    \endverbatim

SourceFiles
    SSGManceau.C

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

#ifndef SSGManceau_H
#define SSGManceau_H

#include "RASModel.H"
#include "ReynoldsStress.H"

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

namespace Foam
{
namespace RASModels
{

/*---------------------------------------------------------------------------*\
                         Class SSGManceau Declaration
\*---------------------------------------------------------------------------*/

template<class BasicMomentumTransportModel>
class SSGManceau
:
    public ReynoldsStress<RASModel<BasicMomentumTransportModel>>
{
    // Private Member Functions

    tmp<volScalarField> T() const;
    tmp<volScalarField> L() const;


protected:

    // Protected data

        // Model coefficients

            dimensionedScalar Cmu_;

            dimensionedScalar C1_;
            dimensionedScalar C1s_;
            dimensionedScalar C2_;
            dimensionedScalar C3_;
            dimensionedScalar C3s_;
            dimensionedScalar C4_;
            dimensionedScalar C5_;

            dimensionedScalar Ceps1_;
            dimensionedScalar Ceps2_;
            dimensionedScalar Cs_;
            dimensionedScalar Ceps_;

            dimensionedScalar CT_;
            dimensionedScalar CL_;
            dimensionedScalar CEta_;

        // Fields

            volScalarField k_;
            volScalarField epsilon_;

            //- Blending parameter to blend SSG model with near-wall treatment
            volScalarField alphaRelax_;


    // Protected Member Functions

        //- Bound epsilon and return Cmu*sqr(k) for nut
        tmp<volScalarField> boundEpsilon();

        //- Correct the eddy-viscosity nut
        virtual void correctNut();

        virtual tmp<fvSymmTensorMatrix> RSource() const;

        virtual tmp<fvScalarMatrix> epsilonSource() const;


public:

    typedef typename BasicMomentumTransportModel::alphaField alphaField;
    typedef typename BasicMomentumTransportModel::rhoField rhoField;


    //- Runtime type information
    TypeName("SSGManceau");


    // Constructors

        //- Construct from components
        SSGManceau
        (
            const alphaField& alpha,
            const rhoField& rho,
            const volVectorField& U,
            const surfaceScalarField& alphaRhoPhi,
            const surfaceScalarField& phi,
            const viscosity& viscosity,
            const word& type = typeName
        );

        //- Disallow default bitwise copy construction
        SSGManceau(const SSGManceau&) = delete;


    //- Destructor
    virtual ~SSGManceau()
    {}


    // Member Functions

        //- Read model coefficients if they have changed
        virtual bool read();

        //- Return the turbulence kinetic energy
        virtual tmp<volScalarField> k() const
        {
            return k_;
        }

        //- Return the turbulence kinetic energy dissipation rate
        virtual tmp<volScalarField> epsilon() const
        {
            return epsilon_;
        }

        virtual tmp<volScalarField> omega() const
        {
            return volScalarField::New
            (
                this->groupName("omega"),
                epsilon_/(Cmu_*k_)
            );
        }

        //- Return the effective diffusivity for R
        tmp<volSymmTensorField> DREff() const;

        //- Return the effective diffusivity for epsilon
        tmp<volSymmTensorField> DepsilonEff() const;

        //- Solve the turbulence equations and correct eddy-Viscosity and
        //  related properties
        virtual void correct();


    // Member Operators

        //- Disallow default bitwise assignment
        void operator=(const SSGManceau&) = delete;
};


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

} // End namespace RASModels
} // End namespace Foam

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

#ifdef NoRepository
    #include "SSGManceau.C"
#endif

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

#endif

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