Foam::tmp<Foam::volScalarField> Foam::SrivastavaSundaresanFrictionalStress::muf
(
    const volScalarField& alpha,
    const volScalarField& Theta,
    const dimensionedScalar& alphaMinFriction,
    const dimensionedScalar& alphaMax,
    const volScalarField& pf,
    const volSymmTensorField& D,
    const dimensionedScalar& phi
) const
{
    const scalar I2Dsmall = 1.0e-35;

    //Creating muf assuming it should be 0 on the boundary which may not be
    // true
    tmp<volScalarField> tmuf
    (
       new volScalarField
       (
          IOobject
          (
             "muf",
             alpha.mesh().time().timeName(),
             alpha.mesh()
          ),
          alpha.mesh(),
          dimensionedScalar("muf", dimensionSet(1, -1, -1, 0, 0), 1e30)
       )
    );
    
    volScalarField& muff = tmuf();
   
      forAll (D, celli)
    {
        if (alpha[celli] >= alphaMinFriction.value())
        {
            muff[celli] =
                0.5*pf[celli]*sin(phi.value())
               /(
                    sqrt(1.0/6.0*(sqr(D[celli].xx() - D[celli].yy())
                  + sqr(D[celli].yy() - D[celli].zz())
                  + sqr(D[celli].zz() - D[celli].xx()))
                  + sqr(D[celli].xy()) + sqr(D[celli].xz())
                  + sqr(D[celli].yz())) + I2Dsmall
                );
        }
        if (alpha[celli] < alphaMinFriction.value())
        {
            muff[celli] = 0.0;
        }
    }

    muff.correctBoundaryConditions();

    return tmuf;
}
Foam::tmp<Foam::volScalarField> Foam::SchaefferFrictionalStress::muf
(
    const volScalarField& alpha,
    const dimensionedScalar& alphaMax,
    const volScalarField& pf,
    const volTensorField& D,
    const dimensionedScalar& phi
) const
{
    const scalar I2Dsmall = 1.0e-15;

    // Creating muf assuming it should be 0 on the boundary which may not be
    // true
    tmp<volScalarField> tmuf
    (
        new volScalarField
        (
            IOobject
            (
                "muf",
                alpha.mesh().time().timeName(),
                alpha.mesh()
            ),
            alpha.mesh(),
            dimensionedScalar("muf", dimensionSet(1, -1, -1, 0, 0), 0.0)
        )
    );

    volScalarField& muff = tmuf();

    forAll (D, celli)
    {
        if (alpha[celli] > alphaMax.value()-5e-2)
        {
            muff[celli] =
                0.5*pf[celli]*sin(phi.value())
               /(
                    sqrt(1.0/6.0*(sqr(D[celli].xx() - D[celli].yy())
                  + sqr(D[celli].yy() - D[celli].zz())
                  + sqr(D[celli].zz() - D[celli].xx()))
                  + sqr(D[celli].xy()) + sqr(D[celli].xz())
                  + sqr(D[celli].yz())) + I2Dsmall
                );
        }
    }

    return tmuf;
}