CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ANSYS Meshing & Geometry

[ICEM] Scripting if command does not work

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 24, 2010, 22:03
Default Scripting if command does not work
  #1
Member
 
Join Date: May 2010
Posts: 44
Rep Power: 7
la7low is on a distinguished road
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!!!

Last edited by la7low; October 28, 2010 at 10:49.
la7low is offline   Reply With Quote

Old   February 21, 2012, 06:20
Default how i will do it.
  #2
CRT
New Member
 
Carles
Join Date: Jan 2012
Location: Karlsruhe
Posts: 29
Rep Power: 5
CRT is on a distinguished road
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
CRT is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to work with constant pressure? Martin CD-adapco 2 February 25, 2009 14:23
Getting FoamX to work shaun OpenFOAM Installation 12 March 23, 2007 09:55
work related to brake study of a vehical aero CD-adapco 3 November 23, 2006 08:43
Why do the Plant library cases don't work? Alumna Phoenics 6 June 22, 2004 12:08
why my In-Form doesn't work? green Phoenics 2 May 27, 2004 21:03


All times are GMT -4. The time now is 12:41.