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

Dynamic under relaxation factors in simpleFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 24, 2015, 10:14
Default Dynamic under relaxation factors in simpleFoam
  #1
New Member
 
My Name
Join Date: Jan 2013
Posts: 13
Rep Power: 13
ingcorra is on a distinguished road
Hello there,

following the procedure described by Alberto Passalacqua in "http://www.cfd-online.com/Forums/ope...tml#post246333" I am trying to implement dynamic under relaxation factors in simpleFoam.

Right now, what I want to accomplish is this:

- check if the maximum intial pressure residual is decreasing
- if it's decreasing, go further
- if not, stop the SIMPLE loop right after the solution of the pressure equation and repeat from the values of U and p which I had at the beginning of the current time. At this stage I do not want to decrease the under relaxation factors.

What I would expect, is that in the second case all the subsequent SIMPLE loops at a fixed time level will look exactly the same, since they are starting from the same values. What happens, is that I have slight variations of U and p for the first four or five loops. Then everything seems not to vary anymore. I am clearly missing something

Any help would be much appreciated!

For simplicity, I have included bot the pEqn.H and UEqn.H in the same file:

Code:
{
    while (true) {

        U = U.oldTime();
        p = p.oldTime();

        // momentum predictor

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

        UEqn().relax(URelaxationFactor);

        fvOptions.constrain(UEqn());

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

        fvOptions.correct(U);

        // pressure corrector

        {
            volScalarField rAU(1.0/UEqn().A());
            volVectorField HbyA("HbyA", U);
            HbyA = rAU*UEqn().H();
            UEqn.clear();

            // compute the surface flux of H/A
            surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(HbyA) & mesh.Sf());

            fvOptions.makeRelative(phiHbyA);

            // correct the flux at the boundaries
            adjustPhi(phiHbyA, U, p);


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

                pEqn.setReference(pRefCell, pRefValue);

                currentResidual = pEqn.solve().initialResidual();

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

            }

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

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

        }


        #include "continuityErrs.H"

        if (currentResidual < initialResidual) {
            Info << "Residuals are going down" << endl;
            initialResidual = currentResidual;
            break;
            cin.get();
        } else {
            Info << "Residuals are going up" << endl;
            cin.get();
        }
    }

}
ingcorra is offline   Reply With Quote

Old   June 25, 2015, 02:31
Default
  #2
New Member
 
My Name
Join Date: Jan 2013
Posts: 13
Rep Power: 13
ingcorra is on a distinguished road
Here is the output of two subsequent loops at the same time level, including the values of U and p at three different points. The initial values of U and p are the same, but the subsequent SIMPLE loop is different

(0.0855723 1.80568e-20 0) (0.0855981 1.42406e-20 0) (0.0855982 -1.22332e-20 0)
2.33476e-18 1.05554e-18 1.60639e-18
smoothSolver: Solving for Ux, Initial residual = 0.0824525, Final residual = 0.000293527, No Iterations 2
smoothSolver: Solving for Uy, Initial residual = 0.245928, Final residual = 0.00069289, No Iterations 3
Pressure gradient source: uncorrected Ubar = 0.0855981, pressure gradient = 0.000423014
GAMG: Solving for p, Initial residual = 0.370823, Final residual = 0.000364608, No Iterations 145
Pressure gradient source: uncorrected Ubar = 0.0855981, pressure gradient = 0.000412304
time step continuity errors : sum local = 4.60786e-19, global = -2.71051e-20, cumulative = -1.0842e-19
Residuals are going up

(0.0855723 1.80568e-20 0) (0.0855981 1.42406e-20 0) (0.0855982 -1.22332e-20 0)
2.33476e-18 1.05554e-18 1.60639e-18
smoothSolver: Solving for Ux, Initial residual = 0.0826425, Final residual = 0.000297825, No Iterations 2
smoothSolver: Solving for Uy, Initial residual = 0.245928, Final residual = 0.00069289, No Iterations 3
Pressure gradient source: uncorrected Ubar = 0.0855981, pressure gradient = 0.000420528
GAMG: Solving for p, Initial residual = 0.402558, Final residual = 0.000397567, No Iterations 60
Pressure gradient source: uncorrected Ubar = 0.0855982, pressure gradient = 0.000412294
time step continuity errors : sum local = 5.42101e-20, global = -5.42101e-20, cumulative = -1.6263e-19
Residuals are going up

Last edited by ingcorra; June 25, 2015 at 03:58.
ingcorra is offline   Reply With Quote

Old   April 20, 2016, 01:04
Default
  #3
Member
 
Sami
Join Date: Nov 2012
Location: Cap Town, South Africa
Posts: 87
Rep Power: 13
Mehrez is on a distinguished road
Hi
Did you fix it ?
Thank you
Mhrz
Mehrez is offline   Reply With Quote

Old   April 20, 2016, 03:58
Default
  #4
New Member
 
My Name
Join Date: Jan 2013
Posts: 13
Rep Power: 13
ingcorra is on a distinguished road
No, I gave up..
ingcorra is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Lets talk about relaxation factor optimization chriss85 OpenFOAM Running, Solving & CFD 35 June 21, 2019 09:54
Automatic Relaxation factors Ivan OpenFOAM Programming & Development 1 June 30, 2016 03:47
Relaxation Factors for Transient solvers philippose OpenFOAM Running, Solving & CFD 19 March 20, 2014 04:39
Purpose of relaxation factors Mohsin FLUENT 5 April 30, 2010 11:57
Relaxation Factors Tim Phoenics 3 June 30, 2004 02:03


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