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

UDF for use value of one BC and use it on another BC

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 13, 2010, 06:15
Lightbulb UDF for use value of one BC and use it on another BC
  #1
New Member
 
Xavi
Join Date: Apr 2009
Location: Amsterdam
Posts: 16
Rep Power: 17
xavi is on a distinguished road
Hi,
I would like to create a boundary condition of velocity inlet which depends on the mass flow rate of the pressure outlet boundary condition of the model. It does exist a delay between the value of the mass flow rate of the pressure outlet and the value of the velocity inlet, this delay is represented by the length and the velocity of the fluid through a pipe which connects the pressure outlet and the velocity inlet of the system (and is not modeled in the CFD software). Does anyone have an UDF which reads this value from another BC and uses it in the present BC?
cheers
xavi is offline   Reply With Quote

Old   May 29, 2013, 17:54
Default values from BC
  #2
Member
 
Nick Cleveland
Join Date: Mar 2012
Posts: 35
Rep Power: 14
NCle is on a distinguished road
Hi Xavi,

I'm trying to currently do something similar. Not sure if you still even remember this cause its from 4 years ago. I want to write UDF to adjust velocity inlet speed based on the pressure at that inlet. So I need to read the pressure average from the inlet surface and put into the UDF, not sure how to. Did you figure it out?
NCle is offline   Reply With Quote

Old   May 29, 2013, 20:52
Default
  #3
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
It is not hard. Declare the average pressure in the file scope. Use
Code:
DEFINE_EXECUTE_AT_END
to calculate it. You might need
Code:
Get_Domain Loopup_Thread BEGIN_F_LOOP END_F_LOOP C_P
for such purpose.

The velocity profile then could be specified with
Code:
DEFINE_PROFILE
blackmask is offline   Reply With Quote

Old   May 30, 2013, 10:32
Default surface specification
  #4
Member
 
Nick Cleveland
Join Date: Mar 2012
Posts: 35
Rep Power: 14
NCle is on a distinguished road
Thanks Blackmask. If you have time, I have a general question about your post. I'm pretty new to UDFs also, so is there a way to first just write a UDF that only gets the average pressure and prints it out (do you know of any so I could start from there?) Then I could hopefully add the velocity adjusting part of it. Should I structure my UDF like this?

DEFINE_EXECUTE_AT_END()
{
commands that get average pressure at inlet (I'm wondering how to print this out)
}

DEFINE PROFILE()
{
F_Profile= some function of the pressure from above section (this determines inlet velocity)
}



This is my UDF currently
/************************************************** ******************
UDF for averaging pressure displaying it in the
console at the end of the current iteration or time step
************************************************** *******************/

#include "udf.h"
#include "mem.h"
7
DEFINE_EXECUTE_AT_END(execute_at_end)
{
Domain *d;
Thread *t;
face_t f;
/* Integrate dissipation. */
real sum_diss=0.;
real press;
cell_t c;
d = Get_Domain(1); /* mixture domain if multiphase */
thread_loop_c(t,d)
{
if (FLUID_THREAD_P(t))
{
begin_f_loop(c,t)
sum_diss += C_P(c,t);
end_f_loop(c,t)
press=sum_diss/F_NNODES(f,t);
}
}
printf("AVERAGE PRESSURE AT FACE: %g\n", sum_diss);
fflush(stdout);

}
DEFINE_PROFILE(unsteady_velocity, thread, position)
{
face_t f;
begin_f_loop(f, thread)
{
real time;
time = CURRENT_TIME;

F_PROFILE(f, thread, position) = 1E7;
}
end_f_loop(f, thread)
}

Last edited by NCle; May 31, 2013 at 11:08.
NCle 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



All times are GMT -4. The time now is 21:02.