|
[Sponsors] |
November 28, 2011, 04:36 |
Stop in macro loop ?
|
#1 |
New Member
Dave Binbin
Join Date: Nov 2011
Posts: 4
Rep Power: 14 |
Hi,
i run my simulation thru a macro that contains a "for" loop calling the solver.step() at each iteration. But when I press the STOP button in the STAR interface, the program seems to exit from the current solver.step() call, but not from the loop within the macro... So is there a way to test in the macro that the STOP button or "user cancel" has been called ? thanks for your help. Dave. |
|
November 28, 2011, 19:50 |
|
#2 |
Senior Member
Join Date: Oct 2009
Location: Germany
Posts: 636
Rep Power: 22 |
You can abort the macro execution by clicking on this little red button with the white cross. It's not in the menu bar but on the left above the property windows, where the status bar could be found.
Another option would be to check for stopping criterias in your loop. Especially the stop file is nice, you just need to create an empty file with the name "ABORT" and the simulation stops after the next iteration or time step. The advantage is, it also works when you run the simulation in batch mode... |
|
November 29, 2011, 05:27 |
|
#3 |
New Member
Dave Binbin
Join Date: Nov 2011
Posts: 4
Rep Power: 14 |
Thank you for the "red cross button" tip, I did not know that it was different from the classic STOP button in the menu bar...
Concerning the ABORT file, I already tested it, but it just force the code to exit the current Solver.Step() call in the macro, but does not exit the macro itself, and the for-loop continues... I just wonder if there is a way in this macro to catch the fact that in the previous solver.step() call, the user pressed the stop button... |
|
December 3, 2011, 14:06 |
|
#4 |
Senior Member
Join Date: Oct 2009
Location: Germany
Posts: 636
Rep Power: 22 |
Just check in your loop header (assuming it's a while or do-while loop) for the stopping criteria. When the stop file stopping criteria is satisfied, the loop shouldn't be executed again.
But the macro itself will not check if there are buttons pressed, since the macro is completely independent from the GUI. Otherwise you would get a big problem when running in batch mode. |
|
December 6, 2011, 08:27 |
|
#5 |
New Member
Dave Binbin
Join Date: Nov 2011
Posts: 4
Rep Power: 14 |
that's precisely what I don't know how to do :
I have a for loop in my macro, but what is the way to check by java if the file stopping criteria is satisfied ? |
|
January 2, 2012, 21:09 |
|
#6 |
Senior Member
Join Date: Oct 2009
Location: Germany
Posts: 636
Rep Power: 22 |
I can't access the API right now, therefore I can't guarantee for the syntax. Maybe you need to adjust it, but that's some (really simple) framework how to do that.
the usual stuff your macro needs to do before it hits the loop ...... StopFileStoppingCriterion stopFile = (StopFileStoppingCriterion) simulation_0.getStoppingCritetrionManager().getSto ppingCriterion("Stop File"); while(!stopFile.getIsSatisfied()) { some stuff your macro should do within the loop } .... some stuff your macro might need to do after finishing the loop |
|
January 3, 2012, 04:50 |
|
#7 |
New Member
Dave Binbin
Join Date: Nov 2011
Posts: 4
Rep Power: 14 |
thanks for your help, I'm using a test of file existence on teh ABORT file, but I will try your suggestion that seems cleaner.
|
|
February 18, 2013, 16:31 |
|
#8 |
Member
Ryan Coe
Join Date: Jun 2010
Location: Albuquerque, NM
Posts: 98
Rep Power: 16 |
I added this feature to a macro of mine, here's the actual code:
Code:
AbortFileStoppingCriterion stopFile = ((AbortFileStoppingCriterion) sim.getSolverStoppingCriterionManager().getSolverStoppingCriterion("Stop File")); while (!stopFile.getIsSatisfied()) { // Do in loop }
__________________
Ryan |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 03:09 |
Star-cd Macro Loop Results | SMM | STAR-CD | 6 | May 2, 2011 21:27 |
[CAD formats] my stl surface is seen as just a line | rcastilla | OpenFOAM Meshing & Mesh Conversion | 2 | January 6, 2010 02:30 |
NACA0012 geometry/design software needed | Franny | Main CFD Forum | 13 | July 7, 2007 16:57 |
CFX TASCflow - while-endwhile loop ina macro | Deepak Ganga | CFX | 0 | September 6, 2003 23:21 |