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

Pitot pressure UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 10, 2020, 10:04
Default Pitot pressure UDF
  #1
New Member
 
Join Date: Mar 2020
Posts: 5
Rep Power: 6
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, 5 views)
rabz is offline   Reply With Quote

Old   March 10, 2020, 10:12
Default Define_
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 12, 2020, 19:32
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ 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
Code:
/*-----------------------------------------------------------
Test on ways to process pitot pressure during a simulation
-------------------------------------------------------------*/
#include "udf.h"
DEFINE_EXECUTE_AT_END(pitot_pressure)
{
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);

thread_loop_c(t,d)
	{
	begin_c_loop(c,t)
		{
		/*-------------------------
		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));
		M=vmag/sqrt(1.4*287*temp);
		dyna = (dens*pow(vmag,2))/2;
		totp = press + dyna;

		/*--------------------------
		Mach filter
		----------------------------*/
		if (M <= 1)
			{
			pitot = totp;
			}
		else
			{
			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;
		}
	end_c_loop(c,thread)
	}
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
UDF for vapor pressure anuarun Fluent UDF and Scheme Programming 12 December 24, 2021 10:12
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 05:02.