
[Sponsors] 
October 10, 2018, 18:45 
Eek! nOuterCorrectors eating energy from heatSource?

#1 
Member
Anonymouse
Join Date: Dec 2015
Posts: 98
Rep Power: 4 
I'm running a rhoPimpleFoam simulation of an (evolved) mesh involving spark gaps firing in specific patterns. The energy is added to the simulation in codeAddSup in scalarCodedSourceCoeffs in a heatSource in fvOptions. All well and good. But something weird happens when I change nOuterCorrectors.
Here's the results for nOuterCorrectors == 2: https://www.youtube.com/watch?v=ZCHv...ature=youtu.be Here's the results for nOuterCorrectors == 8: https://www.youtube.com/watch?v=FoRf...ature=youtu.be It's eating all of my energy input from my heatSource! I've checked with printouts from the codeAddSup and it's still adding the energy to the cells... it's just disappearing from the simulation! Any clue what could be going on? Some general info about my case: nCorrectors: 1 nNonOrthogonalCorrectors: 0 transonic: yes maxCo: 1 Turbulence: RAS / LaunderSharmaKE I started messing with nOuterCorrectors when I started trying to up the courant number. As the models are to be evolved in a genetic algorithm, I obviously need the cases to run as quickly as possible (and unfortunately, due to the transient nature of the sparks, I have to use a transient simulation). Advice on how to get as high of a courant number without it crashing out is, of course, quite welcome  I don't need precision, just a reasonable approximation. But in the process of trying to up the courant number I ran into this nOuterCorrectors issue, and so for now I'm forgetting about upping the courant number and trying to wrap my head around what's going on here. I do notice something curious. Note that the lines beginning with "****" and "" are debugging statements in my codeAddSup: Code:
PIMPLE: iteration 1 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 DILUPBiCGStab: Solving for Ux, Initial residual = 0.15932592095457531745, Final residual = 1.1548576351923050908e05, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 0.037127561281924695291, Final residual = 2.9791603271809994777e06, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.37214223517900157923, Final residual = 4.67629236169307904e07, No Iterations 1 DILUPBiCGStab: Solving for e, Initial residual = 0.16809447344164404892, Final residual = 1.3246400427386530665e05, No Iterations 1 GAMG: Solving for p, Initial residual = 0.16418462618748358439, Final residual = 1.6645280804302222903e10, No Iterations 2 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 7.6742864544555995127e14, global = 4.1324041375401492154e14, cumulative = 6.5988075225086239377e11 PIMPLE: iteration 2 DILUPBiCGStab: Solving for Ux, Initial residual = 0.0014448643807351863478, Final residual = 8.1669328637574418402e08, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 0.00027546989643842948381, Final residual = 2.5471593662362301991e08, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.0011725874700291632688, Final residual = 3.43998872314807975e09, No Iterations 1 **** 0.029542883977424907321, 0.57939046460174492559: 231328.87744016532088: 231328.87744016532088: 231328.87744016532088, 1  0.029542883977424907321, 0.57939046460174492559: 1: 2.6400000000000001346e06, 0.12298966836295191496, 0.00019899783528436345128 / 0.00035338220963484161643 **** 1.4454774530462930629e09, 0.45167385015223665556: 6971.0485656573118831: 6971.0485656573118831: 6971.0485656573118831, 1  1.4454774530462930629e09, 0.45167385015223665556: 1: 2.6400000000000001346e06, 0.79567036862702411604, 0.0049310756848542462716 / 0.00093577083064323631628 **** 0.10387054382167526523, 0.80822519910258905362: 63157.279128186026355: 63157.279128186026355: 63157.279128186026355, 1  0.10387054382167526523, 0.80822519910258905362: 1: 2.6400000000000001346e06, 0.52570315048303750682, 0.00029215070043198435815 / 5.3379389691171304829e05  0.0020286084081171046681, 0.87663340936826095184: 0: 2.6400000000000001346e06, 0.35548424768006886554, 0.00039742416601329453706 / 3.8839031163536092209e06 DILUPBiCGStab: Solving for e, Initial residual = 0.016633910190306896992, Final residual = 7.0333565916009248229e07, No Iterations 1 GAMG: Solving for p, Initial residual = 0.00581019704090993995, Final residual = 2.1653426872621771768e07, No Iterations 1 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 1.8046236487480513319e10, global = 5.5905235824988312242e11, cumulative = 1.2189331105007455162e10 PIMPLE: iteration 3 DILUPBiCGStab: Solving for Ux, Initial residual = 6.9185422926261512478e05, Final residual = 3.9417584805672499565e09, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 1.7397410679419544693e05, Final residual = 9.7452266864967517617e10, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.0010964142781748811156, Final residual = 4.184495695933905655e09, No Iterations 1 DILUPBiCGStab: Solving for e, Initial residual = 0.016793934999454012552, Final residual = 8.4546027323164682118e08, No Iterations 1 GAMG: Solving for p, Initial residual = 0.0041564748641993113504, Final residual = 8.0932871389897639411e08, No Iterations 1 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 5.7545486820407337315e11, global = 4.933207048457593362e11, cumulative = 1.712253815346504917e10 PIMPLE: iteration 4 DILUPBiCGStab: Solving for Ux, Initial residual = 3.0098475292996436489e05, Final residual = 7.4237688725730853256e10, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 8.7667969774453377482e06, Final residual = 2.2084608084162864429e10, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.0010375809055311849445, Final residual = 3.8564189527667151277e09, No Iterations 1 DILUPBiCGStab: Solving for e, Initial residual = 0.00013987384740133046923, Final residual = 1.784772774312934773e09, No Iterations 1 GAMG: Solving for p, Initial residual = 4.3711669458214045462e05, Final residual = 6.3508616335680282179e10, No Iterations 1 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 4.992653057942766643e13, global = 3.5398087697986237241e13, cumulative = 1.7157936241163035069e10 PIMPLE: iteration 5 DILUPBiCGStab: Solving for Ux, Initial residual = 8.9172137104080305001e07, Final residual = 8.9172137104080305001e07, No Iterations 0 DILUPBiCGStab: Solving for Uy, Initial residual = 6.4001241803146574679e07, Final residual = 6.4001241803146574679e07, No Iterations 0 DILUPBiCGStab: Solving for Uz, Initial residual = 0.0010879057755952480872, Final residual = 4.0691783309642113622e09, No Iterations 1 DILUPBiCGStab: Solving for e, Initial residual = 1.3918370498400953989e05, Final residual = 1.3171378077423801706e10, No Iterations 1 GAMG: Solving for p, Initial residual = 4.5629369578008409459e06, Final residual = 5.5317464934446860273e11, No Iterations 1 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 4.3675931617769713726e14, global = 2.0627912377480958794e14, cumulative = 1.7155873449925287794e10 PIMPLE: iteration 6 DILUPBiCGStab: Solving for Ux, Initial residual = 6.50065314057371466e08, Final residual = 6.50065314057371466e08, No Iterations 0 DILUPBiCGStab: Solving for Uy, Initial residual = 1.2884770698931408974e08, Final residual = 1.2884770698931408974e08, No Iterations 0 DILUPBiCGStab: Solving for Uz, Initial residual = 0.0010321735805182002954, Final residual = 3.9624429012951149402e09, No Iterations 1 DILUPBiCGStab: Solving for e, Initial residual = 7.9173245861778451799e07, Final residual = 7.9173245861778451799e07, No Iterations 0 GAMG: Solving for p, Initial residual = 4.6723900156853273234e08, Final residual = 4.6723900156853273234e08, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 3.6736732998395064462e11, global = 2.0631511162535782774e14, cumulative = 1.7153810298809033756e10 PIMPLE: iteration 7 DILUPBiCGStab: Solving for Ux, Initial residual = 2.6229616260430618369e09, Final residual = 2.6229616260430618369e09, No Iterations 0 DILUPBiCGStab: Solving for Uy, Initial residual = 2.2366059462807110856e07, Final residual = 2.2366059462807110856e07, No Iterations 0 DILUPBiCGStab: Solving for Uz, Initial residual = 3.113827036408037766e06, Final residual = 4.1981355644990774214e11, No Iterations 1 DILUPBiCGStab: Solving for e, Initial residual = 7.6606409886354104506e07, Final residual = 7.6606409886354104506e07, No Iterations 0 GAMG: Solving for p, Initial residual = 4.6881062470010722192e08, Final residual = 4.6881062470010722192e08, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 3.6846913096204086676e11, global = 2.0631730260216672126e14, cumulative = 1.7149684220513182386e10 DILUPBiCGStab: Solving for epsilon, Initial residual = 0.99360336695874584834, Final residual = 1.1888773190773920551e07, No Iterations 1 DILUPBiCGStab: Solving for k, Initial residual = 0.73133648040774557053, Final residual = 3.5347136829280503655e07, No Iterations 1 ExecutionTime = 0.33000000000000001554 s ClockTime = 0 s writeObjects rhofunc write: automatically written object rho forces upwardForce write: Sum of forces Total : (53.832371111223288551 490.31955076991397391 1.3425905756708779663e15) Pressure : (53.832405571916339682 489.96801167026700341 1.3425899812552512436e15) Viscous : (3.4460693050318596435e05 0.3515390996469474616 5.94415626670074e22) Sum of moments Total : (24.515977538495661747 2.6916185555611953362 141.93049425004139152) Pressure : (24.498400583513316064 2.6916202785958480703 141.86190852845609811) Viscous : (0.017576954982347365447 1.7230346525158682425e06 0.068585721585288861313) Courant Number mean: 0.0042792624626332544449 max: 0.042179241961921243309 deltaT = 1.7279999999999998032e06 Time = 4.3679999999999995143485503890091e06 Thoughts? ED: One more run, with nOuterCorrectors == 1, nCorrectors == 2: https://www.youtube.com/watch?v=CCKa...ature=youtu.be 

October 11, 2018, 02:19 

#2 
Super Moderator

Hi,
thanks for your thread. Indeed interesting. However, to check it more carefully, details are missing.
Generally, using the PIMPLE algorithm will allow you to increase the timestep. However, you should use it correctly. Thus, using relaxation factors appropriatly and the residual control. Further hints:  nice coarse mesh; maybe a bit to coarse? In the gaps, one/two cells more would be good? Sure, its always a matter of accuracy vs speed  You don´t use residual control to leave the outer loops  Adding minIter to the solvers (to ensure that you make at least 1 iteration; this helps sometimes) A remark to your output.
Thanks in advance, Tobi
__________________
Keep foaming, Tobias Holzmann 

October 11, 2018, 05:37 

#3  
Member
Anonymouse
Join Date: Dec 2015
Posts: 98
Rep Power: 4 
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
Will look into these this evening; they weren't in the naca airfoil example that I based my code off of. Quote:


October 12, 2018, 00:45 

#4  
Super Moderator

Quote:
__________________
Keep foaming, Tobias Holzmann 

October 12, 2018, 21:58 

#5  
Member
Anonymouse
Join Date: Dec 2015
Posts: 98
Rep Power: 4 
Quote:
*** I had to break the test case up into two tarballs and rename them to text files to be able to upload them to the forum. 

October 13, 2018, 04:53 

#6 
Super Moderator

Hi,
I checked the case and it works fine with my personal coded stuff (copy&paste from the header). However, you code does not run at all. Code:
PIMPLE: Iteration 1 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 DILUPBiCGStab: Solving for Ux, Initial residual = 0.082583517869215028462, Final residual = 1.5132790637562652651e05, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 0.01806460985322959692, Final residual = 3.4815363492091973089e06, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.15472716674413361515, Final residual = 3.944648390305966073e07, No Iterations 1 foo foo **codeSetValue** DILUPBiCGStab: Solving for e, Initial residual = 0.057465267730118500811, Final residual = 9.8625283234867808907e06, No Iterations 1 **codeCorrect** GAMG: Solving for p, Initial residual = 0.070229304922914195797, Final residual = 5.6339922050230987653e06, No Iterations 1 GAMG: Solving for p, Initial residual = 2.5018139949821598437e05, Final residual = 3.4172573712020873153e09, No Iterations 1 GAMG: Solving for p, Initial residual = 1.7517222467274839476e08, Final residual = 1.7517222467274839476e08, No Iterations 0 GAMG: Solving for p, Initial residual = 1.7517222467274839476e08, Final residual = 1.7517222467274839476e08, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 3.6022471099480605211e11, global = 3.7524435657106932169e12, cumulative = 3.2242318826135843071e10 GAMG: Solving for p, Initial residual = 0.00013029157741722673385, Final residual = 1.2092405239817128058e08, No Iterations 1 GAMG: Solving for p, Initial residual = 6.5520140909152026198e08, Final residual = 6.5520140909152026198e08, No Iterations 0 GAMG: Solving for p, Initial residual = 6.5520140909152026198e08, Final residual = 6.5520140909152026198e08, No Iterations 0 GAMG: Solving for p, Initial residual = 6.5520140909152026198e08, Final residual = 6.5520140909152026198e08, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 1.3474441380642783955e10, global = 1.6427329318844997987e11, cumulative = 3.0599585894251342626e10 GAMG: Solving for p, Initial residual = 3.1350376330926383887e06, Final residual = 1.6631648704174867973e10, No Iterations 1 GAMG: Solving for p, Initial residual = 1.3556522770063032791e09, Final residual = 1.3556522770063032791e09, No Iterations 0 GAMG: Solving for p, Initial residual = 1.3556522770063032791e09, Final residual = 1.3556522770063032791e09, No Iterations 0 GAMG: Solving for p, Initial residual = 1.3556522770063032791e09, Final residual = 1.3556522770063032791e09, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 2.7881030599957615413e12, global = 6.729567339240278097e14, cumulative = 3.0606315461590583613e10 PIMPLE: Iteration 2 DILUPBiCGStab: Solving for Ux, Initial residual = 0.00071627931036244603391, Final residual = 8.5075321114874858666e08, No Iterations 1 DILUPBiCGStab: Solving for Uy, Initial residual = 0.00017202752667494502787, Final residual = 3.7812687757696778027e08, No Iterations 1 DILUPBiCGStab: Solving for Uz, Initial residual = 0.00089013857895736355798, Final residual = 6.6777722140240487123e09, No Iterations 1 foo foo **codeSetValue** DILUPBiCGStab: Solving for e, Initial residual = 0.0058962971408500833292, Final residual = 4.6172709650005078661e11, No Iterations 1 **codeCorrect** GAMG: Solving for p, Initial residual = 0.0025524815179021097603, Final residual = 3.5810777808251610507e07, No Iterations 1 GAMG: Solving for p, Initial residual = 1.5283633308277009206e06, Final residual = 3.1165272939292720171e10, No Iterations 1 GAMG: Solving for p, Initial residual = 1.335373767225192395e09, Final residual = 1.335373767225192395e09, No Iterations 0 GAMG: Solving for p, Initial residual = 1.335373767225192395e09, Final residual = 1.335373767225192395e09, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 2.6269237780954993169e12, global = 4.2979288288287500323e13, cumulative = 3.0563336173302298304e10 GAMG: Solving for p, Initial residual = 2.622344119518172666e05, Final residual = 2.0645692070624235978e09, No Iterations 1 GAMG: Solving for p, Initial residual = 1.0746551136261335936e08, Final residual = 1.0746551136261335936e08, No Iterations 0 GAMG: Solving for p, Initial residual = 1.0746551136261335936e08, Final residual = 1.0746551136261335936e08, No Iterations 0 GAMG: Solving for p, Initial residual = 1.0746551136261335936e08, Final residual = 1.0746551136261335936e08, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 2.1136460893127259922e11, global = 6.3236495238322293335e13, cumulative = 3.0626572668540619254e10 GAMG: Solving for p, Initial residual = 6.5640352584576753641e07, Final residual = 6.5640352584576753641e07, No Iterations 0 GAMG: Solving for p, Initial residual = 6.5640352584576753641e07, Final residual = 6.5640352584576753641e07, No Iterations 0 GAMG: Solving for p, Initial residual = 6.5640352584576753641e07, Final residual = 6.5640352584576753641e07, No Iterations 0 GAMG: Solving for p, Initial residual = 6.5640352584576753641e07, Final residual = 6.5640352584576753641e07, No Iterations 0 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 1.2910163692305130795e09, global = 6.3236606951079251525e13, cumulative = 3.0689809275491698183e10 Code:
code #{ this>refValue() = vector(1, 0, 0) *min(10, 0.1*this>db().time().value()); this>refGrad() = Zero; this>valueFraction() = 1.0; #}; // codeInclude //#{ // #include "fvCFD.H" //#}; // codeOptions //#{ // I$(LIB_SRC)/finiteVolume/lnInclude //#}; Code:
if (cell == 1) continue; Code:
if (afl[i] * afl_percent > 0) Pout << "**** " << x[i] << ", " << y[i] << ": " << hSource[cell] << ": " << (afl[i] * afl_percent) << ": " << afl[i] << ", " << afl_percent << endl; Pout << " " << x[i] << ", " << y[i] << ": " << afl_percent << ": " << cur_time2 << ", " << raw_cycle_number << ", " << spark_start << " / " << spark_end << endl
__________________
Keep foaming, Tobias Holzmann 

October 13, 2018, 08:18 

#7  
Member
Anonymouse
Join Date: Dec 2015
Posts: 98
Rep Power: 4 
Quote:
If my code does not work on your version of OpenFOAM, feel free to substitute any code that does work for you. The key issue is that energy added in codeAddSup disappears when the number of outer correctors increases. Quote:
Quote:
2) My code works just fine here. The code in codeInclude runs a single time at the top of the dynamiccompiled code 3) The code you presented from codedMixedBC does not run over here (I just tested it). Putting code in a section called "code" does not cause it to get inserted into the dynamic compiled code. Quote:
Why would there be sparks that aren't in the mesh? Simple: when you run rhoPimpleFoam decomposed through mpirun, not all decomposed cases have all cells. So we have to have this check. The code exists of course regardless of whether you run it decomposed or not (the problem with nOuterCorrectors occurs in both decomposed and nondecomposed cases) Quote:


October 14, 2018, 05:53 

#8 
Super Moderator

Hi Karen,
the codedMixedBoundary I mentioned is indeed not in your case but the boundary works with the same functionality as the coded one within the fvOption. I was wrong about the continue stuff. After a quick look into the funcionality at cplusplus.com, it was clear. For any reason, I related the continue keyword to the ifcondition rather than to the forloop. However, your code works on my machine now and the source term is executed in each pimple loop. The results for PISO, PIMPLE (corr=3) and PIMPLE (corr=6) looks almost identical. Regarding the execution of the code, everything works fine. I guess that is the main point. See here: https://Holzmanncfd.de/forums/compare.ogv I am using the latest DEV version of the Foundation toolbox. Good luck.
__________________
Keep foaming, Tobias Holzmann 

October 14, 2018, 09:29 

#9  
Member
Anonymouse
Join Date: Dec 2015
Posts: 98
Rep Power: 4 
Quote:
All of the versions you show in your video are wrong; none of them show the energy input from the sparks in the upper compartment of the model on the left, which you can see in my first video. I'm starting to think that i may have no option but to stick with nOuterCorrectors == 1 and just use a high value for nCorrectors and nNonOrthogonalCorrectors to compensate. 

October 14, 2018, 11:47 

#10 
Super Moderator

As we are talking about PISO and PIMPLE corr corresponds to nOuterCorrectors, everything else would not make any sense.
By the way, I cannot give any feedback about the result based on the fact that I did not investigate into your problem too much. In addition, I was not going through your code in detail. After you mention, that everything I did is wrong, I will stop wasting my time to support here.
__________________
Keep foaming, Tobias Holzmann 

October 14, 2018, 16:55 

#11  
Member
Anonymouse
Join Date: Dec 2015
Posts: 98
Rep Power: 4 
Quote:


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Energy balance in conjugative/ porous simulation; Domain Energy is greater than Input  Vishnu_bharathi  CFX  2  June 27, 2018 10:08 
ATTENTION! Reliability problems in CFX 5.7  Joseph  CFX  14  April 20, 2010 15:45 
energy in sonicFoam  joern  OpenFOAM Running, Solving & CFD  0  June 16, 2009 15:53 
Energy dissipation and Drag coefficient  Freeman  Main CFD Forum  10  January 27, 2006 07:42 
Why FVM for highRe flows?  Zhong Lei  Main CFD Forum  23  May 14, 1999 13:22 