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

Modifying sonicFoam to run with variable timestep - strange results

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 31, 2013, 07:19
Default Modifying sonicFoam to run with variable timestep - strange results
  #1
New Member
 
Aaron
Join Date: Mar 2013
Posts: 10
Rep Power: 4
dalaron is on a distinguished road
I have modified the sonicFoam solver (version 2.1.1) to run a variable timestep and with maximum Courant number. The reason I want to have a variable timestep sonicFoam solver is to perform a grid dependency study, and doing so with a static timestep was very frustrating.

The modified solver works for some grid resolutions and not for others. I don't know why. The test case, and some (incorrect) pressure plots are attached.

At the start of the simulation I set MaxCo = 0.2 in my controlDict file, run own_sonicFoam, and everything appears to be proceeding okay. A typical output near the start of the simulation is:
Code:
Courant Number mean: 0.0629867 max: 0.200099
deltaT = 2.48178e-05
TIME = 0.127543
The max courant number is slightly higher than the specified MaxCo but I think that's okay for now. The timestep updates nicely, increasing or decreasing to keep the max Courant number ~< 0.2.

Then at a certain point the timestep drops rapidly and there is a huge discrepancy between the Courant number mean and max:
Code:
Courant Number mean: 8.67688e-05 max: 0.2
deltaT = 1.53002e-09
TIME = 0.199746794
Looking at the solution for pressure develop over time in paraview, there is a transition from being symmetric about the central line (everything updating nicely, deltaT nice size) to unsymmetrical flow (timestep rapidly drops). What would cause this transition to unsymmetrical? Is there anything I can do to stop it?

One of the more confusing things about this was that for one test case (refer blockMeshDict file) I found that an odd number of cells in the vertical direction caused problems, but an even number gave a good solution.

The changes I made to the sonicFoam solver are:
Code:
#include "fvCFD.H"
#include "basicPsiThermo.H"
#include "turbulenceModel.H"

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

int main(int argc, char *argv[])
{
    #include "setRootCase.H"        
    #include "createTime.H"             
    #include "createMesh.H"            
    #include "createFields.H"
    #include "initContinuityErrs.H"

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

    Info<< "\nSTARTING TIME LOOP\n" << endl;

    while (runTime.loop()) //runTime.run() ?
    {

        #include "readPISOControls.H"
        #include "compressibleCourantNo.H"
        #include "readTimeControls.H" 
        #include "setDeltaT.H" 
        runTime++;    
        
        Info<< "TIME = " << runTime.timeName() << nl << endl;

        //#include "readPISOControls.H"
        //#include "compressibleCourantNo.H"

        #include "rhoEqn.H"

        #include "UEqn.H"

        #include "eEqn.H"
        // --- PISO loop

        for (int corr=0; corr<nCorr; corr++)
        {
            #include "pEqn.H"
        }

        turbulence->correct();

        rho = thermo.rho(); // thermodynamics call.

        runTime.write();

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

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

    return 0;
}
My programming experience with C++ and OpenFOAM is limited, so any insights or suggestions would be appreciated.
Attached Images
File Type: jpg tGood.jpg (13.2 KB, 19 views)
File Type: jpg tBad.jpg (17.0 KB, 19 views)
Attached Files
File Type: gz variableTsonicFoam.tar.gz (82.5 KB, 6 views)

Last edited by dalaron; August 31, 2013 at 08:48. Reason: wrong .C file initially
dalaron is offline   Reply With Quote

Old   September 2, 2013, 07:21
Default
  #2
New Member
 
Aaron
Join Date: Mar 2013
Posts: 10
Rep Power: 4
dalaron is on a distinguished road
A semi-progress update. Increasing the Courant number from 0.2 to 0.5 solves this problem and gives me good results.

As far as I understand, the Courant number only affects the stability of the solver. So shouldn't a higher Courant number be more likely to cause problems? What have I done wrong here that a lower Courant number is doing this instead?
dalaron is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable BC in time and space for transient run Porry CFX 2 February 21, 2012 10:38
Working directory via command line Luiz CFX 4 March 6, 2011 21:02
intermediate results during a transient run Michael Skoblin CFX 1 September 25, 2006 14:00
Error when changing timestep in transient run Tony CFX 4 December 8, 2004 15:13
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09


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