CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   max function in Schnerr-Sauer Cavitation File (https://www.cfd-online.com/Forums/openfoam-programming-development/214661-max-function-schnerr-sauer-cavitation-file.html)

dviam February 8, 2019 15:39

max function in Schnerr-Sauer Cavitation File
 
I am a bit unsure that the min/max functions are working properly in the Schnerr-Sauer cavitation model. The current code reads as:

Code:

Foam::Pair<Foam::tmp<Foam::volScalarField>>
Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotAlphal() const
{
    const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
    volScalarField pCoeff(this->pCoeff(p));

    volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));

    return Pair<tmp<volScalarField>>
    (
        Cc_*limitedAlpha1*pCoeff*max(p - pSat(), p0_),

        Cv_*(1.0 + alphaNuc() - limitedAlpha1)*pCoeff*min(p - pSat(), p0_)
    );
}

It should be noted that p0_ is simply the scalar 0. Consider the case where p-pSat() > 0. This means that the first term in the pair Cc_*.... should have a non-zero value while the second term Cv_*.... should have a value of zero. It should be the case that these pairs never have both non-zero values at the same time. This is, however, not the case. Writing the pair to disk shows that there are instances where both values in the pair have non-zero ideas.

Any ideas how this can be corrected? Or am I interpreting the code incorrectly.

Thanks


All times are GMT -4. The time now is 19:19.