One of the cool features in the ANSYS Workbench is the ability to set up a design study and kick off a bunch of runs that bring back key parameters. This is great for a design exploration but sometimes you actually would like a result plot, or maybe the info in a text file as well. When a design study is done, unless you tell Workbench to save all your run files, it deletes all the files.
To do the posting on ICEM CFD in the workbench project page, I needed to do just that, so I thought I would share my method in case others want to use it.
The way I do it is pretty simple:
- Use a /INQUIRE to get the directory the run is running in
- Use some string functions to get the name of the design point from the directory name
- Temporarily change the jobname
- Save my plots
- Change the jobname back to file
- Copy the files to the User_Files directory.
Here is what it looks like:
1: /post1
2: set,last
3: finish
4: /inquire,aa,directory
5: ii = strpos(aa(1),'dp')
6: ij = strpos(aa(ii+1),'')-1
7: dpn = strsub(aa(1),ii+1,ij)
8: dpn = strcat(dpn,'_')
9: /file,dpn
10: /post1
11: /view,1,1,1,1
12: /vup,1,z
13: /show,png
14: eplot
15: plnsol,u,sum
16: /show,close
17: /sys,copy *.png ......user_files
18: finish
19: /file,file
See how it uses /inquire to get the directory, then strpos(), strsub(), and strcat() to get the design point name. Then it simply changes the file name, does a /show,png and plots. The results are copied using a system command.
Two important things to note:
- You have to do the set command before you change the jobname, otherwise your RST files will not work
- This version is written for windows, you need to use forward slashes and cp for Linux.
You can attach this to a MAPDL system or as a code snippet.