# Problem with loop in CFX-Post macro

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

 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: 10 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); !}``` I hope that helps.

 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: 10 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.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Stephen Lau CFX 1 April 18, 2007 03:02 cfddummy Siemens 1 April 9, 2007 12:37 Kevin CFX 3 October 18, 2006 12:18 Matthew Morse Tecplot 5 July 5, 2004 01:31 Wen Long Main CFD Forum 9 April 1, 2004 12:38

All times are GMT -4. The time now is 10:29.

 Contact Us - CFD Online - Privacy Statement - Top