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

Description
    This blending method is intended to work similar to the 'none' method, but
    for an arbitrary number of disperse and of continuous phases.

    For every phase, the function 'isDisperse' indicates, whether this phase is
    disperse (1) or not (0). This information is taken from the list called
    continuousPhases, which has to be provided by the user.

    For a pair of continuous phases, the blending coefficient for any kind of
    phase interface model (e.g. 'water_oil') is always equal to 1, whereas f1
    and f2 are always zero for such a pair.

    For a pair of a continuous and a disperse phase, the blending coefficient
    (f1 or f2) corresponding to the dispersed phase interface model
    '<disperse>_dispersedIn_<continuous>' is one, wherever this specific
    continuous phase is present and no other continuous phase is. This blending
    coefficient becomes zero, where this specific continuous phase is not
    present at al. In regions, where multiple continuous phases are present, the
    blending coefficient is proportional to the ratio of the volume fraction of
    this specific continuous phase and the sum of volume fractions of all
    continuous phases at this point.

    Blending factor f1 is corresponding to a dispersed phase interface model
    '<phase1>_dispersedIn_<phase2>'. f2 is defined vice versa, accordingly
    \f[
        f_1 = \mathit{isDisperse}(\mathrm{phase1})
            \frac{\alpha_2}{\alpha_{\Sigma c}}
    \f]
    \f[
        f_2 = \mathit{isDisperse}(\mathrm{phase2})
            \frac{\alpha_1}{\alpha_{\Sigma c}}
    \f]

    with the sum volume fraction of all phases declared as continuous
    \f[
        \alpha_{\Sigma c} = \Sigma_{i\in c} \alpha_i
    \f]

    Note, that the blending factors could be stored during runtime by enabling
    the debug switch 'blendingMethod'. Calls to functions f1() and f2() may be
    enforced with a debug switch for a specific model type,
    e.g. 'BlendedInterfacialModel<dragModel> '.

SourceFiles
    definitePhases.C

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

#ifndef definitePhases_H
#define definitePhases_H

#include "blendingMethod.H"

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

namespace Foam
{
namespace blendingMethods
{

/*---------------------------------------------------------------------------*\
                       Class definitePhases Declaration
\*---------------------------------------------------------------------------*/

class definitePhases
:
    public blendingMethod
{
protected:

    // Protected Member Functions

        //- Evaluate the blending function
        virtual tmp<volScalarField> fContinuous
        (
            const UPtrList<const volScalarField>& alphas,
            const label phaseSet,
            const label systemSet
        ) const;

        //- Evaluate the blending function. Filters out phases that cannot
        //  become continuous from the sets, then calls fContinuous
        virtual tmp<volScalarField> f
        (
            const UPtrList<const volScalarField>& alphas,
            const label phaseSet,
            const label systemSet
        ) const;


public:

    //- Runtime type information
    TypeNameNoDebug("definitePhases");


    // Constructors

        //- Construct from a dictionary and two phases
        definitePhases
        (
            const dictionary& dict,
            const phaseInterface& interface
        );


    //- Destructor
    ~definitePhases();


    // Member Functions

        //- Return whether or not a phase can be considered continuous
        virtual bool canBeContinuous(const label index) const;

        //- Return whether or not this interface can segregate
        virtual bool canSegregate() const;
};


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

} // End namespace blendingMethods
} // End namespace Foam

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

#endif

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