|
[Sponsors] |
October 27, 2011, 13:15 |
Run macro for Multiple file
|
#1 |
New Member
Francesco Furini
Join Date: Oct 2011
Posts: 3
Rep Power: 15 |
Hi, unfortunately at now i am only a beginner of Star CCM +. I want get the WSS tecplot (.plt) solution from 160 simulation files. It's a big work, so I created a macro that can be run by a batch file, with 160 lines.
Code:
// STAR-CCM+ macro: export.java package macro; import java.util.*; import star.common.*; import star.base.neo.*; import star.vis.*; import star.flow.*; import java.io.File; public class export extends StarMacro { static final String PLT = ".plt"; public void execute() { Simulation simulation_0 = getActiveSimulation(); Region region_0 = simulation_0.getRegionManager().getRegion("Body_1"); Solution solution_0 = simulation_0.getSolution(); // 2) Impostazione Nome Simulazione x Export final File MySimFile = new File(simulation_0.getSessionPath()); final String SimName = MySimFile.getName(); final String SimTitle = SimName.substring(0, SimName.lastIndexOf(".")); final String SimPath = MySimFile.separator; ImportManager importManager_0 = simulation_0.getImportManager(); importManager_0.setExportParts(new NeoObjectVector(new Object[] {})); importManager_0.setExportBoundaries(new NeoObjectVector(new Object[] {})); importManager_0.setExportRegions(new NeoObjectVector(new Object[] {region_0})); PrimitiveFieldFunction primitiveFieldFunction_0 = ((PrimitiveFieldFunction) simulation_0.getFieldFunctionManager().getFunction("WallShearStress")); VectorMagnitudeFieldFunction vectorMagnitudeFieldFunction_0 = simulation_0.getFieldFunctionManager().getVectorMagnitudeFunction(primitiveFieldFunction_0); importManager_0.setExportScalars(new NeoObjectVector(new Object[] {vectorMagnitudeFieldFunction_0})); importManager_0.setExportVectors(new NeoObjectVector(new Object[] {})); importManager_0.setExportOptionAppendToFile(false); importManager_0.setExportOptionSolutionOnly(false); String Fname23 = SimTitle + PLT; importManager_0.export(resolvePath(Fname23), new NeoObjectVector(new Object[] {region_0}), new NeoObjectVector(new Object[] {}), new NeoObjectVector(new Object[] {}), new NeoObjectVector(new Object[] {vectorMagnitudeFieldFunction_0}), false); } } I hope that it's all clear. Thank you in advance |
|
October 28, 2011, 01:44 |
|
#2 |
Senior Member
Join Date: Oct 2009
Location: Germany
Posts: 636
Rep Power: 22 |
It's no good idea to run 160 files simultaneously. I assume, we aren't talking about exporting models with 500 cells, so keep the available ressources in mind!
What you want to do would require 160 licenses, 160 CPU-cores, enough memory for all 160 processes, enough memory bandwith to prevent the processes from blocking each other and the hard disk would be excited to read and write 160 files at the same time. When the job is small, it shouldn't harm to do it serial. When the job is big, you have to do it serial. To run it, I would just write a shell script or a few lines in awk which executes this macro on all 160 sim-files. Something like you already did, is this right? When you've got enough computational ressources, you might split it up to 2 or more shell scripts, each handling 80 (or less) sim-files. But don't try to do more jobs at the same time than you've got CPU-cores available on the machine. |
|
October 28, 2011, 06:02 |
|
#3 |
New Member
Francesco Furini
Join Date: Oct 2011
Posts: 3
Rep Power: 15 |
Yes excuse me, my bad English.
I used a wrong word, exactly I wanted to say one by one. ok? I want to avoid a batch with 160 macro request, so I asked if it's possible to modify my macro, in order to automate the export process for all my files, NOT SIMOULTANEOUSLY (excuse me), but ONE BY ONE. |
|
October 29, 2011, 06:45 |
|
#4 |
Senior Member
Join Date: Oct 2009
Location: Germany
Posts: 636
Rep Power: 22 |
Okay, in this case sorry for the misunderstanding.
You CAN do it by modifying the macro. But I recommend to do it via batch script. It will finish one run and start the next, exactly like you want it. And it's easier to do it this way, because otherway you would have to open one simulation to executes the macro and opens another one. That can get tricky and is more prone to errors. Do you know how to run a simulation in batch mode? With a command like starccm+ -batch #yourMacro.java #yourSimFile (there might be additional commands like number of CPU's, remote shell etc, depending on your system) Now you don't run it by typing the command by hand, but just put it in a shell script which executes the command line above on several sim-files. On Monday I can post an example how I did this on our cluster, it's essentially only a shell script (on a Linux system). But on a windows system it's pretty much the same. |
|
October 29, 2011, 06:58 |
|
#5 |
New Member
Francesco Furini
Join Date: Oct 2011
Posts: 3
Rep Power: 15 |
Thank you Abdul, I just knew about macro in batch mode,but my problem is that I have hundreds of files that need hundreds of batch rows .
Today I will write the batch, only for don't waste the time. I thank you another time Abdul for you availability |
|
October 29, 2011, 07:13 |
|
#6 |
Senior Member
Join Date: Oct 2009
Location: Germany
Posts: 636
Rep Power: 22 |
Well, when there's a naming convention like simFile001.sim, simFile002.sim etc it should be easy to write the shell script. Otherwise you might just get every file in a specified directory and pass it to the command line.
On Monday I could maybe provide you with some awk lines. I used it to convert hundreds of pictures, but in principle it's similar to your problem: Get a file and pass it's name as argument to a command line. When you would like to modify the java macro, you also would need some referene to the sim-file. Maybe it can be done with a collection of all files in a directory. Then use a short for-loop iterating over the collection to load the sim-files... The command in the macro to load a simulation from an existing sim-file should be Simulation xxl = new Simulation(PathToSimFile); with xxl as simulation reference. I haven't tried it, so you have to try on your own if it works. |
|
November 28, 2011, 15:54 |
|
#7 |
Member
Join Date: May 2010
Posts: 40
Rep Power: 16 |
An example of how to run multiple simulation files consecutively using a macro is given in the help files. Just search for it. However, it will not work as it is if you only got a single license because it will try to start two servers.
You have to add Simulation sim = getActiveSimulation(); sim.kill(); at the beginning of the startAndRun function. Last edited by Ladnam; November 28, 2011 at 15:56. Reason: Links |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
tecio compilation errors in latest 1.6.x | rsamuel | OpenFOAM Bugs | 2 | June 25, 2021 09:10 |
[swak4Foam] GroovyBC the dynamic cousin of funkySetFields that lives on the suburb of the mesh | gschaider | OpenFOAM Community Contributions | 300 | October 29, 2014 19:00 |
ParaView Compilation | jakaranda | OpenFOAM Installation | 3 | October 27, 2008 12:46 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |