Optimizing simulation workflows for Simcenter STAR-CCM+

Written in 2024. Menus and defaults may differ in newer releases.

In short

Old .sim files fill your disk as studies grow. This post builds a Linux shell script that searches a folder tree for Simcenter STAR-CCM+ .sim files, opens each in batch, runs a ClearClose.java macro to clear mesh and solution data, saves the file and removes temporary files. The script can be downloaded.

Imagine you’re working on a project that involves running simulations in Simcenter STAR-CCM+. Each simulation run generates a .sim file containing crucial data about the model, mesh, and solution. As your project progresses or when you perform a Design Space Exploration, these files accumulate, consuming valuable disk space. The only way to free up disk space is to clear mesh and solution data to archive them for future. Manually performing these tasks can be time-consuming and error-prone. In this article, we’ll explore the creation of a Linux shell script that automates these processes, making data management a breeze.

Introducing Automation: The Shell Script Solution

To address these challenges, we’ll create a shell script that automatically detects .sim files, opens them in Simcenter STAR-CCM+, clears mesh and solution data, and saves the modified files. Here’s how it works:

  1. Detecting .sim Files: The script starts by scanning the specified directory (and its subdirectories) for files with the .sim extension. We can recursively search a directory and its sub-directories, by writing a recursive function that takes as initial argument the path of the target directory (argument). It iterates through each entry of the current directory and invokes itself whenever that entry is a directory.

  2. Bash script with a recursive iterate function that walks a directory and its subdirectories
    Then we check each file in the directory for its ending:

  3. Bash check for files ending in .sim and storing the current path temporarily
  1. Store Path temporarily: Once a sim file was detected, we need to store the path temporarily since we are continuously changing the directory.
  2. Automating Simcenter STAR-CCM+ Operations: Once the .sim files are identified, the script utilizes Simcenter STAR-CCM+’s command-line to open each file to run the ClearClose.java script. With each .sim file open, the script executes commands within Simcenter STAR-CCM+ to clear the mesh and solution data. This step is crucial for conserving disk space while retaining the essential aspects of the simulation setup.
    Bash line running STAR-CCM+ in batch mode with the ClearClose.java macroClearClose.java:
    ClearClose.java code clearing the solution and the generated meshes of the active simulation
  3. Saving Modified Files: After clearing the data, the script instructs Simcenter STAR-CCM+ to save the modified .sim file, ensuring that the changes are preserved for future use.
    ClearClose.java code reading the stored path from the tmp file and saving the simulation under it
  4. Clean up: Simcenter STAR-CCM+ creates temporary files every time you save the simulation. Thus we need to clean up and remove all *.sim~ files.
    find command removing the temporary *.sim~ backup files
  5. Run: Last step is the application on your simulation directory. Add the path to your Simcenter STAR-CCM+ installation as well as the ClearClose.java macro.
    Script header setting the paths to the ClearClose.java macro and the STAR-CCM+ executable
    Say that you have an archive of completed project where you dump all finished project folders. Navigate to the script we are building and execute: Running loopFiles.sh on the archive root directory

Conclusion

By automating the management of simulation files, we can streamline workflows, save time, and ensure consistency in data handling. Whether you’re dealing with a handful of simulations or a vast dataset, a well-designed shell script can be a valuable tool in your arsenal. With the approach outlined in this article, you’ll be better equipped to tackle the challenges of data management in the world of CFD and simulation.

Have you ever automated file operations in your simulation workflows? Share your experiences and insights with us support@volupe.com! Let’s continue the conversation on efficient data management in Simcenter STAR-CCM+.

Working with Simcenter STAR-CCM+?

More Simcenter STAR-CCM+ articles

All 255 Simcenter STAR-CCM+ articles

Florian Vesting and seven other application specialists write here.

Loading

We use your address only to send these emails and never pass it to Siemens or other partners. Every email has an unsubscribe link. Privacy policy