Testing and Debugging
Test and debug your macro.
There are some useful tools that can help to debug the macro and find the source of the problems.
The first is used with the try-catch error handler, and has the following syntax:
try {
} catch (Exception e) {
JOptionPane.showMessageDialog(
null, e.toString()
);
}

Another useful tool that can be used when debugging is the ability to print a line of text to the Output window in the Simcenter STAR-CCM+GUI. Implement code that follows the following syntax:
Simulation mySim =
getActiveSimulation();
mySim.println(“Output Text”);
The output line is passed to the println() method as an Object, and so can include various parameters. The following example has inputs of type String, int, and double:
String myStr = “initial conditions”;
double myDbl = 19.84;
int myInt = 910;
Simulation mySim =
getActiveSimulation;
mySim.println(
“Setting ” + myStr + “: “ + myInt + “ “ + myDbl
);

You can use this tool to print a line of text to the Output window when each key step in the macro has been performed. In this way, if the macro comes to a halt prematurely then you know that the code before the last printed message is not responsible for the error.
Keep the macro run-time to a minimum during development, as it is likely that several attempts are required to get everything correct. The number of iterations can be increased to their final amount at the end.