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

SimpleFoam solver doesn't end the process after convergence is reached

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 12, 2022, 06:52
Default SimpleFoam solver doesn't end the process after convergence is reached
  #1
New Member
 
Abhishek Srivastava
Join Date: Apr 2017
Location: Aveiro, Portugal
Posts: 11
Rep Power: 9
AbhisheK_ is on a distinguished road
Dear Foam users,

I have developed a code in which I have to stop the simulation after a certain value of an 'objective function' is reached. The code used to work well and suddenly I get a strange error in which the code doesn't stop the process once the convergence criteria is met.

I am unable to figure out what could be reason for this. I have checked the BC's, fvSolution and the code but couldn't figure out. Any suggestions would help.

log file:

Code:
Difference from fobjTot prev value is 0.000993049
nCounter: 8
Time = 1007

smoothSolver:  Solving for Ux, Initial residual = 0.000251858, Final residual = 2.41959e-05, No Iterations 2
smoothSolver:  Solving for Uy, Initial residual = 0.000354038, Final residual = 1.28174e-05, No Iterations 3
smoothSolver:  Solving for Uz, Initial residual = 4.22694e-05, Final residual = 1.45835e-06, No Iterations 3
GAMG:  Solving for p, Initial residual = 5.11821e-05, Final residual = 2.93447e-06, No Iterations 2
time step continuity errors : sum local = 0.000686456, global = -0.000113395, cumulative = 313072
DILUPBiCG:  Solving for T, Initial residual = 0.00112086, Final residual = 5.13307e-05, No Iterations 1
ExecutionTime = 61.02 s  ClockTime = 61 s

Difference from fobjTot prev value is 0.000992063
nCounter: 9
Time = 1008

smoothSolver:  Solving for Ux, Initial residual = 0.000250857, Final residual = 2.40985e-05, No Iterations 2
smoothSolver:  Solving for Uy, Initial residual = 0.000352491, Final residual = 1.27625e-05, No Iterations 3
smoothSolver:  Solving for Uz, Initial residual = 4.20958e-05, Final residual = 1.4525e-06, No Iterations 3
GAMG:  Solving for p, Initial residual = 5.10157e-05, Final residual = 2.92618e-06, No Iterations 2
time step continuity errors : sum local = 0.000684548, global = -0.000112994, cumulative = 313072
DILUPBiCG:  Solving for T, Initial residual = 0.00112089, Final residual = 5.13313e-05, No Iterations 1
ExecutionTime = 61.08 s  ClockTime = 61 s

Difference from fobjTot prev value is 0.00099108
nCounter: 10
Time = 1009

smoothSolver:  Solving for Ux, Initial residual = 0.00024986, Final residual = 2.40015e-05, No Iterations 2
smoothSolver:  Solving for Uy, Initial residual = 0.00035095, Final residual = 1.27079e-05, No Iterations 3
smoothSolver:  Solving for Uz, Initial residual = 4.19231e-05, Final residual = 1.44668e-06, No Iterations 3
GAMG:  Solving for p, Initial residual = 5.08501e-05, Final residual = 2.91791e-06, No Iterations 2
time step continuity errors : sum local = 0.000682647, global = -0.000112595, cumulative = 313072
DILUPBiCG:  Solving for T, Initial residual = 0.00112091, Final residual = 5.13319e-05, No Iterations 1
ExecutionTime = 61.15 s  ClockTime = 61 s

reached convergence criterion for fobjTot
Time = 1010

smoothSolver:  Solving for Ux, Initial residual = 0.000248867, Final residual = 2.39049e-05, No Iterations 2
smoothSolver:  Solving for Uy, Initial residual = 0.000349415, Final residual = 1.26535e-05, No Iterations 3
smoothSolver:  Solving for Uz, Initial residual = 4.17513e-05, Final residual = 1.44089e-06, No Iterations 3
GAMG:  Solving for p, Initial residual = 5.06853e-05, Final residual = 2.90968e-06, No Iterations 2
time step continuity errors : sum local = 0.000680751, global = -0.000112198, cumulative = 313072
DILUPBiCG:  Solving for T, Initial residual = 0.00112093, Final residual = 5.13325e-05, No Iterations 1
ExecutionTime = 61.23 s  ClockTime = 61 s
The code should say something like SIMPLE solution converged in 1010 steps but it keeps running. I've attached ControlDict and objective function file for reference. please let me know if you need anymore info.

ControlDict:

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  v2012                                 |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     simpleFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         20000;

deltaT          1.0;

writeControl    timeStep;

writeInterval   100;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

libs ("libmyViscosityModels.so");


functions
{
    functionObj
    {
        type            fobj;
        libs            ("libfobjFunctionObject.so");            
        nES             3; //dependent of geometry
        nIS	            1; //dependent of geometry   
    }      
}

// *********************************************************************//
objective function code: calculates objective function and stops the simulation

Code:
if (Pstream::master())
    {
        scalar tol = 1e-3;
        label minCounter = 10;
        label timeSteps = time_.time().value();
        
        scalar fobjTotOld = fobjTot;
        fobjTotOld = Foam::scalar(timeSteps);
        scalar fobjTotNew = fobjTot;
        fobjTotNew = Foam::scalar(timeSteps+1);
        
        scalar diff = (fobjTotNew - fobjTotOld)/fobjTotNew; 


        if (diff <= tol) 
        {
            nCounter_ += 1;
        }
        else
        {
            nCounter_ = 0;
        }

        if (nCounter_ > minCounter) 
        {
            Info << "reached convergence criterion for fobjTot" << endl;
            obr_.time().stopAt(Time::saNoWriteNow);
        }
        else
        {
            Info << "Difference from fobjTot prev value is " << diff << endl; 
            Info << "nCounter: " << nCounter_ << endl; 
        }
    }
    
    return true;
 }
AbhisheK_ 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
Wind turbine simulation Saturn CFX 60 July 17, 2024 06:45
Multiphase flow - incorrect velocity on inlet Mike_Tom CFX 6 September 29, 2016 02:27
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 07:20
Low torque values on Screw Turbine Shaun Waters CFX 34 July 23, 2015 09:16
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 18:44


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