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

Description
    Calculates specified dimensionless numbers for a phase interface and stores
    them on the database. Note that it works only in run-time processing mode
    and in combination with the addonMultiphaseEuler solver.

    Example of function object specification:
    \verbatim
    dimensionlessNumbers
    {
        type                dimensionlessNumbers;
        libs                ("libaddonMultiphaseEulerFunctionObjects.so");
        executeControl      writeTime;
        writeControl        writeTime;
        dispersedPhase      air;
        continuousPhase     water;

        fields
        (
            Re
            St
            Sr
        );

        St
        {
            CT         0.224;
            CLambda    0.234;
        }

        Sr
        {
            residualRe 0.1;
        }
    }
    \endverbatim

Usage
    \table
        Property        | Description                     | Required | Default
        type            | type name: dimensionlessNumbers | yes      |
        dispersedPhase  | name of the dispersed phase     | yes      |
        continuousPhase | name of the continuous phase    | yes      |
        fields          | fields to store (see below)     | yes      |
        CT              | Lagrangian integral time scale  | no       | 0.224
        CLambda         | Eularian integral length scale  | no       | 0.234
        residualRe      | Residual Reynolds number        | no       | 0.1
    \endtable

    Where \c fields can include:
    \plaintable
        Re          | Reynolds Number
        Pr          | Prandtl Number
        Eo          | Eotvos Number
        Mo          | Morton Number
        Ta          | Takahashi Number
        St          | Stokes Number
        Sr          | Dimensionless Shear Rate
    \endplaintable

See also
    Foam::functionObject::fvMeshFunctionObject
    Foam::functionObject

SourceFiles
    dimensionlessNumbers.C

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

#ifndef functionObjects_dimensionlessNumbers_H
#define functionObjects_dimensionlessNumbers_H

#include "fvMeshFunctionObject.H"
#include "phaseSystem.H"

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

namespace Foam
{
namespace functionObjects
{

/*---------------------------------------------------------------------------*\
                    Class dimensionlessNumbers Declaration
\*---------------------------------------------------------------------------*/

class dimensionlessNumbers
:
    public fvMeshFunctionObject
{
public:

    //- Enumeration for the fields
    enum class fieldType
    {
        Re,
        Pr,
        Eo,
        Mo,
        Ta,
        St,
        Sr
    };

    //- Names of the fields
    static const NamedEnum<fieldType, 7> fieldsNames_;


private:

    // Private data

        //- Dispersed phase for which fields are evaluated
        const phaseModel& dispersedPhase_;

        //- Continuous phase for which fields are evaluated
        const phaseModel& continuousPhase_;

        //- Fields to load
        wordHashSet fields_;

        //- Constant to describe the Lagrangian integral timescale
        //  following the fluid motion.
        //  Required only for the calculation of Stokes number
        dimensionedScalar CT_;

        //- Constant to describe the Eulerian longitudinal
        //  integral length scale.
        //  Required only for the calculation of Stokes number
        dimensionedScalar CLambda_;

        //- Residual Reynolds number
        dimensionedScalar residualRe_;

        //- Constant access to phaseSystem
        const phaseSystem& fluid_;


    // Private Member Functions

        //- Process the dimensionless field
        template<class Type>
        void processField
        (
            const word& fieldName,
            const tmp<VolField<Type>>& tvalue
        );


public:

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


    // Constructors

        //- Construct from Time and dictionary
        dimensionlessNumbers
        (
            const word& name,
            const Time& runTime,
            const dictionary&
        );


    //- Destructor
    virtual ~dimensionlessNumbers();


    // Member Functions

        //- Read the data
        virtual bool read(const dictionary&);

        //- Return the list of fields required
        virtual wordList fields() const
        {
            return wordList::null();
        }

        //- Calculate the fields
        virtual bool execute();

        //- Write the fields
        virtual bool write();
};


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

} // End namespace functionObjects
} // End namespace Foam

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

#endif

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