// Preprocessors
#include "udf.h"
#include "mem.h"
// Constants
#define CMU 0.09
#define KARMAN 0.4187
#define E 9.793
#define DENSITY 998.2
#define MU 1.003e-3
// Main program
DEFINE_WALL_FUNCTIONS(std_wf, f, t, c0, t0, wf_ret, yPlus, Emod)
{
real wf_value;
Domain *d;
d = Get_Domain(1);
int wall_id = 11;
Thread *t_wall;
Thread *t_adj;
cell_t c_adj;
real f_cen[ND_ND], c_cen[ND_ND], dist;
real rho, mu, k, y_star;
t_wall = Lookup_Thread(d, wall_id);// Identify the wall cell thread
begin_f_loop(f, t_wall)
{
c_adj = F_C0(f, t_wall);// Identify adjacent cell to the wall
t_adj = THREAD_T0(t_wall);// Identify adjacent cell thread
F_CENTROID(f_cen, f, t_wall);// Get face centeroid on the wall
C_CENTROID(c_cen, c_adj, t_adj);// Get cell centeroid adjacent to the
wall
dist = sqrt(ND_SUM(pow(c_cen[0]-f_cen[0],2),
pow(c_cen[1]-f_cen[1],2),pow(c_cen[2]-f_cen[2],2)));
/*Distance from the cell of first layer to the face on the wall*/
//C_UDMI(c_adj, t_adj, 1) = dist;
//rho = C_R(c_adj,t_adj);// Get the density within the cell
//mu = C_MU_L(c_adj,t_adj);// Get the dynamic viscosity within the cell
k = C_K(c_adj,t_adj);// Get the kinetic turb. energy within the cell
y_star = (DENSITY*pow(CMU,(1./4.))*pow(k,(1./2.))*dist)/MU;
//printf("y plus value: %f\n", y_star);
//printf("dist: %d\n", dist);
}
end_f_loop(f, t_wall)
switch (wf_ret)
{
case UPLUS_LAM:
wf_value = y_star;
break;
case UPLUS_TRB:
wf_value = log(E*y_star)/KARMAN;
break;
case DUPLUS_LAM:
wf_value = 1.0;
break;
case DUPLUS_TRB:
wf_value = 1./(KARMAN*y_star);
break;
case D2UPLUS_TRB:
wf_value = -1./(KARMAN*y_star*y_star);
break;
default:
printf("Wall function return value unavailable\n");
}
return wf_value;
}