CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   STAR-CCM+ (http://www.cfd-online.com/Forums/star-ccm/)
-   -   Run Multiple Files in Batch (http://www.cfd-online.com/Forums/star-ccm/87355-run-multiple-files-batch.html)

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.

Code:

%\starccm+ -batch -np 4 runMultiple.java
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.

Code:

%\starccm+ -batch -np 4 -new runMultiple.java
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.

Code:

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

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

Code:


// STAR-CCM+ macro: runMultiple.java
package macro;
import java.io.*;
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())) {
      startAndRun(f);
    }
  }
  public void startAndRun(File f) {
    System.out.println("\n Starting "+f);
    String fileName = f.getAbsolutePath();
    Simulation sim = new Simulation(fileName);
   
    runmesh();
    initialize_iters();
    sim.getSimulationIterator().step(8);
    String newFileName = fileName.replaceAll("\\.sim","-new.sim");
    sim.saveState(newFileName);
    sim.kill();
  }
  public void initialize_iters() {
    Simulation simulation_0 = getActiveSimulation();
    Solution solution_0 =
      simulation_0.getSolution();
    solution_0.clearSolution();
    InnerIterationStoppingCriterion innerIterationStoppingCriterion_0 =
      ((InnerIterationStoppingCriterion) simulation_0.getSolverStoppingCriterionManager().getSolverStoppingCriterion("Maximum Inner Iterations"));
    innerIterationStoppingCriterion_0.setMaximumNumberInnerIterations(120);
    simulation_0.getSimulationIterator().step(1);
    innerIterationStoppingCriterion_0.setMaximumNumberInnerIterations(45);
  }
  public void runmesh() {
    Simulation simulation_0 = getActiveSimulation();
   
    MeshPipelineController meshPipelineController_0 = simulation_0.get(MeshPipelineController.class);
   
    meshPipelineController_0.clearGeneratedMeshes();
   
    meshPipelineController_0.generateVolumeMesh();
  }
}


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:

http://www.cfd-online.com/Forums/sta...atch-mode.html

olauer April 19, 2011 04:56

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

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


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