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

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

#include "populationBalanceModel.H"
#include "populationBalance.H"
#include "volFieldsFwd.H"

// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //

inline Foam::label Foam::populationBalanceModel::sourceUpdateInterval() const
{
    return solverDict().lookupOrDefault<label>("sourceUpdateInterval", 1);
}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

inline const Foam::phaseSystem& Foam::populationBalanceModel::fluid() const
{
    return fluid_;
}


inline const Foam::fvMesh& Foam::populationBalanceModel::mesh() const
{
    return mesh_;
}


inline const Foam::phaseModel&
Foam::populationBalanceModel::continuousPhase() const
{
    return continuousPhase_;
}


inline Foam::label Foam::populationBalanceModel::nGroups() const
{
    return phases_.size();
}


inline const Foam::UPtrList<const Foam::phaseModel>&
Foam::populationBalanceModel::phases() const
{
    return phases_;
}


inline const Foam::UPtrList<const Foam::phaseModel>&
Foam::populationBalanceModel::uniquePhases() const
{
    return uniquePhases_;
}


inline const Foam::UPtrList<const Foam::diameterModels::populationBalance>&
Foam::populationBalanceModel::diameters() const
{
    return diameters_;
}


inline const Foam::UPtrList<const Foam::diameterModels::populationBalance>&
Foam::populationBalanceModel::uniqueDiameters() const
{
    return uniqueDiameters_;
}


inline const Foam::PtrList<Foam::volScalarField>&
Foam::populationBalanceModel::fs() const
{
    return fs_;
}


inline Foam::PtrList<Foam::volScalarField>& Foam::populationBalanceModel::fs()
{
    return fs_;
}


inline const Foam::volScalarField& Foam::populationBalanceModel::f
(
    const label i
) const
{
    return fs_[i];
}


inline Foam::volScalarField& Foam::populationBalanceModel::f(const label i)
{
    return fs_[i];
}


inline const Foam::PtrList<Foam::dimensionedScalar>&
Foam::populationBalanceModel::dSphs() const
{
    return dSphs_;
}


inline const Foam::dimensionedScalar& Foam::populationBalanceModel::dSph
(
    const label i
) const
{
    return dSphs_[i];
}


inline const Foam::PtrList<Foam::dimensionedScalar>&
Foam::populationBalanceModel::vs() const
{
    return vs_;
}


inline const Foam::dimensionedScalar& Foam::populationBalanceModel::v
(
    const label i
) const
{
    return vs_[i];
}


inline const Foam::populationBalanceModel::dmdtfTable&
Foam::populationBalanceModel::dmdtfs() const
{
    return dmdtfs_;
}


inline const Foam::populationBalanceModel::dmdtfTable&
Foam::populationBalanceModel::expansionDmdtfs() const
{
    return expansionDmdtfs_;
}


inline const Foam::populationBalanceModel::dmdtfTable&
Foam::populationBalanceModel::modelSourceDmdtfs() const
{
    return modelSourceDmdtfs_;
}


inline const Foam::dictionary& Foam::populationBalanceModel::solverDict() const
{
    return mesh_.solution().solverDict(name_);
}


inline bool Foam::populationBalanceModel::solveOnFinalIterOnly() const
{
    return solverDict().lookupOrDefault<bool>("solveOnFinalIterOnly", false);
}


inline const Foam::List<Foam::Pair<Foam::label>>&
Foam::populationBalanceModel::coalescencePairs() const
{
    return coalescencePairs_;
}


inline const Foam::List<Foam::Pair<Foam::label>>&
Foam::populationBalanceModel::binaryBreakupPairs() const
{
    return binaryBreakupPairs_;
}


inline const Foam::volScalarField& Foam::populationBalanceModel::alphas() const
{
    return
        uniquePhases_.size() > 1
      ? alphas_()
      : uniquePhases_.first();
}


inline Foam::tmp<Foam::volVectorField> Foam::populationBalanceModel::U() const
{
    return
        uniquePhases_.size() > 1
      ? tmp<volVectorField>(U_())
      : uniquePhases_.first().U();
}


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