CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

[New solver] buoyantPorousSimpleFoam implicit porous

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 13, 2016, 12:20
Default [New solver] buoyantPorousSimpleFoam implicit porous
  #1
Senior Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 105
Rep Power: 12
hiuluom is on a distinguished road
Hi everyone,

I made a solver "buoyantPorousSimpleFoam" based on buoyantSimpleFoam OF 2.2.x. I know that buoyantSimpleFoam original can run porous with explicit.
But I want to simulate with implicit option, it will easier to reach convergence and faster than explicit option.

What I did:

In order to write buoyantPorousSimpleFoam, I review code of rhoPorousSimpleFoam and porousInterFoam. porousInterFoam solves p_rgh as the buoyantSimpleFoam but it is only explicit porous. So I prefer rhoPorousSimpleFoam to make code for buoyantPorousSimpleFoam.

My problem


I ran a test case in rhoPorousSimpleFoam and buoyantPorousSimpleFoam which gravity equal zero but the pressure loss both of solvers are difference.

Does someone can give me a hint how to set these files right?

Here is the content of code:

buoyantPorousSimpleFoam.C
Code:
#include "fvCFD.H"
#include "rhoThermo.H"
#include "RASModel.H"
#include "radiationModel.H"
#include "simpleControl.H"
#include "fvIOoptionList.H"
#include "IOporosityModelList.H"

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

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    
    simpleControl simple(mesh);
    
    #include "readGravitationalAcceleration.H"
    #include "createFields.H"
    #include "createFvOptions.H"
    #include "createRadiationModel.H"
    #include "createZones.H"
    #include "initContinuityErrs.H"

    

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

    Info<< "\nStarting time loop\n" << endl;

    while (simple.loop())
    {
        Info<< "Time = " << runTime.timeName() << nl << endl;

        // Pressure-velocity SIMPLE corrector
        {
            #include "UEqn.H"
            #include "EEqn.H"
            #include "pEqn.H"
        }

        turbulence->correct();

        runTime.write();

        Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info<< "End\n" << endl;

    return 0;
}


// ************************************************************************* //
createZones.H
Code:
    IOporosityModelList pZones(mesh);
    Switch pressureImplicitPorosity(false);

    // nUCorrectors used for pressureImplicitPorosity
    int nUCorr = 0;
    if (pZones.active())
    {
        // nUCorrectors for pressureImplicitPorosity
        simple.dict().readIfPresent("nUCorrectors", nUCorr);

        if (nUCorr > 0)
        {
            pressureImplicitPorosity = true;
            Info<< "Using pressure implicit porosity" << endl;
        }
        else
        {
            Info<< "Using pressure explicit porosity" << endl;
        }
    }
pEqn.H

Code:
{
    rho = thermo.rho();
    rho.relax();

    volScalarField rAU(1.0/UEqn().A());
    surfaceScalarField rhorAUf("Dp", fvc::interpolate(rho*rAU));

    volVectorField HbyA("HbyA", U);
    if (pressureImplicitPorosity)
    {
        HbyA = trTU() & UEqn().H();
    }
    else
    {
        HbyA = trAU()*UEqn().H();
    }
    UEqn.clear();

    surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf());

    surfaceScalarField phiHbyA
    (
        "phiHbyA",
        fvc::interpolate(rho)*(fvc::interpolate(HbyA) & mesh.Sf())
    );

    fvOptions.relativeFlux(fvc::interpolate(rho), phiHbyA);

    bool closedVolume = adjustPhi(phiHbyA, U, p_rgh);

    phiHbyA += phig;

    while (simple.correctNonOrthogonal())
    {
       tmp<fvScalarMatrix> tpEqn;

        if (pressureImplicitPorosity)
        {
            tpEqn = (fvm::laplacian(rho*trTU(), p_rgh) == fvc::div(phiHbyA));
        }
        else
        {
            tpEqn = (fvm::laplacian(rho*trAU(), p_rgh) == fvc::div(phiHbyA));
        };

        tpEqn().setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));
        tpEqn().solve();
        
        if (simple.finalNonOrthogonalIter())
        {
            // Calculate the conservative fluxes
            phi = phiHbyA - tpEqn().flux();

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

            // Correct the momentum source with the pressure gradient flux
            // calculated from the relaxed pressure
            if (pressureImplicitPorosity)
            {
                U = HbyA + (trTU() & fvc::reconstruct((phig - tpEqn().flux())/rhorAUf));
            }
            else
            {
                U = HbyA + (trAU()*fvc::reconstruct((phig - tpEqn().flux())/rhorAUf));
            }
            U.correctBoundaryConditions();
            fvOptions.correct(U);
        }
    }

    #include "continuityErrs.H"

    p = p_rgh + rho*gh;

    // For closed-volume cases adjust the pressure level
    // to obey overall mass continuity
    if (closedVolume)
    {
        p += (initialMass - fvc::domainIntegrate(psi*p))
            /fvc::domainIntegrate(psi);
        p_rgh = p - rho*gh;
    }

    rho = thermo.rho();
    rho.relax();
    Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value()
        << endl;
}
UEqn.H

Code:
    // Solve the Momentum equation

    tmp<fvVectorMatrix> UEqn
    (
        fvm::div(phi, U)
      + turbulence->divDevRhoReff(U)
     ==
        fvOptions(rho, U)
    );

    UEqn().relax();
    
    tmp<volScalarField> trAU;
    tmp<volTensorField> trTU;

    // fvOptions.constrain(UEqn());

    
    
    if (pressureImplicitPorosity)
    {
        tmp<volTensorField> tTU = tensor(I)*UEqn().A();
        pZones.addResistance(UEqn(), tTU());
        trTU = inv(tTU());
        trTU().rename("rAU");

        fvOptions.constrain(UEqn());

        volVectorField gradp(fvc::reconstruct((ghf*fvc::snGrad(rho) + fvc::snGrad(p_rgh))*mesh.magSf()));

        for (int UCorr=0; UCorr<nUCorr; UCorr++)
        {
            U = trTU() & (UEqn().H() - gradp);
        }
        U.correctBoundaryConditions();
        
        fvOptions.correct(U);
    }
    else
    {
        pZones.addResistance(UEqn());

        fvOptions.constrain(UEqn());

        // solve(UEqn() == -fvc::grad(p));

        // fvOptions.correct(U);
        
        if (simple.momentumPredictor())
        {
            solve
            (
                UEqn()
             ==
                fvc::reconstruct
                (
                    (
                      - ghf*fvc::snGrad(rho)
                      - fvc::snGrad(p_rgh)
                    )*mesh.magSf()
                )
            );

            fvOptions.correct(U);
        }

        trAU = 1.0/UEqn().A();
        trAU().rename("rAU");
    }
the case in attach file at

https://1drv.ms/u/s!AkLk2AeMilR1g517bxSoT0IHNg7BQA

Any suggestions would be appreciated.

Thanh
Attached Images
File Type: png p_buoyantPorousSimpleFoam.PNG (19.6 KB, 37 views)
File Type: png p_rhoPorousSimpleFoam.PNG (18.9 KB, 39 views)
File Type: png U_buoyantPorousSimpleFoam.PNG (17.3 KB, 32 views)
File Type: png U_rhoPorousSimpleFoam.PNG (18.0 KB, 29 views)

Last edited by hiuluom; September 13, 2016 at 21:40.
hiuluom is offline   Reply With Quote

Old   September 18, 2016, 10:52
Default
  #2
Senior Member
 
Huynh Phong Thanh
Join Date: Aug 2013
Location: Ho Chi Minh City
Posts: 105
Rep Power: 12
hiuluom is on a distinguished road
Hi all,

If I only add resistance in momentum equation, the pressure loss equivalent to rhoPorousSimpleFoam.

Code:
    // Solve the Momentum equation

    tmp<fvVectorMatrix> UEqn
    (
        fvm::div(phi, U)
      + turbulence->divDevRhoReff(U)
     ==
        fvOptions(rho, U)
    );

    UEqn().relax();
    pZones.addResistance(UEqn());
    fvOptions.constrain(UEqn());

    if (simple.momentumPredictor())
    {
        solve
        (
            UEqn()
         ==
            fvc::reconstruct
            (
                (
                  - ghf*fvc::snGrad(rho)
                  - fvc::snGrad(p_rgh)
                )*mesh.magSf()
            )
        );

        fvOptions.correct(U);
    }
in porosityProperties file

Code:
porous
    {
        type            DarcyForchheimer;
       	active          yes;
        cellZone        porous;

        DarcyForchheimerCoeffs
        {
            d                       d [ 0 -2 0 0 0 0 0 ] ( 0 0 0 ); 
            f                       f [ 0 -1 0 0 0 0 0 ] ( 289.7 -1000 -1000); 
            coordinateSystem
            {
                e1                      ( 0 0 -1 );
                e2                      ( 0 1 0 );
             }    
        }       
    }
I must add porous implicit because I had a test porous fvoption which gave me bad result.
If I try my sample case as porous parameter above with rhoPorousSimpleFoam in explicit option that means nUCorrectors = 0, the pressure loss have been never reached convergence at least the mesh at porous zone must be finest.

Best,
Thanh
Attached Images
File Type: png p_buoyantPorousExplicitSimpleFoam.PNG (22.3 KB, 15 views)
hiuluom is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Porous media setup issues in Fluent Bernard Van FLUENT 29 January 26, 2017 04:09
Modelling Combustion in Porous Zone tanjinjack FLUENT 2 September 26, 2016 04:10
Modelling sound propagation through layered porous media nkinar Main CFD Forum 0 July 4, 2010 14:45
species mass source in porous media ? PK FLUENT 0 February 16, 2007 11:12
porous media: Fluent or Star-CD? Igor Main CFD Forum 0 December 5, 2002 15:16


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