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

UDF Data access problems

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 16, 2011, 18:45
Thumbs down UDF Data access problems
  #1
New Member
 
Aaron Mosher
Join Date: Jun 2011
Location: St. Louis
Posts: 5
Rep Power: 14
Mosheraa is on a distinguished road
I'm fairly new to Fluent, and as part of teaching myself the UDF structure I made a small UDF to read area and flow at the boundary.

However, when I printed the data to the screen it gave me nothing but nonsense values. Also, when I directly printed the "M_PI" function, the output was somewhere above 1.6 trillion.

Has anyone encountered similar problems, or have any thoughts about what might be going wrong?

For reference, here is the small UDF I wrote. I applied it as a pressure outlet boundary condition for laminar flow in an axi-symmetric pipe.

/************************************************** **************************************
Test function to debug Fluent/UDF operations
************************************************** **************************************/

#include "udf.h"


/*Test Axisymmetric Floow and Area*/


DEFINE_PROFILE( area_test, t, i )
{
/*Variables*/

real r = 0;
real ri[ND_ND];
real q = 0;

face_t f;


/*Loop Over Faces*/

begin_f_loop( f, t )
{
q += 2*M_PI*F_FLUX( f, t );

F_AREA(ri,f,t);
r += NV_MAG(ri);

F_PROFILE(f,t,i) = 0;

printf( "Inside Loop area: %d\n", F_AREA(ri,f,t) );
printf( "INside LOop flux: %d\n", F_FLUX(f,t) );
}
end_f_loop( f, t )


/*Print out data*/

printf( "Outlet Area is: %d\n", r );
printf( "Outlet flow is: %d\n", q );
printf( "Fluent thinks pi is %d\n", M_PI);
}
Mosheraa is offline   Reply With Quote

Old   June 17, 2011, 03:37
Default
  #2
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
printf("%d",x) outputs data as integer numbers. Your variables are defined as real = floating numbers! The correct format is %g.

cheers
coglione is offline   Reply With Quote

Old   June 17, 2011, 09:52
Default
  #3
New Member
 
John Palmore
Join Date: Jun 2010
Posts: 8
Rep Power: 15
p4lm0r3 is on a distinguished road
One thing to add. I have had problems with UDFs that use FLEUNT builtin functions. Many of the values are not defined until after you initialize your solution. Make sure you initialize your solution before hooking in your UDF. Not sure if this is your error, but if you do this it will help you out in the future.
p4lm0r3 is offline   Reply With Quote

Old   June 17, 2011, 11:35
Default Issue Resolved
  #4
New Member
 
Aaron Mosher
Join Date: Jun 2011
Location: St. Louis
Posts: 5
Rep Power: 14
Mosheraa is on a distinguished road
Thanks everyone for the suggestions, switching the printf statements from %d to %g fixed the issue. I thought the output values looked like min or max integer values, and I was very confused.

As a separate question, does anyone have any suggestions for tracking and updating a user defined variable between iterations? I'm trying to model an autoregulation response in the arteries and then adjust a pressure boundary condition accordingly. The closest thing I have found so far is the F_UDMI function.

~Aaron
Mosheraa is offline   Reply With Quote

Old   June 17, 2011, 13:16
Default
  #5
Member
 
pranab_jha's Avatar
 
Pranab N Jha
Join Date: Nov 2009
Location: Houston, TX
Posts: 86
Rep Power: 16
pranab_jha is on a distinguished road
Quote:
Originally Posted by Mosheraa View Post
As a separate question, does anyone have any suggestions for tracking and updating a user defined variable between iterations? I'm trying to model an autoregulation response in the arteries and then adjust a pressure boundary condition accordingly. The closest thing I have found so far is the F_UDMI function.

~Aaron
Yes, you can use the F_UDMI macro. I have done it.
You can use the value stored at the memory location in the next time step (supposing you are doing this way) and then store the new value back in the memory.
Always, start with a steady state solver, read in the UDF and then run the steady state solver for 1/2 iterations atleast, even if you dont want a steady solution at that instant. Then load the UDF on your boundary or wherever you want it. Then switch to unsteady mode and start your calculation.
This method worked for me. Earlier I used to start my job in batch mode right after reading in the UDFs and used to get memory errors.
pranab_jha is offline   Reply With Quote

Reply

Tags
data access, debugging, udf error


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
I/O of a real value by "DEFINE_RW_FILE" (UDF) Pietro Asinari Fluent UDF and Scheme Programming 1 August 15, 2015 19:08
How can I get access to all flowfield properties throughout the domain by UDF behrang2009 Fluent UDF and Scheme Programming 1 August 6, 2010 14:03
Use of Experimental Data in fluent using UDF anvitaa.sharma FLUENT 2 February 18, 2010 10:46
UDF Data Access Macro Woo Meng Wai FLUENT 0 November 6, 2007 20:23
UDF (write a data file) problem lichun Dong FLUENT 2 July 29, 2005 11:39


All times are GMT -4. The time now is 18:33.