Jul-28-2023, 03:30 PM
Hello,
It has been a while since I have coded in C++, and I am new to python since I am currently making macros for a CFD software called STAR-CCM.
Backround
I plan on running a sim on the cluster, which means I have CAD software generating a new geometry file for the number of iterations I want, and then importing the geometry file into the CFD software. My macro is created to import the geometry file into the CFD software. The problem is, in every iteration, the geometry file is named differently, such as "geom_{#OfIteration}." So iteration 1 will have a geometry file name "geom_1," iteration 2 has the name "geom_2" and so on...
My Goal
So, my goal is to create a macro that looks for the current geometry file name and renames it to a new name since I already have a STAR .sim file that has mesh settings only for a geometry file named "geom_0." So, therefore, I want to name every geometry file name to "geom_0."
What I know the code should do
Since I have some background in C++, I know that I should create an if-then statement. For instance, I want the code to parse through the file name, and if the name contains "geom" (which it will), then I want the name to be replaced with "geom_0." I am unfamiliar with python syntax, but can someone guide me in achieving this goal? I assume it won't be that difficult since I just want to save the file name as a new name. Maybe I am wrong though.
It has been a while since I have coded in C++, and I am new to python since I am currently making macros for a CFD software called STAR-CCM.
Backround
I plan on running a sim on the cluster, which means I have CAD software generating a new geometry file for the number of iterations I want, and then importing the geometry file into the CFD software. My macro is created to import the geometry file into the CFD software. The problem is, in every iteration, the geometry file is named differently, such as "geom_{#OfIteration}." So iteration 1 will have a geometry file name "geom_1," iteration 2 has the name "geom_2" and so on...
My Goal
So, my goal is to create a macro that looks for the current geometry file name and renames it to a new name since I already have a STAR .sim file that has mesh settings only for a geometry file named "geom_0." So, therefore, I want to name every geometry file name to "geom_0."
What I know the code should do
Since I have some background in C++, I know that I should create an if-then statement. For instance, I want the code to parse through the file name, and if the name contains "geom" (which it will), then I want the name to be replaced with "geom_0." I am unfamiliar with python syntax, but can someone guide me in achieving this goal? I assume it won't be that difficult since I just want to save the file name as a new name. Maybe I am wrong though.