CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Pitot pressure UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   March 10, 2020, 10:04
Default Pitot pressure UDF
New Member
Join Date: Mar 2020
Posts: 1
Rep Power: 0
rabz is on a distinguished road
I am currently trying to create a UDF to calculate the pitot pressure along a series of planes that I already set in a supersonic simulation around an axisymmetric body.

The idea here is to filter the information based on Mach number in such a way that the total pressure (found as the sum of static and dynamic pressures) is used in the subsonic regions of the planes and the total pressure obtained by using Rayleigh's pitot tube equation is used in the supersonic regions.

I am new at doing UDF's and at coding in C (I made and tested the code in python and changed it to C by following notes). I am facing several difficulties at making my UDF in ANSYS Fluent and thus I would like to ask for some support on it. I currently have two main questions:

1) Regarding the UDF I'm not completely sure on the way to use the macros. Given that I'm trying to find a scalar value (pitot pressure) out of field variables I was thinking on using DEFINE_SOURCE. However I don't know if the macro DEFINE_PROPERTY could be used in my case. Could someone give me advice on the different types of macros and when it is recommended to use each of them?

2) I saw several examples of UDF's online but it never came clear to me from which point in the UDF one has to start and end the loop to find the desired property. I've attached the ".c" function in case someone wants to give it a try in Fluent.

Any extra advise regarding the way I'm coding the UDF would be more than welcomed.

Thank you very much for the attention!
Attached Files
File Type: c UDFTest.c (1.2 KB, 2 views)
rabz is offline   Reply With Quote

Old   March 10, 2020, 10:12
Default Define_
Senior Member
vinerm's Avatar
Join Date: Jun 2009
Location: Nederland
Posts: 1,305
Blog Entries: 1
Rep Power: 21
vinerm is on a distinguished road
Though this can be done inside any DEFINE_ function, including DEFINE_PROPERTY that you used, however, as the name clarifies, DEFINE_PROPERTY is used to modify property of fluid or flow and not meant for post-processing.

However, for your scenario, you don't need a UDF. All you need is a Custom Field Function or expression if you are using R19.x. A CFF is just an equation defined in terms of available field variables.

PM to be used if and only if you do not want something to be shared on the Forum
vinerm is offline   Reply With Quote

Old   March 12, 2020, 19:32
Senior Member
Join Date: Apr 2013
Posts: 1,182
Rep Power: 19
AlexanderZ will become famous soon enough
if you still wanna try UDF, you may use user-defined memory, the code will look like this,compile it, in fluent you must allocate memory for UDMI in User-Defined -> memory
Test on ways to process pitot pressure during a simulation
#include "udf.h"
Domain *d;
Thread *t;
cell_t c;
real uc; /*velocity x component*/
real vc; /*velocity y component*/
real wc; /*velocity w component*/
real temp; /*Static temperature*/
real press; /*Static pressuret*/
real dens; /*Density*/
Variables to calculate
real M; /*Mach number*/
real vmag; /*Velocity magnituder*/
real dyna; /*Dynamic pressure*/
real totp; /*Total pressure*/
real pitot; /*Pitot pressure*/

d = Get_Domain(1);

		Fluent fleld variables
		uc = C_U(c,t); /*velocity x component*/
		vc = C_V(c,t); /*velocity y component*/
		wc = C_W(c,t); /*velocity w component*/
		temp = C_T(c,t); /*Static temperature*/
		press = C_P(c,t); /*Static pressuret*/
		dens = C_R(c,t); /*Density*/
		vmag = sqrt(pow(uc,2) + pow(vc,2) + pow(wc,2));
		dyna = (dens*pow(vmag,2))/2;
		totp = press + dyna;

		Mach filter
		if (M <= 1)
			pitot = totp;
			pitot = (pow(((2.4*2.4*pow(M,2))/(5.6*pow(M,2)-0.8)),3.5)*((-0.4+2.8*pow(M,2))/2.4))*press;
		C_UDMI(c,t,0) = pitot;
best regards

press LIKE if this message helped you

How to ask questions:
AlexanderZ is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
UDF for vapor pressure anuarun Fluent UDF and Scheme Programming 5 February 4, 2020 06:27
static vs. total pressure auf dem feld FLUENT 17 February 26, 2016 13:04
sonicFoam - pressure driven pipe: flow continuity violation and waveTransmissive BC Endel OpenFOAM Running, Solving & CFD 3 September 11, 2014 16:29
vaporization pressure UDF Komon Fluent UDF and Scheme Programming 0 September 20, 2011 19:33
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 02:15

All times are GMT -4. The time now is 00:15.