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

Bug in Artificial Compressibility Method using Dual-Time Stepping

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

Like Tree1Likes
  • 1 Post By Jesus.M

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 20, 2020, 07:02
Default Bug in Artificial Compressibility Method using Dual-Time Stepping
  #1
New Member
 
Jesús Miguel Sánchez
Join Date: Jan 2019
Posts: 9
Rep Power: 7
Jesus.M is on a distinguished road
Hello OpenFOAM Community,

I am implementing the Artificial Compressibility method with dual-time stepping. I finished the code by adding a for loop in order to advance the solution in real time besides the pseudo-time stepping that this method uses. Therefore, I had to set also a counter for the real time and do several modifications to the code. I fixed some previous bugs that kept me from having a clean compilation. Once I had a clean compilation, I tried the code and it runs, but it does not print the solution for the specified time-step... Any suggestion of what it can be causing this problem?

Here's the code for more clarity.


Code:
int main(int argc, char *argv[])
{
   
        #include "postProcess.H"
        #include "addCheckCaseOptions.H"
        #include "setRootCaseLists.H"
        #include "createTime.H"
        #include "createMesh.H"
        #include "createControl.H"
        #include "createFields.H"
        #include "initContinuityErrs.H"
        #include "CourantNo.H"
        #include "readTimeControls.H"
        #include "setInitialDeltaT.H"


    scalar maxCoRealTime = runTime.controlDict().lookupOrDefault<scalar>("maxCoRealTime", 1.0);

    scalar realDeltaT = runTime.controlDict().lookupOrDefault<scalar>("realDeltaT", GREAT);
    
    scalar CoNumRealTime = 0.0;

    #include "CourantNoRealTime.H"

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

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

    //declaration Time Variables

        auto maxIterRealTime = runTime.controlDict().lookupOrDefault<scalar>("maxIterRealTime",1);
    auto maxIterPseudoTime = runTime.controlDict().lookupOrDefault<scalar>("maxIterPseudoTime",1);
        
    decltype(realDeltaT) timeTotalRealTime = 0.0;
    
    auto runRealTime = runTime.timeIndex();
    runRealTime = 0;

    //declaration of fluid properties

    decltype(U) Udt1 = U;
    decltype(U) Udt0 = U;
    
    
    //Real-time step
    for(auto i = decltype(maxIterRealTime){0}; i < maxIterRealTime; ++i)
    {

        ++runRealTime;
        #include "readRealTimeControls.H"
        #include "CourantNoRealTime.H"
        #include "setRealDeltaT.H"

        Udt0 = Udt1; // Updating U at real time. 

            

        //Pseudo-time step
        while (runTime.timeIndex() < maxIterPseudoTime)
        {

            ++runTime;

            //Time derivative

             auto dualDt = dimensionedScalar("dt_real", dimTime, realDeltaT);
                 Udt1    = U;
                 dt_ddt  = (Udt1 - Udt0) / dualDt;

            //CFL-based time-step

            #include "readTimeControls.H"
            #include "CourantNo.H"
                #include "setDeltaT.H"
                
        
                Info<< "Time = " << runTime.timeName() << nl << endl;
    
                //Continuity Equation

            phi = fvc::interpolate(U) & mesh.Sf();
        
            fvScalarMatrix pEqn
            (
              fvm::ddt(p) + beta * fvc::div(U)
            );

            //pEqn.setReference(pRefCell, pRefValue);

            pEqn.solve();
    
            #include "continuityErrs.H"

            p.correctBoundaryConditions();
    
            //Momentum Equation

                fvVectorMatrix UEqn
            (
              fvm::ddt(U) + fvm::div(phi,U) - fvm::laplacian(nu,U)
            );

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

        }
        
        runTime.printExecutionTime(Info);

        
        
        //Update Real time and reset pseudo-time
        
        timeTotalRealTime += realDeltaT;
       
        runTime.setTime(timeTotalRealTime, runRealTime);
            runTime.write();

        runTime.setTime(0.0, 0);
        
    }

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

    return 0;
}
Thank you

Last edited by Jesus.M; June 23, 2020 at 06:47.
Jesus.M is offline   Reply With Quote

Old   June 23, 2020, 06:49
Default
  #2
New Member
 
Jesús Miguel Sánchez
Join Date: Jan 2019
Posts: 9
Rep Power: 7
Jesus.M is on a distinguished road
Hello OpenFOAM community,



I have figured out that the command runTime.write() does not work. However, I don't know the reason why.

Does anyone know why it can stop working?
Jesus.M is offline   Reply With Quote

Old   June 26, 2020, 06:52
Default
  #3
New Member
 
Jesús Miguel Sánchez
Join Date: Jan 2019
Posts: 9
Rep Power: 7
Jesus.M is on a distinguished road
Hello,

I have found the problem. I will post the solution for anyone who encounters the same problem. The code ran fine. When you are doing dual-time stepping, you have to set the writeControl inside the controlDict file to timeStep.

Then, OpenFOAM will write every time-step in real time.
scleakey likes this.
Jesus.M is offline   Reply With Quote

Reply

Tags
dual time stepping method

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
bash script for pseudo-parallel usage of reconstructPar kwardle OpenFOAM Post-Processing 41 August 23, 2023 02:48
courant number increases to rather large values 6863523 OpenFOAM Running, Solving & CFD 22 July 5, 2023 23:48
laplacianFoam with source term Herwig OpenFOAM Running, Solving & CFD 17 November 19, 2019 13:47
pressure in incompressible solvers e.g. simpleFoam chrizzl OpenFOAM Running, Solving & CFD 13 March 28, 2017 05:49
Dual Time Stepping Method X. Ye Main CFD Forum 1 September 23, 1999 04:05


All times are GMT -4. The time now is 03:10.