CFD Online Discussion Forums

CFD Online Discussion Forums (
-   STAR-CCM+ (
-   -   Stop in macro loop ? (

binbinhfr November 28, 2011 04:36

Stop in macro loop ?

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.


abdul099 November 28, 2011 19:50

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...

binbinhfr November 29, 2011 05:27

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...

abdul099 December 3, 2011 14:06

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.

binbinhfr December 6, 2011 08:27

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 ?

abdul099 January 2, 2012 21:09

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

binbinhfr January 3, 2012 04:50

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.

ryancoe February 18, 2013 16:31

I added this feature to a macro of mine, here's the actual code:


AbortFileStoppingCriterion stopFile = ((AbortFileStoppingCriterion) sim.getSolverStoppingCriterionManager().getSolverStoppingCriterion("Stop File"));
while (!stopFile.getIsSatisfied()) {
// Do in loop

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