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

Problem with loop in CFX-Post macro

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 26, 2009, 10:20
Default Problem with loop in CFX-Post macro
  #1
New Member
 
Join Date: Mar 2009
Posts: 2
Rep Power: 0
chris_101 is on a distinguished road
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!
chris_101 is offline   Reply With Quote

Old   March 26, 2009, 12:12
Default
  #2
LKF
New Member
 
Join Date: Mar 2009
Posts: 16
Rep Power: 17
LKF is on a distinguished road
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.
LKF is offline   Reply With Quote

Old   March 26, 2009, 12:45
Default It works
  #3
New Member
 
Join Date: Mar 2009
Posts: 2
Rep Power: 0
chris_101 is on a distinguished road
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!
chris_101 is offline   Reply With Quote

Old   March 26, 2009, 14:18
Default
  #4
New Member
 
cfdguy's Avatar
 
Join Date: Mar 2009
Location: Brazil
Posts: 16
Rep Power: 17
cfdguy is on a distinguished road
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.
cfdguy 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
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


All times are GMT -4. The time now is 16:28.