|
[Sponsors] |
July 21, 2006, 02:54 |
I am looking for a (simple) me
|
#1 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
I am looking for a (simple) method to exit cleanly from the main calculation loop.
As pseudo-code: for (runTime++; !runTime.end(); runTime++) { solve_equations(); if ( isConverged() or user_signal()) { runTime.writeNow() and exit_loop; } } Looking through Time*.H, it would appear that something like altering the stop flag to 'saWriteNow' might do the trick, but I would really appreciate some pointers about the correct approach. Thanks, /mark |
|
July 21, 2006, 05:25 |
You can create your own derive
|
#2 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
You can create your own derived Time class. All the main functions (specifically 'end()') are virtual.
Modifying the stop flag to saWriteNow will probably do the trick. It does require the operator++ to be executed though (since the time needs to be past the endTime) so will only stop at the start of the next loop. Let us know how you solved it. |
|
July 21, 2006, 10:56 |
Hi Mattijs,
Following your
|
#3 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Hi Mattijs,
Following your tip, I tried my preferred solution, which resembled the following ... bool Foam::myTime::writeAndEnd() const { stopAt_ = saWriteNow; endTime_ = value(); outputTime_ = true; return write(); } After too many messages about fiddling with protected fields, I ditched this for the brute-force method: loop (!runTime.end()) { solve_equations(); bool written = runTime.write(); if ( isConverged() ) { while (!written && !runTime.end()) { written = (++runTime).write(); } break; } } This is certainly not elegant, but it does ensure that my data are written and the calculations stop. I'll see about getting back to the 'proper' solution when I have more time. Perhaps it would even be useful enough to add back into the Foam::Time class? Thanks, /mark |
|
July 25, 2006, 09:45 |
Hi Mattijs,
I finally had a
|
#4 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Hi Mattijs,
I finally had a few minutes more time and found the 'const' mistake. Attached is a version of myTime myTime.tar.gz that adds the following two member functions: //- Write immediately bool writeNow(); //- Write immediately and increment endTime to finish bool writeAndEnd(); I left the copyright as "OpenCFD Ltd." /mark |
|
July 25, 2006, 11:14 |
Looks pretty good - thanks! I
|
#5 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
Looks pretty good - thanks! I have added it to the Time class.
Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to get the case nameroot outside main | normunds | OpenFOAM Running, Solving & CFD | 2 | May 18, 2007 05:31 |
Main Diffenrences between commercian packages ?? | Abou | Main CFD Forum | 8 | October 16, 2006 09:36 |
axisymmetric main flow + injection | Stephan | FLUENT | 1 | January 19, 2006 12:43 |
loop(p,I->p) how this loop works? | Sinan | FLUENT | 0 | January 18, 2005 19:04 |
Main Star-CD Commands | Maxime Perelli | Siemens | 1 | April 17, 2001 09:35 |