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

[ICEM] Scripting if command does not work

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread 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: 15
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, 05:20
Default how i will do it.
  #2
CRT
New Member
 
Carles
Join Date: Jan 2012
Location: Karlsruhe
Posts: 29
Rep Power: 14
CRT is on a distinguished road
I´m working in a script as well, and i´m don´t 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 "

I´m sorry but i can help u more.. good luck
CRT is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to work with constant pressure? Martin Siemens 2 February 25, 2009 13:23
Getting FoamX to work shaun OpenFOAM Installation 12 March 23, 2007 08:55
work related to brake study of a vehical aero Siemens 3 November 23, 2006 07: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 06:35.