Skip to content

Instantly share code, notes, and snippets.

@pfsq pfsq/
Last active Dec 30, 2015

What would you like to do?
Snippet to show Pushover integration into a STAR-CCM+ Java macro.
* This is the main method in the macro. It is executed when the macro is
* run in STAR-CCM+.
public void execute() {
try {
// Find the current simulation
Simulation theSim =
// Set up DataReader
DataReader reader =
new DataReader();
// Read from input file; populate list with SimData objects
reader.readInput(folder + "/trainInput.txt");
// Reference to list of SimData objects (to simplify later steps)
List<SimData> listCases =
// Set up DataWriter (this creates the output file and writes headings)
DataWriter writer =
new DataWriter(folder + "/trainOutput.txt");
// Set up Simrunner (retrieves various objects from the sim which will be set)
SimRunner runner =
new SimRunner(theSim);
// Set up PostProcessor (retrieves scenes and plots which will be saved)
PostProcessor postP =
new PostProcessor(theSim);
// Set up PushoverClient (sends notifications to the smartphone)
PushoverClient client =
new PushoverRestClient();
// The following construct is a "for-each" loop...
for (SimData sD : listCases) {
// Print line to output window to show how far the process has reached
theSim.println("Inside the loop. Running case with angle " + sD.getAngle());
.setTitle("Starting case.")
.setMessage("Inside the loop. Running case with angle " + sD.getAngle())
// Set various conditions, clear previous solution, run simulation for x iterations
runner.runCase(sD, 5);
// Retrieve the drag coefficient from the SimData object and write it to file
// Save hardcopies of vel mag and streamlines scenes, and residual plot
folder + "/velMag" + sD.getAngle() + ".png"
folder + "/residuals" + sD.getAngle() + ".png"
folder + "/strlines" + sD.getAngle() + ".sce"
// Save simulation
folder + "/train" + sD.getAngle() + ".sim"
// Send notification
.setTitle("Stopping case.")
.setMessage("Stopping criteria for case 'train" + sD.getAngle() + "' reached.")
} catch (Exception e) {
// Included for debugging, create a window displaying the error message
null, e.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.