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

Description
    This boundary condition provides a turbulentNormalStressPressure condition,
    calculated as:

        \f[
            p_{TNS} = p + \frac{2}{3}\sum_\varphi\varphi\rho_\varphi\,k_\varphi
        \f]

    where
    \vartable
        p_{TNS}      | turbulent normal stress pressure [Pa]
        p            | static pressure [units]
        \varphi      | phase fraction [-]
        \rho_\varphi | phase density [kg/m^3]
        k_\varphi    | phase turbulent kinetic energy [m^2/s^2]
    \endtable

Usage
    \table
        Property | Description                      | Req'd? | Default
        pTNS     | turbulent normal stress pressure | yes    |
    \endtable

    Example of the boundary condition specification:
    \verbatim
    <patchName>
    {
        type       turbulentNormalStressPressure;
        pTNS       101329;
        value      uniform 101329; // optional initial value
    }
    \endverbatim

SourceFiles
    turbulentNormalStressPressureFvPatchScalarField.C

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

#ifndef turbulentNormalStressPressureFvPatchScalarField_H
#define turbulentNormalStressPressureFvPatchScalarField_H

#include "fixedValueFvPatchFields.H"

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

namespace Foam
{

/*---------------------------------------------------------------------------*\
       Class turbulentNormalStressPressureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/

class turbulentNormalStressPressureFvPatchScalarField
:
    public fixedValueFvPatchScalarField
{
    // Private Data

        //- Static pressure that includes turbulent normal stress
        scalarField pTNS_;

    // Private Member Functions

        //- Check explicitTurbulentNormalStress switch
        void explicitTurbulentNormalStressRequired
        (
            const dictionary&
        );

public:

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


    // Constructors

        //- Construct from patch, internal field and dictionary
        turbulentNormalStressPressureFvPatchScalarField
        (
            const fvPatch&,
            const DimensionedField<scalar, volMesh>&,
            const dictionary&
        );

        //- Construct by mapping given fixedValueTypeFvPatchField
        //  onto a new patch
        turbulentNormalStressPressureFvPatchScalarField
        (
            const turbulentNormalStressPressureFvPatchScalarField&,
            const fvPatch&,
            const DimensionedField<scalar, volMesh>&,
            const fieldMapper&
        );

        //- Disallow copy without setting internal field reference
        turbulentNormalStressPressureFvPatchScalarField
        (
            const turbulentNormalStressPressureFvPatchScalarField&
        ) = delete;

        //- Construct as copy setting internal field reference
        turbulentNormalStressPressureFvPatchScalarField
        (
            const turbulentNormalStressPressureFvPatchScalarField&,
            const DimensionedField<scalar, volMesh>&
        );

        //- Construct and return a clone setting internal field reference
        virtual tmp<fvPatchScalarField> clone
        (
            const DimensionedField<scalar, volMesh>& iF
        ) const
        {
            return tmp<fvPatchScalarField>
            (
                new turbulentNormalStressPressureFvPatchScalarField
                (
                    *this,
                    iF
                )
            );
        }


    // Member Functions

        // Mapping functions

            //- Map the given fvPatchField onto this fvPatchField
            virtual void map(const fvPatchScalarField&, const fieldMapper&);


        // Evaluation functions

            //- Update the coefficients associated with the patch field
            virtual void updateCoeffs();


        //- Write
        virtual void write(Ostream&) const;
};


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

} // End namespace Foam

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


#endif

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