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

Applying pressure on a boundary

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 24, 2011, 20:25
Default Applying pressure on a boundary
  #1
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
Hello Everyone,

Been a regular visitor to this site. Recently started playing with UDFs. I am stuck at this one. I have to model a pressure boundary condition similar to a hydrostatic pressure at the inlet.
My problem is that I am not able to get the pressure already available at the first time step at every face of the inlet thread (I use a steady state solution as my initial condition for the unsteady case) and then compute its average. I have to store this as the initial pressure. Then I have to decrease the initially calculated volume Q0 at the inlet with the volume flux and compute pressure P1 using the new remaining volume Q1 to be stored in a user defined memory location (MEM2) and use it in the next time step.

Can anyone take a look and help me out here.

Thanks,
Pranab


#include "udf.h"

DEFINE_PROFILE(pv1, t, index)
{
face_t f;
int n = N_TIME; /*no. of time steps*/
real P1;
real P_sum=0;
real P_avg=0;
real Q0, Q1;
real vol_out;
real mass_flux=0;
real mass_flux_tot=0;
real MEM1, MEM2, MEM3;
Thread *t1;
int d;

int Zone_ID = 22; /*look up the id from the boundary conditions panel*/
d=Get_Domain(1); /*domain*/

t1=Lookup_Thread(d,Zone_ID);

/**Initialize UDM to face-pressure at the first time-step**/
if(n==1) {printf("\nFirst timestep\n");
begin_f_loop(f,t1)
{
P_sum = P_sum + F_P(f,t1);
P_avg = P_sum / 7;

F_UDMI(f,t1,0) = P_avg; /*constant for all iterations*/

Q0 = (P_avg * 10000)/(0.6679 * 9.81); /*initial volume*/

F_UDMI(f,t1,1) = Q0;

F_UDMI(f,t1,2) = Q0; /*constant for all iterations*/

}end_f_loop(f,t1)
}


/**Assign all UDM's to a variable to be used later**/
MEM1 = F_UDMI(f,t1,0);
MEM2 = F_UDMI(f,t1,1);
MEM3 = F_UDMI(f,t1,2); /

begin_f_loop(f,t1)
{
mass_flux = mass_flux + F_FLUX(f,t1);
}end_f_loop(f,t1)

mass_flux_tot = mass_flux;

vol_out = 0.0001* mass_flux_tot/0.6679;

/**Calculate remaining volume & new pressure**/
Q1 = MEM2 - vol_out; /**new volume**/

P1 = Q1 * MEM1 / MEM3; /**new pressure**/
printf("New Pressure = %f\n", P1);

begin_f_loop(f,t1)
{
/**Apply new pressure on the face**/
F_PROFILE(f,t1,index) = P1;
}end_f_loop(f,t1)

/**Update the udm with new Q1**/
F_UDMI(f,t1,1) = Q1;

}
pranab_jha is offline   Reply With Quote

Old   March 29, 2011, 12:37
Default
  #2
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
Hello All,

I am still stuck at the problem... so I decided to narrow down to the place that I was stuck. I am having issues with the UDM here. I used a small UDF to check. Here it is:


#include "udf.h"

DEFINE_EXECUTE_AT_END(abcd)
{
face_t f;
Thread *t1;
int d;
int Zone_ID = 22;
d = Get_Domain(1);

t1 = Lookup_Thread(d,Zone_ID);

begin_f_loop(f,t1)
{
F_UDMI(f,t1,0) = F_P(f,t1);
}
end_f_loop(f,t1)

printf("memory = %f\n", F_UDMI(f,t1,0));

}

But I always get the value of the UDM as 0 when I plot it every iteration.
Can anyone suggest anything. What is it that I am overlooking? Also, in steady state calculations, the UDM never gets printed to the console while in the unsteady calculations it does. This is also bothering me.
pranab_jha is offline   Reply With Quote

Old   March 29, 2011, 13:34
Default
  #3
Senior Member
 
Amir's Avatar
 
Amir
Join Date: May 2009
Location: Montreal, QC
Posts: 735
Blog Entries: 1
Rep Power: 22
Amir is on a distinguished road
Hi,
these changes may help you. (just a suggestion, I didn't check that before)
Code:
#include "udf.h"

DEFINE_EXECUTE_AT_END(abcd)
{
face_t f;
cell_t c;
Thread *t1,*t2;
Domain *d=Get_Domain(1);
int Zone_ID = 22;
t1=Lookup_Thread(d,Zone_ID);
begin_f_loop(f,t1)
{
c=F_C0(f,t1);
t2=THREAD_T0(t1);
F_UDMI(f,t1,0) = C_P(c,t2);
}
end_f_loop(f,t1)

printf("memory = %f\n", F_UDMI(f,t1,0));

}
Amir is offline   Reply With Quote

Old   March 29, 2011, 15:29
Default
  #4
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
Hi Amir,
Thanks for the reply.
My code that I posted earlier did compile after I made some changes:

begin_f_loop(f,t1)
{ Message("test");
val += F_P(f,t1);
F_UDMI(f,t1,0) = val;
val1 = F_UDMI(f,t1,0);
printf("\nmemory = %f\n", val1);
}
end_f_loop(f,t1)

The modified code that you gave me, which utilizes the adjacent cell thread funda also ran, and both gave me the same result. But that did not solve my problem.
My problem is that the pressure on the boundary in my case file is actually 20 Pa. But what returns from the function for each cell is completely different (values like 14 Pa, 10 Pa, 12 Pa, 5 Pa, -3 Pa, etc.) which is wrong. I need the variable (in this case pressure) on the boundary face thread as applied to the boundary in fluent and store the average of all the cell faces in a UDM. (I have not included the averaging process in the above code).

Any suggestions/comments?

Thanks again for the earlier code.
pranab_jha is offline   Reply With Quote

Old   March 31, 2011, 10:37
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
Hi All,

Continuing my discussion here, I would like to ask if somebody has had a problem like this before:

When I use the F_FLUX(f,t) macro to get the value of total pressure on a face thread, I get a value that is not consistent with the mass flow rate that I get from the Report -> Fluxes -> Mass Flow Rate menu.

What can be the reason for this? My model is a "2D axisymmetric" one. Is it because I am missing a factor of 2*pi or something like that in my UDF? I noticed that the difference is a factor of about 6, F_FLUX gives me the lesser value.

Any suggestions?
pranab_jha is offline   Reply With Quote

Old   April 1, 2011, 06:58
Default
  #6
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 17
coglione is on a distinguished road
From the udf-Manuel:
C-side calculations for axisymmetric models in ANSYS FLUENT are made on a 1 radian basis. Therefore, when you are utilizing certain data access macros (e.g., F_AREA or F_FLUX) for axisymmetric flows, your UDF will need to multiply the result by 2*PI (utilizing the macro M_PI) to get the desired value.
cheers
coglione is offline   Reply With Quote

Old   April 1, 2011, 08:20
Default
  #7
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
Thanks Max,
I should have read the manual more carefully.
pranab_jha is offline   Reply With Quote

Reply

Tags
pressure, udf, volume


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
stagnation pressure boundary problem mbgnfrx2 STAR-CD 2 November 25, 2012 23:55
Boundary Condition pressure inlet/oulet for combustion simulations Giuki FLUENT 0 May 6, 2009 10:04
Pressure Boundary Conditions kantipudi Main CFD Forum 1 August 10, 2008 04:07
Convective Heat Transfer - Heat Exchanger Mark CFX 6 November 15, 2004 15:55
what the result is negatif pressure at inlet chong chee nan FLUENT 0 December 29, 2001 05:13


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