|
[Sponsors] |
March 26, 2009, 10:20 |
Problem with loop in CFX-Post macro
|
#1 |
New Member
Join Date: Mar 2009
Posts: 2
Rep Power: 0 |
Hi everybody!
I am trying to evaluate a frequency-dependent expression inside a loop for different frequency values. A minimum example looks like the following: !for(my $frequency=100;$frequency<2000;$frequency+=10) !{ LIBRARY: CEL: EXPRESSIONS: testvalue=$frequency END END END EXPRESSION EVALUATOR: Evaluated Expression = testvalue END > forceupdate EXPRESSION EVALUATOR !my ($result,$unit) =evaluate("minVal(testvalue)\@Volume0"); !print "\n $result \t $frequency"; !} The problem is that the expression 'testvalue' remains at the value 100 which is the starting value of the for-loop. The output of this function is: 100 710 100 720 100 730 100 740 100 750 100 760 Does anybody have an idea how I could force an update of the expression value so that 'testvalue' and 'frequency' are equal while the loop is running? The output I am looking for would be: 710 710 720 720 730 730 740 740 750 750 760 760 Thanks for your help! |
|
March 26, 2009, 12:12 |
|
#2 |
New Member
Join Date: Mar 2009
Posts: 16
Rep Power: 17 |
CFX Help for the minVal function states: "minVal Returns the minimum value of the specified variable on the specified locator. You should create a User Variable if you want to find the minimum value of an expression."
I belive the following code block will make your simple example work. Whether or not you can modify it to work for your intended purpose I don't know. Code:
!for($frequency = 100; $frequency <150; $frequency +=10) !{ USER SCALAR VARIABLE:testvalue Boundary Values = Conservative Calculate Global Range = Off Expression = $frequency Recipe = Expression Variable to Copy = Pressure END !open (MYFILE, '>>.\Out.txt'); !my ($result,$unit) = evaluate("minVal(testvalue)\@Plane1"); !print MYFILE "\n $result \t $frequency"; !close (MYFILE); !} |
|
March 26, 2009, 12:45 |
It works
|
#3 |
New Member
Join Date: Mar 2009
Posts: 2
Rep Power: 0 |
I managed to get it work by adding some user variables for every perl variable that's changing inside the loop like you did in your listing.
I think the clue for getting the expression updated every loop-cycle is to store the dependent variable somewhere. Thanks LKF! |
|
March 26, 2009, 14:18 |
|
#4 |
New Member
Join Date: Mar 2009
Location: Brazil
Posts: 16
Rep Power: 17 |
Sometimes I have problems with these IsoVolumes. What I usually do, I delete and redefine them at each loop.
For me, this is a POST issue, not a Perl one. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem on mesh import to Ansys CFX 10.0 | Stephen Lau | CFX | 1 | April 18, 2007 04:02 |
Macro problem | cfddummy | Siemens | 1 | April 9, 2007 13:37 |
Proper output of angle of attack in CFX post | Kevin | CFX | 3 | October 18, 2006 13:18 |
TECPLOT 10 macro problem | Matthew Morse | Tecplot | 5 | July 5, 2004 02:31 |
Big loop problem of fortran | Wen Long | Main CFD Forum | 9 | April 1, 2004 13:38 |