|
[Sponsors] |
UDF for use value of one BC and use it on another BC |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 13, 2010, 06:15 |
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 |
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 |
|
May 29, 2013, 17:54 |
values from BC
|
#2 |
Member
Nick Cleveland
Join Date: Mar 2012
Posts: 35
Rep Power: 14 |
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? |
|
May 29, 2013, 20:52 |
|
#3 |
Senior Member
|
It is not hard. Declare the average pressure in the file scope. Use
Code:
DEFINE_EXECUTE_AT_END Code:
Get_Domain Loopup_Thread BEGIN_F_LOOP END_F_LOOP C_P The velocity profile then could be specified with Code:
DEFINE_PROFILE |
|
May 30, 2013, 10:32 |
surface specification
|
#4 |
Member
Nick Cleveland
Join Date: Mar 2012
Posts: 35
Rep Power: 14 |
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. |
|
|
|