# How to get initial residuals for U components during runtime?

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

 April 11, 2011, 11:49 How to get initial residuals for U components during runtime? #1 Senior Member   Florian Krause Join Date: Mar 2009 Location: Munich Posts: 103 Rep Power: 9 Dear all, I use a modified simpleFoam in OpenFOAM-1.7.x. I simulate a laminar pipe flow with uniform fixed value inlet boundary conditons and zeroGradient outlet boundary conditions. I've set up the case as a wedge using wedge boundary conditions. so far so good... Now I want to stop the simulations if a pre-defined convergence criterion is satisfied for pressure p and the axial (x) and wall-normal (y) velocity component. If I use tmp UEqn ( fvm::div(phi, U) + turbulence->divDevReff(U) ); UEqn().relax(); eqnResidualU = solve ( UEqn() == -fvc::grad(p) ).initialResidual(); maxResidualU = max(eqnResidualU, maxResidualU); then I get the initial residuals for all three velocity components. And using if (maxResidualU < convergenceCriterionU && maxResidualP < convergenceCriterionP) { Info<< "reached convergence criterion for U and p"<< endl; runTime.writeAndEnd(); Info<< "latestTime = " << runTime.timeName() << endl; } I perform the actual convergence check on all three velocity components. As mentioned above, for this wedge case, I want to stop the calculation if only the x and y component of U satisfy the pre-defined convergence criterion. Does anyone know how to do that? As always, any help is appreciated! Best, Florian

 May 5, 2011, 18:22 #2 Member   Logan Page Join Date: Sep 2010 Posts: 38 Rep Power: 8 Try modifying the solver along the lines of this int StopItter = 1; while (runTime.loop() && StopItter) { . . .#include "UEqn.H" #include "TEqn.H" #include "pEqn.H" . . . } then where you do the convergence check try this if (maxResidualU < convergenceCriterionU && maxResidualP < convergenceCriterionP) { Info<< "reached convergence criterion for U and p"<< endl; runTime.writeAndEnd(); Info<< "latestTime = " << runTime.timeName() << endl; StopItter = 0; }

 May 6, 2011, 03:10 #3 Senior Member   Florian Krause Join Date: Mar 2009 Location: Munich Posts: 103 Rep Power: 9 thanks for your reply, but if I understand your suggestions correctly, then it will basically do the same as before usingif (maxResidualU < convergenceCriterionU && maxResidualP < convergenceCriterionP) { runTime.writeAndEnd(); } It will stop the calculation when the convergence criteria are satisfied. My concern iseqnResidualU = solve ( UEqn() == -fvc::grad(p) ).initialResidual(); maxResidualU = max(eqnResidualU, maxResidualU); If I compare maxResidualU with my convergence criterion, it will always check if the residuals of all velocity components satisfy the convergence criterion. What I need in my specific case is to stop the calculation if only the residuals of Ux and Uy satisfy my convergence criterion. Best, Florian

 May 6, 2011, 08:54 #4 Member   Logan Page Join Date: Sep 2010 Posts: 38 Rep Power: 8 Hmm yeah sorry i didtnt look at the code properly before replying :P I actually have no idea how you would split the Ux and Uy residuals in OpenFOAM itself. How i ended up terminating a simulation upon reaching steady-state was by controlling it with an octave script 1) run OpenFoam solver for n time steps (say 200) from previous time step 2) access the log file and pull out the initial residuals 3) check convergence criterion 4) if convergence reached stop else (1) not very efficient i know, but for what i am doing i had problems with the Ux and Uy residuals, they never actually reach the convergence criterion but rather approached a flat line so i had to specify (1-UxRes(@200)/UxRes(@0)) < 1e-4 for example sorry i couldnt be of more help.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20 Unseen OpenFOAM Running, Solving & CFD 7 April 16, 2014 03:38 xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33 carsten OpenFOAM Bugs 11 September 12, 2008 11:16 sivakumar OpenFOAM Pre-Processing 9 September 9, 2008 12:53

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