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

udf for compute pressure drag force

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

LinkBack Thread Tools Search this Thread Display Modes
Old   January 24, 2018, 04:10
Default udf for compute pressure drag force
New Member
Join Date: Dec 2015
Posts: 6
Rep Power: 10
fatemi is on a distinguished road
i want to separate the viscous and pressure drag force in an unsteady simulation which means i want every time step fluent write pressure drag force in a file .
i calculate this formula for pressure drag : Fp=p(pressure) *mag(area)* nx(unit normal in x direcyion and the flow is in x direction)

i write a udf and use F_P (f, t) to obtain pressure and F_AREA(A,f,t) for unit vector
i understand that A=A[0] i + A[1] j that A[0] is mag(A)*nx

here is my udf:

#include "udf.h"


Domain *d;
face_t f;
real nx;
real ny;
real force;
real force2;
real force3;
real force4;
real force5;
real avgP;
int ii;
real NV_VEC (A);
cell_t c;
Thread *t ;

if (!Data_Valid_P())

d = Get_Domain(1); /*Get the domain ID*/
/* int wallId=8; Modify the ID of surface on which you want to calculate the species gradient*/
t=Lookup_Thread(d,5); /* Get the thread id of that surface*/

/* Loop over all surface faces*/

F_AREA(A,f,t); /*Get the area vector*/
nx=(A[0])/NV_MAG (A);
ny=(A[1])/NV_MAG (A);
force = force + ((F_P (f, t)+10174.63) * NV_MAG (A)*(1.0*nx));
force2 = force2 +( (F_P (f, t) +10174.63)* NV_MAG (A));
force3 = force3 +(( F_P (f, t)-10174.63) * NV_MAG (A));
force4 = force4 + ( (F_P (f, t)-10174.63) * (A[0]) );
force5 = force5 +( F_P (f, t) * (A[1]) );

avgP= avgP + F_P (f, t);

printf("mag is = %8.4f\n", NV_MAG (A) );
printf("pressure is = %8.4f\n", F_P (f, t) );
printf("A0 is = %8.4f\n", A[0] );
printf("A1 is = %8.4f\n", A[1] );
printf("nx is = %8.4f\n", nx );
printf("ny is = %8.4f\n", ny );
ii =ii+1;
end_f_loop(f, t)

Message0("Pressuredrag -nx is = %8.4f\n", force );
Message0("Pressuredrag2 -ny is = %8.4f\n", force2 );
Message0("Pressuredrag3 A is = %8.4f\n", force3 );
Message0("Pressuredrag4 A0 is = %8.4f\n", force4 );
Message0("Pressuredrag5 A1is = %8.4f\n", force5);
Message0("avgP A1is = %8.4f\n", avgP/ii);

/*printf("Volume integral of turbulent dissipation: %g\n", sum_diss);*/


problem is that the computed pressure drag force do not match with i report from fluent in reports> forces in x=1 , y=0 direction

i check my unit normal with a case that is true
i wonder if F_P (f, t) return static pressure or not

help me

force = force + ((F_P (f, t)+10174.63) * NV_MAG (A)*(1.0*nx));
here 10174.63 is Pref
i test it without Pref again it doesnt match
fatemi is offline   Reply With Quote

Old   January 26, 2018, 13:27
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
As far as I recall, "F_P(f,t)" returns the static pressure relative to the reference pressure.

Are you sure that your reference pressure is approximately 1.01e4 Pa? -- because a much more common value would be approximately 1.01e5 Pa. In any case, it should not matter for calculating pressure force, as the pressure acts on equal areas on the left side and the right side of an object (assuming that object is completely represented in the model).

"ii" should be initialized to 0 here, I think.

If the pressure reports from Fluent are sufficient, I would advise you to use those instead of a UDF -- for example, by making Fluent report the force at every iteration or timestep (in Calculation Activities, or Monitors); save a transcript file and then edit it in a powerful text-editor.

obscureed 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
Pressure force UDF with Fluent rsarma Fluent UDF and Scheme Programming 3 May 24, 2021 11:35
Drag Force UDF in Non-Newtonian (powerlaw) Fluid ali hemmati Fluent UDF and Scheme Programming 2 March 28, 2019 13:08
Pressure force calculations by FLUENT UDF rsarma Fluent UDF and Scheme Programming 4 January 24, 2018 04:59
Setup/monitor points of pressure and force coefficients siw CFX 3 October 22, 2010 06:07
About UDF for pressure Drag mkrao FLUENT 2 February 8, 2009 05:51

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