Hi, All
I have written the UDF for time average wall shear stress (TAWSS) but it does not give the right results as expected. It compiled and run successfully, but it does not give the expected results within its limit. Can anyone help me to find out the mistakes in the code?
Thanks and regards
Asif
/******************************************************
Time-averaged wall shear stress (TAWSS)
******************************************************/
#include "udf.h"
#include "math.h"
#include "storage.h"
#include "sg_udms.h"
#define domain_ID 1
#define zone_ID 8
/* Define Names for the WSS UDMI and its components */
DEFINE_EXECUTE_ON_LOADING(nameinit, libudf)
{
Set_User_Memory_Name(0, "uWSSx");
Set_User_Memory_Name(1, "uWSSy");
Set_User_Memory_Name(2, "uWSSz");
Set_User_Memory_Name(3, "TAWSS");
}
/* Initialize the UDM value to zero in complete domain */
DEFINE_INIT(meminit,domain)
{
Thread *c_thread;
cell_t c;
thread_loop_c(c_thread,domain)
{
begin_c_loop(c, c_thread)
{
C_UDMI(c,c_thread,0)= 0; /* cumulative x-component of wss */
C_UDMI(c,c_thread,1)= 0; /* cumulative y-component of wss */
C_UDMI(c,c_thread,2)= 0; /* cumulative z-component of wss */
C_UDMI(c,c_thread,3)= 0; /* TAWSS ****/
}
end_c_loop(c, c_thread)
}
}
/* Calculate wall shear stress and store them in UDM */
DEFINE_EXECUTE_AT_END(TAWSS)
{
Domain *domain;
real area;
face_t f;
real A[ND_ND];
cell_t c, c0;
Thread *t,*t0, *c_thread;
real wallshear [ND_ND];
domain = Get_Domain(domain_ID);
t = Lookup_Thread(domain,zone_ID);
begin_f_loop(f, t)
{
F_AREA(A,f,t);
area = NV_MAG(A);
NV_V(wallshear,=,F_STORAGE_R_N3V(f,t, SV_WALL_SHEAR));
c0 = F_C0(f,t);
t0 = THREAD_T0(t);
C_UDMI(c0,t0,0) += -wallshear[0]/area;
C_UDMI(c0,t0,1) += -wallshear[1]/area;
C_UDMI(c0,t0,2) += -wallshear[2]/area;
C_UDMI(c0,t0,3) = (sqrt(C_UDMI(c0,t0,1)*C_UDMI(c0,t0,1) + C_UDMI(c0,t0,2)*C_UDMI(c0,t0,2) + C_UDMI(c0,t0,3)*C_UDMI(c0,t0,3))/1.0);
}
end_f_loop(f,t)
}