Simcenter STAR-CCM+ How to find number of parts,regions, boundaries and interfaces using macro and save the info as text file?

2022-06-21T05:50:56.000-0400
Simcenter STAR-CCM+ Simcenter STAR-CCM+ Virtual Reality Teamcenter Share Simcenter STAR-CCM+ Viewer Simcenter STAR-CCM+ Application Specific Solutions

Summary

There may be scenarios where we may have to know the number of geometry parts, regions, boundaries and interfaces in a sim file. If the parts are few then it will be easy to count it manually but if there are hundreds to thousands of boundaries/parts this will be very difficult to count manually. In this article we will be creating a macro that does this job automatically and writes the info into a text file.


Details

To create a macro to count parts, regions, boundaries and interfaces follow below steps,

We are going to use collection class for our case.
Collection<GeometryPart> colParts = simulation_0.getGeometryPartManager().getLeafParts() - To collect geometry parts
Collection<Region> regionpart=simulation_0.getRegionManager().getRegions() - To collect regions
Collection<Boundary> bound=reg1.getBoundaryManager().getBoundaries() - To collect boundaries
Collection<Interface> inter=simulation_0.getInterfaceManager().getObjects() - To collect interfaces

There are two options available in this macro to view the count.
1. View the part count in STAR-CCM+ output window
2. Write the count into in a text file by specifying the file path.

In order to use the first or second method the following info need to be updated in the macro file,
User-added image
Set the savetype as 0 to view the count in STAR-CCM+ output window
Set the savetype as 1 to save the count to a text file
Also for second option update the filepath as shown in below image,
User-added image
Step-1:
Collect the parts for geometry using the command
Collection<GeometryPart> colParts = simulation_0.getGeometryPartManager().getLeafParts()

Step-2:
Create a for loop to count the number of parts one by one using the following command
User-added image
User-added image
Here we have initialized a int variable to store the number of parts count. This procedure can be repeated for others as well.

Step-3;
To write the count info in a text file. This can be done using try catch method
User-added image
User-added image
Find attached sim file and java file for reference

KB Article ID# KB000045107_EN_US

Contents

SummaryDetails

Associated Components

Design Manager Electronics Cooling In-Cylinder (STAR-ICE) Job Manager Simcenter STAR-CCM+