CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (https://www.cfd-online.com/Forums/ansys-meshing/)
-   -   [ICEM] Question about the use of ICEM tcl scripting (https://www.cfd-online.com/Forums/ansys-meshing/104676-question-about-use-icem-tcl-scripting.html)

lnk July 12, 2012 15:51

Question about the use of ICEM tcl scripting
 
Hi,

I'm using the ICEM tcl scripting right now. But there are still something about it not clear to me.

The tcl scripting is able to record all my commands at ICEM, so that if I have an idea about changing the geometry to improve my fluid dynamics behavior, I can change it very quickly.

But my project geometry is complex and there are a lot of points. Sometimes if I intend to change the diameter of a circle of my geometry, it takes me a lot of time to find out the correspondent points and change several points very carefully.

I'm wondering is there any way that I can parameterize my geometry like defining the diameters of the circles by parameters so that I can change them easily?:confused:

Best regards and many thanks,
lnk

PSYMN July 13, 2012 08:43

Yes... You can read about this in the programmers guide. (under the Help menu)

In the commands you can use a $variable. At the top of the script, you could "set variable" to some value...

For instance, at the top of the window you could type the following...

Quote:

global tdv_current_viewer
set rotate_angleX 1
set rotate_angleY 2
set turns 5
This would be creating 3 parameters and setting their values to 1, 2, and 5.

you could then use these in expressions to create other parameters (if you want)

Quote:

set angleX [expr ($rotate_angleX * 3.14159) / 180]
set angleY [expr ($rotate_angleY * 3.14159) / 180]
And then you could either use these directly in a line of your replay or create a fancy for loop like this (it basically just rotates your model in view screen)...

Quote:

for {set cur_angle 0} {$cur_angle < [expr 360 * $turns]} {set cur_angle [expr $cur_angle + $rotate_angleX]} {
tdv_rotate_axis $tdv_current_viewer 0 1 0 $angleY
#tdv_rotate_axis $tdv_current_viewer 1 0 0 $angleX
tdv_trans_update $tdv_current_viewer
update
}

Any command you find in the replay can have any number replaced with a $variable or even a $array like this next example.

ic_geo_cre_bsp_crv_n_pnts HELIX "" $pnt_list 0


Just for fun, here is another script. This one makes a helix. The instructions at the start tell you where to put this file and then how to run it from the ICEM CFD message window. You could also add this to the UI with a little more effort. In this one, you set all the initial variable values as you launch the script... (that proc line), and then other variables are calculated from those and used in a loop to generate the points and finally the helix.

Quote:

## source "path"/helix.tcl
## helix
## p1: Center point of base
## d: Diameter of coil
## h: Height per turn
## n: number of turns
## eg. type "source helix.tcl"
## and then type "helix "10 5 2" 1 3 3 curve"

proc helix {p1 d h n {fam ""}} {
set pnt_list ""
set h_he [expr $h/round($n)]
set hei_s [expr $h_he/20.0]
set ang_s [expr 2*3.141592654/20.0]
set d_z 0
set alfa 0
while 1 {
set x_cor [expr [lindex $p1 0]+$d*cos($alfa)/2.0]
set y_cor [expr [lindex $p1 1]+$d*sin($alfa)/2.0]
set z_cor [expr [lindex $p1 2]+$d_z]
set d_z [expr $d_z+$hei_s]
set alfa [expr $alfa+$ang_s]
set pnt[list $x_cor $y_cor $z_cor]
lappend pnt_list $pnt
if {$d_z > $h} break
}
if {$fam == ""} {set fam "HELIX"}
ic_geo_cre_bsp_crv_n_pnts HELIX "" $pnt_list 0
}

PSYMN July 13, 2012 08:51

R14.5 has checkbox parameters...
 
4 Attachment(s)
One other fun bit of information...

In R14.5 (due out later this year), we have added the ability to just click a checkbox to parameterize ICEM CFD (like you would in DM or ANSYS Meshing)...

Attachment 14420

You can even use them to create blocking edge parameters

Attachment 14421

These parameters are then driven by the Workbench Parameter manager.

Of course, this only works when ICEM CFD is launched from within Workbench...

Attachment 14422

Attachment 14421

Far July 13, 2012 08:53

Quote:

Originally Posted by PSYMN (Post 371304)
Yes... You can read about this in the programmers guide. (under the Help menu)

In the commands you can use a $variable. At the top of the script, you could "set variable" to some value...

For instance, at the top of the window you could type the following...



This would be creating 3 parameters and setting their values to 1, 2, and 5.

you could then use these in expressions to create other parameters (if you want)



And then you could either use these directly in a line of your replay or create a fancy for loop like this (it basically just rotates your model in view screen)...




Any command you find in the replay can have any number replaced with a $variable or even a $array like this next example.

ic_geo_cre_bsp_crv_n_pnts HELIX "" $pnt_list 0


Just for fun, here is another script. This one makes a helix. The instructions at the start tell you where to put this file and then how to run it from the ICEM CFD message window. You could also add this to the UI with a little more effort. In this one, you set all the initial variable values as you launch the script... (that proc line), and then other variables are calculated from those and used in a loop to generate the points and finally the helix.

Great. It find it interesting.

Far July 13, 2012 08:55

Will parametrization replace the Tcl scripting in R14.5?

PSYMN July 13, 2012 09:42

Oh no, TCL scripting is a very important part of ICEM CFD... Users would RIOT if we ever threatened to take it away.

This new parametric ability is more about ease of use and connection with the Workbench Parameter manager. TCL scripting still offers more flexibility and power.

In fact, you can also define parameters in Workbench for use in ICEM CFD replay scripts (instead of setting the variable in the script, it is driven by the workbench parameter manager). We are working on a tutorial right now and will release it with the software.

lnk July 13, 2012 13:37

Quote:

Originally Posted by PSYMN (Post 371318)
Oh no, TCL scripting is a very important part of ICEM CFD... Users would RIOT if we ever threatened to take it away.

This new parametric ability is more about ease of use and connection with the Workbench Parameter manager. TCL scripting still offers more flexibility and power.

In fact, you can also define parameters in Workbench for use in ICEM CFD replay scripts (instead of setting the variable in the script, it is driven by the workbench parameter manager). We are working on a tutorial right now and will release it with the software.


May I ask if I have iterative geometry, could I make a iterative loop for it? How? And since the curve and points name are not iterative, how to solve that problem?

Best regards and many thanks,
lnk

PSYMN July 13, 2012 14:49

Yes, you can.

I suggest you start simple and grow from there. Take a look into the programmers guide for more help. There are many things you can do once you understand the basics.

mvoss January 16, 2013 05:42

Quote:

Originally Posted by PSYMN (Post 371318)
Oh no, TCL scripting is a very important part of ICEM CFD... Users would RIOT if we ever threatened to take it away.

This new parametric ability is more about ease of use and connection with the Workbench Parameter manager. TCL scripting still offers more flexibility and power.

In fact, you can also define parameters in Workbench for use in ICEM CFD replay scripts (instead of setting the variable in the script, it is driven by the workbench parameter manager). We are working on a tutorial right now and will release it with the software.

Was the mentioned tut released with WB 14.5 update as i would really want to know more about using wb-parameters within an TCL script.

PSYMN January 16, 2013 09:24

I showed a live demo of how to turn an ICEM CFD script into one that uses Workbench Parameters during a webinar last Thursday. You can find the recording on the ANSYS website (Here and search for ICEM ) (or here is the download link .

I will re-record it for Youtube at some point...

You can also find the instructions if you go into the workbench help (no the ICEM CFD help) and do a search for ICEM CFD... Read down the ICEM CFD Component page until you find the Custom Input Parameter section. It explains the process there.


All times are GMT -4. The time now is 16:21.