CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Automated png generation for scenes from autosaved files

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 12, 2015, 05:29
Default Automated png generation for scenes from autosaved files
  #1
New Member
 
Adrian Bürger
Join Date: Jun 2015
Location: Karlsruhe, Germany
Posts: 6
Rep Power: 11
adbuerger is on a distinguished road
Hello everyone,

I'm pretty new to the topic of CFD as well as to the software STAR-CCM+, and I hope that somebody in this forum can help me solve my problem:

Over the last two weeks, I ran a simulation that in addition to the autosaves files generated png pictures from a specific scene. Now I realized that I would need the visualization of additional scenes, and I could get them from the autosaved files. But since there are several hundred saved files, I would not want to open every file and generate the pngs by hand, but would like to use a builtin-function (if there is one for this task) or a script for this (while I do not know exactly how to script STAR-CCM+).

Does someone of you know an elegant solution for this, or can point out to me how this could be achieved?

Any suggestions are highly appreciated! Thank you very much for your help!
adbuerger is offline   Reply With Quote

Old   June 15, 2015, 09:26
Default
  #2
Member
 
kris
Join Date: May 2014
Posts: 73
Rep Power: 12
kguntur is on a distinguished road
Hello,

This is what you could do -
1- open one of the files.
2- record a java macro and to all the things you want to do i.e. open a scene, display parts, save the PNG, and save the sim file. (and any other operations that you want to do on all the files)
3- use batch commad to open each sim file and run the above java macro.

the batch command goes something like this
installation directory\starccm+ -batch javafile.java simfile.sim

installation directory is where your starccm+is installed.
in notepad, write the above command for all your files and save it as .bat file.
double click this and it will be done.

you could also use a "loop" within the batch file to loop all your files, if you are good at that.

hope this helps !!
kguntur is offline   Reply With Quote

Old   June 16, 2015, 11:34
Default
  #3
New Member
 
Adrian Bürger
Join Date: Jun 2015
Location: Karlsruhe, Germany
Posts: 6
Rep Power: 11
adbuerger is on a distinguished road
Quote:
Originally Posted by kguntur View Post
Hello,

This is what you could do -
1- open one of the files.
2- record a java macro and to all the things you want to do i.e. open a scene, display parts, save the PNG, and save the sim file. (and any other operations that you want to do on all the files)
3- use batch commad to open each sim file and run the above java macro.

the batch command goes something like this
installation directory\starccm+ -batch javafile.java simfile.sim

installation directory is where your starccm+is installed.
in notepad, write the above command for all your files and save it as .bat file.
double click this and it will be done.

you could also use a "loop" within the batch file to loop all your files, if you are good at that.

hope this helps !!
I recorded the java macro, and now invoke STAR-CCM+ with the batch argument you provided for every sim-file from within a Python script using the subprocess module, while the script also handles e. g. renaming the new png-files. One can even run multiple macros per call if you pass them as a comma-separated list (without blank spaces in between!).

The main, relevant part now looks something like this

Code:
import subprocess

for k in list_of_files:

    p = subprocess.Popen([ \
        "/opt/CD-adapco/STAR-CCM+9.06.011-R8/star/bin/starccm+", \
        "-batch", \
        "/path/to/macro1.java,/path/to/macro2.java", \
        "/path/to/file" + k])

    p.communicate()
just if someone maybe needs this as well in the future.

It works like a charm! You just saved me a lot of time, thank you very much!
adbuerger is offline   Reply With Quote

Old   June 18, 2015, 01:27
Default
  #4
Member
 
kris
Join Date: May 2014
Posts: 73
Rep Power: 12
kguntur is on a distinguished road
Cool. but you can use the following code instead of using python script.
for /f "delims=|" %%f in ('dir /b yourfolder\*.sim') do C:\Program Files\CD-adapco\STAR-CCM+9.04.009\star\bin\starccm+ -batch %%f location\javamacro.java

copy paste that code into a notepad file. Edit the bold part with your values and save the file as .bat
double click this file. And you are done.

This will run the specified macro on all *.sim files in "Your Folder".
kguntur is offline   Reply With Quote

Old   June 24, 2015, 02:43
Default
  #5
New Member
 
Adrian Bürger
Join Date: Jun 2015
Location: Karlsruhe, Germany
Posts: 6
Rep Power: 11
adbuerger is on a distinguished road
Quote:
Originally Posted by kguntur View Post
Cool. but you can use the following code instead of using python script.
for /f "delims=|" %%f in ('dir /b yourfolder\*.sim') do C:\Program Files\CD-adapco\STAR-CCM+9.04.009\star\bin\starccm+ -batch %%f location\javamacro.java

copy paste that code into a notepad file. Edit the bold part with your values and save the file as .bat
double click this file. And you are done.

This will run the specified macro on all *.sim files in "Your Folder".
That's right of course, I used Python for this since I'm simply just much more familiar with it :-) But I think your second post can help other people looking for this, also because your explanations show how to do this on Windows, so thanks again!
adbuerger is offline   Reply With Quote

Reply

Tags
scenes, scripting


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for UDF files of the tutorial "Simulation of Wave Generation in a Tank" seucj Fluent UDF and Scheme Programming 12 August 21, 2015 06:52
automated generation of DPM injection points Wouter FLUENT 5 March 10, 2006 03:45
Latest News in Mesh Generation Robert Schneiders Main CFD Forum 1 February 18, 2000 01:48
Latest new in mesh generation Robert Schneiders Main CFD Forum 0 February 16, 2000 08:12
Latest news in mesh generation Robert Schneiders Main CFD Forum 0 March 2, 1999 05:07


All times are GMT -4. The time now is 18:11.