Scripting the Application

Scripting allows you to work more efficiently by automating repetitive tasks.

In many situations, a Java file is not needed. If the properties in your simulation file are correctly set, many batch simulations can be run using the default operations with no java file:

starccm+ -batch [SIMULATION]

For example, reports, auto-save, auto-export, and scene hardcopies can all be specified in the simulation properties. You would need a macro to customize extensively, or to automate the setting of the relevant properties so they are the same across simulations.

What Is a Java Macro?

A Simcenter STAR-CCM+ macro is a Java program that is compiled and executed within the Simcenter STAR-CCM+ workspace.

The Java SDK (Software Development Kit) is required for this key reason - to compile the Java macros. Unlike other macro systems, Simcenter STAR-CCM+ does not record every mouse movement, button click, and keystroke, but rather it translates your actions from the workspace into meaningful Java code.

The macros that you write are standard Java so you have access to all the programming constructs of that language, such as loops and conditional constructs. In addition, the Simcenter STAR-CCM+ server exposes a number of objects that you instantiate and manipulate to carry out the sequence of tasks that you require. You can activate a macro with the Play Macro... command.

For security implications, see Product Security.

You can write a macro from scratch, but that would require up-front knowledge about all the objects, attributes, and methods that the server exposes. It is more effective to use the workspace to record the actions you want to perform. Then you can edit the Java file using your favorite text editor to get the exact effect you require. You can then run the macro as often as you need.

The macro is just a Java program, so it does not compile if there are syntax errors. In this instance, error messages are displayed so that you have specific file names, line numbers, and issues to fix.

Macro Files

The macros are stored in a .java file that contains a set of tasks for the program to perform.

Macro files are Java language files that can be recorded as a journal of your interaction with the application. While it is most convenient to create the macro files from within a Simcenter STAR-CCM+ session, they can be manually edited in a text editor. For example, they can be specialized for specific applications using the full power of the Java programming language.

The two most significant macro commands are play and record. As their names suggest, play causes an existing macro file to be executed and record causes the file to be opened for recording. Recording occurs until the stop recording command is executed. A pause option is also available to preclude certain interactions form being recorded into a given macro file while it is still open for recording.