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

Description
    Free-surface phase turbulence damping function

    Adds an extra source term to the mixture or phase epsilon or omega
    equation to reduce turbulence generated near a free-surface.  The
    implementation is based on

    Reference:
    \verbatim
        Frederix, E. M. A., Mathur, A., Dovizio, D., Geurts, B. J.,
        & Komen, E. M. J. (2018).
        Reynolds-averaged modeling of turbulence damping
        near a large-scale interface in two-phase flow.
        Nuclear engineering and design, 333, 122-130.
    \endverbatim

    but with an improved formulation for the coefficient \c A appropriate for
    unstructured meshes including those with split-cell refinement patterns.
    However the dimensioned length-scale coefficient \c delta remains and must
    be set appropriately for the case by performing test runs and comparing with
    known results.  Clearly this model is far from general and more research is
    needed in order that \c delta can be obtained directly from the interface
    flow and turbulence conditions.

    In contrast to the original implementation of interface turbulence damping,
    for kOmegaSST models, the constant betaStar might be used instead of the
    field of the blended beta coefficient for source term formulation.

Usage
    Example usage:
    \verbatim
    addonInterfaceTurbulenceDamping
    {
        type        addonInterfaceTurbulenceDamping;

        libs        ("libaddonMultiphaseEulerFvModels.so");

        phase       air;

        useBetaStar false;

        // Interface turbulence damping length scale
        // This is a required input as described in section 3.3 of the paper
        delta       1e-4;
    }
    \endverbatim

SourceFiles
    addonInterfaceTurbulenceDamping.C

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

#ifndef addonInterfaceTurbulenceDamping_H
#define addonInterfaceTurbulenceDamping_H

#include "fvModel.H"
#include "interfaceTurbulenceDamping.H"
#include "resolvedInterfaceSystem.H"

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

namespace Foam
{
namespace fv
{

/*---------------------------------------------------------------------------*\
                Class addonInterfaceTurbulenceDamping Declaration
\*---------------------------------------------------------------------------*/

class addonInterfaceTurbulenceDamping
:
    public interfaceTurbulenceDamping
{
    // Private Data

        // As a friend, can reuse private data of interfaceTurbulenceDamping

        //- Use betaStar coefficient in denominator
        const Switch useBetaStar_;


    // Private Member Functions

        //- Interface fraction in a cell
        virtual tmp<volScalarField::Internal> interfaceFraction
        (
            const volScalarField& alpha
        ) const;


public:

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


    // Constructors

        //- Construct from explicit source name and mesh
        addonInterfaceTurbulenceDamping
        (
            const word& sourceName,
            const word& modelType,
            const fvMesh& mesh,
            const dictionary& dict
        );

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


    // Member Functions

        //- Add explicit contribution to phase omega equation
        virtual void addSup
        (
            const volScalarField& alpha,
            const volScalarField& rho,
            const volScalarField& field,
            fvMatrix<scalar>& eqn
        ) const;
};


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

} // End namespace fv
} // End namespace Foam

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

#endif

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