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/)
-   -   Different implementation pEqn.H in pimpleFoam vs interPhaseChangeFoam (https://www.cfd-online.com/Forums/openfoam-programming-development/163399-different-implementation-peqn-h-pimplefoam-vs-interphasechangefoam.html)

DanielRCalvete November 28, 2015 13:10

Different implementation pEqn.H in pimpleFoam vs interPhaseChangeFoam
 
Hello,

I am confusing about the implementation of pEqn.H in pimpleFoam vs interPhaseChangeFoam:

From Non-orthogonal pressure corrector loop, pimpleFoam is written:

Code:


// Non-orthogonal pressure corrector loop
while (pimple.correctNonOrthogonal())
{
    // Pressure corrector
    fvScalarMatrix pEqn
    (
        fvm::laplacian(rAUf, p) == fvc::div(phiHbyA)
    );

    pEqn.setReference(pRefCell, pRefValue);

    pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter())));

    if (pimple.finalNonOrthogonalIter())
    {
        phi = phiHbyA - pEqn.flux();
    }
}

#include "continuityErrs.H"

// Explicitly relax pressure for momentum corrector
p.relax();

U = HbyA - rAU*fvc::grad(p);
U.correctBoundaryConditions();
fvOptions.correct(U);

Since in interPhaseChangeFoam is:

Code:

    while (pimple.correctNonOrthogonal())
    {
        fvScalarMatrix p_rghEqn
        (
            fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh)
          - (vDotvP - vDotcP)*(pSat - rho*gh) + fvm::Sp(vDotvP - vDotcP, p_rgh)
        );

        p_rghEqn.setReference(pRefCell, pRefValue);

        p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter())));

        if (pimple.finalNonOrthogonalIter())
        {
            phi = phiHbyA + p_rghEqn.flux();

            U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf);
            U.correctBoundaryConditions();
            fvOptions.correct(U);
        }
    }

    p == p_rgh + rho*gh;

    if (p_rgh.needReference())
    {
        p += dimensionedScalar
        (
            "p",
            p.dimensions(),
            pRefValue - getRefCellValue(p, pRefCell)
        );
        p_rgh = p - rho*gh;
    }
}

Two main differents and questions:

1) In pimpleFoam U is solved outside the while condition, since in interPhaseChangeFoam is inside it.
My firts thought was that the U is not solved in interPhaseChangeFoam if we set nonOrthogonalCorrector = 0, what is very strange. But seing the solutionControl Class (in particular solutionControlI.H) I find that is added 1 to nNonOrthCorr, therefore I guess that non-Othogonal correction is solved at least one. My questions are:

a) am I correct on this?

b) is any difference in the final solution between putting U reconstruction inside or outside the [CODE] "while" ?

2) In interPhaseChangeFoam the p.relax() does not exist, therefore if we use pimple Loops outerCorr > 1, it is not applied relaxion factors.

c) Does anybody knows why is not p.relax() in the code, or if I miss somewhere where is applied it?

Thank you to anyone who can help me.

Regards,

danny123 December 4, 2015 10:37

Hello DanielRCalvete,

Logically thinking I would guess the following:

1. The Pimple solver was designed before the interPhaseChangeFoam solver
2. You cannot call pEqn.flux() without pEqn being solved

So, this explains why there is that if-clause to calculate phi at the end of each pEq solving loop. If you set the number of nonOrthogonal corrections to -1, the call pEqn.flux() will lead to an error. I do not know why you would do this, but some people apparantly did.

Later, interPhaseChangeFoam was made and the same issue has been found about U. Look at the different code for U.

Regards,

Daniel


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