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/)
-   -   How to update phi in Fractional Step Method (https://www.cfd-online.com/Forums/openfoam-programming-development/185304-how-update-phi-fractional-step-method.html)

Carlen March 22, 2017 19:15

How to update phi in Fractional Step Method
 
Hi Foamers,

I intend to realise a semi-implicit fractional step in OpenFOAM but got stuck at the final step where the flux phi is updated. Please see the code here:
Code:

// Create Poisson Matrix
    fvScalarMatrix pEqn
    (
        fvm::laplacian(p)
    );
    pEqn.setReference(pRefCell, pRefValue);

// PressureCorrection.H
    solve(pEqn==fvc::div(U)/runTime.deltaT());
    phi -= pEqn.flux();// This is where I have problem.
    U -= runTime.deltaT()*fvc::grad(p);
    U.correctBoundaryConditions();

According to Jasak, if there is a plus sign before laplacian (p) then it should be:
Code:


    phi -= pEqn.flux();

otherwise it should be

Code:


    phi += pEqn.flux();

However, I cannot get very good mass conservation from both of them. Or there are other ways to update flux? PS: I am solving momentum equation implicitly using second order backward.

Thanks for your help,

Carlen

gu1 March 19, 2019 08:31

Quote:

Originally Posted by Carlen (Post 641886)
Hi Foamers,

I intend to realise a semi-implicit fractional step in OpenFOAM but got stuck at the final step where the flux phi is updated. Please see the code here:
Code:

// Create Poisson Matrix
    fvScalarMatrix pEqn
    (
        fvm::laplacian(p)
    );
    pEqn.setReference(pRefCell, pRefValue);

// PressureCorrection.H
    solve(pEqn==fvc::div(U)/runTime.deltaT());
    phi -= pEqn.flux();// This is where I have problem.
    U -= runTime.deltaT()*fvc::grad(p);
    U.correctBoundaryConditions();

According to Jasak, if there is a plus sign before laplacian (p) then it should be:
Code:


    phi -= pEqn.flux();

otherwise it should be

Code:


    phi += pEqn.flux();

However, I cannot get very good mass conservation from both of them. Or there are other ways to update flux? PS: I am solving momentum equation implicitly using second order backward.

Thanks for your help,

Carlen

Did you solve this problem?


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