KR124: Check for the Boundary types in UDF


Sometimes it becomes necessary to modify/ operate on a specific type of boundaries dynamically i.e., during the runtime. For this purpose we need to retrieve the type of boundary in an UDF.

Boundary Type Macro
Wall THREAD_F_WALL
Interior THREAD_F_INTERIOR
Symmetry THREAD_F_SYMMETRIC
Periodic THREAD_F_PERIODIC
Mass Flow Inlet THREAD_F_MFINLET
Pressure Inlet THREAD_F_PINLET
Pressure Outlet THREAD_F_POUTLET
Pressure Farfield THREAD_F_PFAR
Velocity Inlet THREAD_F_VINLET
Outflow THREAD_F_OUTFLOW

An UDF to print Area weighted average Temperature and the Mass flow rate at Pressure outlet boundary.
#include "udf.h"
DEFINE_ON_DEMAND(Data_out)
{
Thread *t;
face_t f;
Domain *domain;
real temp,atemp=0.,area,tarea=0.,flow=0.;
domain= Get_Domain(1);
thread_loop_f(t, domain)
{
if(THREAD_TYPE(t)==THREAD_F_POUTLET)
{
begin_f_loop(f, t)
{
area= F_AREA(A,f,t);
temp=F_T(f,t);
atemp+=F_T(f,t)*area;
tarea+=area;
flow+= F_FLUX(f,t);
}
end_f_loop(f, t)
atemp/=tarea;
int zone_ID = THREAD_ID(t);
Message(`Area Weighted Average Temperature on zone ID %d is %g`, zone_ID,atemp);
Message(`Mass Flow rate is %g Kg/s`,flow);
atemp=0.;
tarea=0.;
flow=0.;
}
}
}





Show Form
No comments yet. Be the first to add a comment!