CFD Online Discussion Forums

CFD Online Discussion Forums (
-   STAR-CCM+ (
-   -   Run Multiple Files in Batch (

nickninevah April 18, 2011 10:40

Run Multiple Files in Batch
Hi all,

I found this wonderful example java macro in the Star CCM+ help files. They claim it should allow me to run multiple simulations files consecutively without a need to make a batch file. I've added a few extra pieces of changing the simulation settings, but it's essentially the same.

Except I can't get it to work. If I try to just invoke Star CCM+ in batch mode without any simulation file, it doesn't work.


%\starccm+ -batch -np 4
And if I try to run Star CCM+ with a new simulation command, it tells me that it can't run the new simulation since the batch macro doesn't set it up.


%\starccm+ -batch -np 4 -new
And finally, I tried to run the macro and just specify the first simulation in the list of files I have. All files are stored in one folder, as required by the macro. That still didn't work. Star CCM+ started off running the simulation. It didn't execute any of the commands in the macro.


%\starccm+ -batch -np 4 LocksVes_Rev0.5.sim
Any ideas what I am doing wrong? Thanks for any help.

Windows XP 64-bit, SP3.
2 Dual core Intel Xeon, 3.33 Ghz
RAM: 16.0 gig


// STAR-CCM+ macro:
package macro;
import star.base.neo.*;
import star.common.*;
public class runMultiple extends StarMacro {
  public class SimFileFilter implements FilenameFilter {
    public boolean accept(File dir, String name) {
      return name.endsWith(".sim");
  public void execute() {
    File simDir = new File("E:\\10099 - John Day Locks\\02 Locks with Vessels\\MeshIndependenceStudy_Rev0.5\\Raw Data\\");
    for (File f : simDir.listFiles(new SimFileFilter())) {
  public void startAndRun(File f) {
    System.out.println("\n Starting "+f);
    String fileName = f.getAbsolutePath();
    Simulation sim = new Simulation(fileName);
    String newFileName = fileName.replaceAll("\\.sim","-new.sim");
  public void initialize_iters() {
    Simulation simulation_0 = getActiveSimulation();
    Solution solution_0 =
    InnerIterationStoppingCriterion innerIterationStoppingCriterion_0 =
      ((InnerIterationStoppingCriterion) simulation_0.getSolverStoppingCriterionManager().getSolverStoppingCriterion("Maximum Inner Iterations"));
  public void runmesh() {
    Simulation simulation_0 = getActiveSimulation();
    MeshPipelineController meshPipelineController_0 = simulation_0.get(MeshPipelineController.class);

nomad April 18, 2011 12:47

You need a parallel license in order to run multiple instances of starccm. Do you have that?
Also, I'm not sure if the batch command actually lets you do that. It will let you run macros, and multiple simulation one after another, but multiple simulations at the same time? I'm not so sure.

nickninevah April 18, 2011 15:58

Yes, we do have the parallel licenses. And I am just trying to run the simulations run after another. From what I understand of the macro, it should run through all commands for an entire simulation before looping back to the next simulation file.

I'm new to Java macros, but if I understand the programming correctly, my goal was to have this macro open a simulation file, generate the volume mesh based on existing settings, and then step through the first few timesteps of the simulation, and save the results. Afterwards, the macro should move on to the next simulation in the file folder.

But I don't know why it isn't working.

nomad April 18, 2011 17:31

Syntax issues maybe?
See if you find anything here:

olauer April 19, 2011 04:56

Name of your java macro must follow directly after -batch option.
So try

%\starccm+ -batch -np 4 LocksVes_Rev0.5.sim

karahan October 6, 2017 07:28

Where do you keep your file? Maybe it can't find this macro.

trampoCFD October 12, 2017 06:17

Hi Nicholas,
it's good practice to add: "pause"
on a new line at the end of your batch file. That means the output is kept in the CMD shell, and you can read the error messages.

Best regards,

All times are GMT -4. The time now is 03:12.