March 30, 2022 at 10:53 am
Subscriber
Hi
I've solved the problem by pointing the face thread to the face centroid, which is
Thread *t = Lookup_Thread(d,6); /* Interface_Fluid_porous1 */
Thread *t0 = t->t0; /* Access t0 (Pointer to the adjacent cells thread.) from t (face thread) */
And using adjacent Cell Index in the f_loop , which is:
c0 = F_C0(f,t);
Now, the pointers I set are : t, t0, c0. Using c0 and t0 instead of c and t solve the problem in the loop. So the UDF is like:
==================================================
DEFINE_ON_DEMAND(Viscous_Drag1)
{
Domain *d = Get_Domain(1); /*Get the domain ID*/
face_t f; /*Index that identifies a wall face.*/
cell_t c0; /*Cell index that identifies the cell next to the wall.*/
/*Get the thread id of that surface*/
Thread *t = Lookup_Thread(d,6); /* Interface_Fluid_porous1 */
Thread *t0 = t->t0; /* Access t0 (Pointer to the adjacent cells thread.) from t (face thread) */
real viscosity;
if (!Data_Valid_P())
{
return;
}
real NV_VEC (A); /*Area normal vector*/
/* Loop over all surface faces*/
begin_f_loop(f,t)
{
F_AREA(A,f,t); /*Get the area vector*/
c0 = F_C0(f,t);
viscosity += C_MU_EFF(c0,t0);
}
end_f_loop(f,t)
}
=========================================
Best
Thread *t = Lookup_Thread(d,6); /* Interface_Fluid_porous1 */
Thread *t0 = t->t0; /* Access t0 (Pointer to the adjacent cells thread.) from t (face thread) */
And using adjacent Cell Index in the f_loop , which is:
c0 = F_C0(f,t);
Now, the pointers I set are : t, t0, c0. Using c0 and t0 instead of c and t solve the problem in the loop. So the UDF is like:
==================================================
DEFINE_ON_DEMAND(Viscous_Drag1)
{
Domain *d = Get_Domain(1); /*Get the domain ID*/
face_t f; /*Index that identifies a wall face.*/
cell_t c0; /*Cell index that identifies the cell next to the wall.*/
/*Get the thread id of that surface*/
Thread *t = Lookup_Thread(d,6); /* Interface_Fluid_porous1 */
Thread *t0 = t->t0; /* Access t0 (Pointer to the adjacent cells thread.) from t (face thread) */
real viscosity;
if (!Data_Valid_P())
{
return;
}
real NV_VEC (A); /*Area normal vector*/
/* Loop over all surface faces*/
begin_f_loop(f,t)
{
F_AREA(A,f,t); /*Get the area vector*/
c0 = F_C0(f,t);
viscosity += C_MU_EFF(c0,t0);
}
end_f_loop(f,t)
}
=========================================
Best