CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (http://www.cfd-online.com/Forums/ansys-meshing/)
-   -   [ICEM] Scripting if command does not work (http://www.cfd-online.com/Forums/ansys-meshing/81349-scripting-if-command-does-not-work.html)

la7low October 24, 2010 22:03

Scripting if command does not work
 
Hi,
I am doing script file for the meshing of simple 2d domain. I included an if statement in it, but it does not work!

My code:
if $lc/$nc<$lcorner/cos($angle)/$ncorner then ic_hex_set_mesh 11 33 n $nc h1rel 0.0 h2rel 0.0 r1 2 r2 2 lmax 0 default unlocked ic_hex_set_mesh 33 19 n $ncorner h1rel linked 11 33 h2rel 0.0 r1 1.05 r2 2 lmax 0 default unlocked else ic_hex_set_mesh 33 19 n $ncorner h1rel 0.0 h2rel 0.0 r1 2 r2 2 lmax 0 default unlocked ic_hex_set_mesh 11 33 n $nc h1rel 0.0 h2rel linked 33 19 r1 1.05 r2 1.05 lmax 0 default unlocked

Programmers guide help says: "if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN?"

Icem gives the following error message when replaying the script:
"wrong # args: extra words after "else" clause in "if" command while executing"

Actually two ic_hex_set_mesh commands are following the "then" and the "else" parts. Is this the reason for the problem? How could I include min 2 commands after "then" or "else"?

I have also tried the following syntax for the same code suggested by other Tcl guide:
"if {$lc/$nc > $lcorner/cos($angle)/$ncorner} then {
ic_hex_set_mesh 11 33 n $nc h1rel 0.0 h2rel 0.0 r1 2 r2 2 lmax 0 default unlocked
ic_hex_set_mesh 33 19 n $ncorner h1rel linked 11 33 h2rel 0.0 r1 1.05 r2 2 lmax 0 default unlocked
} else {
ic_hex_set_mesh 33 19 n $ncorner h1rel 0.0 h2rel 0.0 r1 2 r2 2 lmax 0 default unlocked
ic_hex_set_mesh 11 33 n $nc h1rel 0.0 h2rel linked 33 19 r1 1.05 r2 1.05 lmax 0 default unlocked
}"

For this I get no error but the if statement does not behave the way I want.

3 more questions on scripting:
1. Does Icem expect the argument of trig functions (sin, cos, etc) to be in degrees or in radians? I think it calculates them in angles, but I want to be 100 % sure, because I think I saw radian somewhere in the programmers guide (although I can not find it now, because only search for topics exist in Icem) and usually all prog languages, math programs use radians.
2. I set the filename as a parameter in the beginning of the script. The script also saves the project and all files with the name given by that parameter, but when I try to open the project again it asks me to browse the tin file then the blk file and so on, because icem looks for filenames by the parameter name itself and not by the value of the parameter. It is strange. How could I resolve this? So that I wont need to browse every file of the project again when I open the project made by my script.
3. What should my script include so that Icem saves the project when finishing the script? There is an exit command, but with a yes it does not work (like in case of fluent journal /exit y if I rem correctly).

Thanks for any answers in advance!!!

CRT February 21, 2012 06:20

how i will do it.
 
Im working in a script as well, and im dont know to much about it.. but i just can say that i will write in this way:

if "$lc/$nc > $lcorner/cos($angle)/$ncorner" "\
ic_hex_set_mesh 11 33 n $nc h1rel 0.0 h2rel 0.0 r1 2 r2 2 lmax 0 default\ ;unlocked\
;ic_hex_set_mesh 33 19 n $ncorner h1rel linkd 11 33 h2rel 0.0 r1 1.05 r2 2\ ;lmax 0 default unlocked\
" else "
ic_hex_set_mesh 33 19 n $ncorner h1rel 0.0 h2rel 0.0 r1 2 r2 2 lmax 0\ ;default unlocked\
;ic_hex_set_mesh 11 33 n $nc h1rel 0.0 h2rel linked 33 19 r1 1.05 r2 1.05\ ;lmax 0 default unlocked\
"

The function cos, I check it and it expect radians.

set pi 3.14159265359
set e [expr "cos($pi)"]
ic_mess " $e "
set e [expr "cos($pi/2)"]
ic_mess " $e "

Im sorry but i can help u more.. good luck


All times are GMT -4. The time now is 14:07.