Simulation Exit Conditions

Simulations can exit either after a specified number of steps, or when a particular condition is met.

Max Steps

The number of steps can be set through the SimulationConfig method of a CUDASimulation object:

# Set the simulation to run for 500 steps
simulation.SimulationConfig().steps = 500

Conditional Exit

Conditional exit from the simulation can be controlled through the use of the FLAMEGPU_EXIT_CONDITION macro. These are specified in the same way as other host functions, but return either CONTINUE or EXIT:

FLAMEGPU_EXIT_CONDITION(my_exit_condition) {
  if (someCondition)
    return EXIT;  // End the simulation here
  else
    return CONTINUE;  // Continue the simulation
}

The exit condition can be added to the model:

# Add 'my_exit_condition' to 'model'
model.addExitCondition(my_exit_condition)