Bruno Machado |
December 9, 2016 10:27 |
I have a convective term in my udf for this equation, which I had implemented as a source.
It is defined as
Code:
C_H2O_LIQ_CONVECTIVE_SRC(c,ct) = - LIQUID_WATER_DENSITY * (C_MU_L(c,ct)*LIQUID_RELATIVE_PERMEABILITY(c,ct) / (DYNAMIC_VISCOSITY_LIQUID_H2O(T0)*GAS_RELATIVE_PERMEABILITY(c,ct))) * (C_DUDX(c,ct) + C_DVDY(c,ct) + C_DWDZ(c,ct));
I tried to implement it using the DEFINE_UDS_FLUX macro, nevertheless, the functions GAS_RELATIVE_PERMEABILITY and LIQUID_RELATIVE_PERMEABILITY are defined in the cell, not in the faces. If you have any idea how to make this work, I'd appreciate any insight. The whole function that define the density of the scalar is defined in dens variable.
Code:
DEFINE_UDS_FLUX(my_uds_flux,f,t,i)
{
cell_t c0, c1 = -1;
Thread *t0, *t1 = NULL;
real NV_VEC(psi_vec), NV_VEC(A), flux = 0.0;
real constant0, constant1;
c0 = F_C0(f,t);
t0 = F_C0_THREAD(f,t);
F_AREA(A, f, t);
/* If face lies at domain boundary, use face values; */
/* If face lies IN the domain, use average of adjacent cells. */
if (BOUNDARY_FACE_THREAD_P(t)) /*Most face values will be available*/
{
real dens;
/* Depending on its BC, density may not be set on face thread*/
if (NNULLP(THREAD_STORAGE(t,SV_DENSITY)))
dens = DENSITY IN THE FACE; /* Set dens to face value if available */
else
dens = LIQUID_WATER_DENSITY * (C_MU_L(c0,t0)*LIQUID_RELATIVE_PERMEABILITY(c0,t0) / (DYNAMIC_VISCOSITY_LIQUID_H2O(T0)*GAS_RELATIVE_PERMEABILITY(c0,t0))); /* else, set dens to cell value */
NV_DS(psi_vec, =, F_U(f,t), F_V(f,t), F_W(f,t), *, dens);
flux = NV_DOT(psi_vec, A); /* flux through Face */
}
else
{
c1 = F_C1(f,t); /* Get cell on other side of face */
t1 = F_C1_THREAD(f,t);
constant0 = LIQUID_WATER_DENSITY * (C_MU_L(c0,t0)*LIQUID_RELATIVE_PERMEABILITY(c0,t0) / (DYNAMIC_VISCOSITY_LIQUID_H2O(T0)*GAS_RELATIVE_PERMEABILITY(c0,t0)));
constant1 = LIQUID_WATER_DENSITY * (C_MU_L(c1,t1)*LIQUID_RELATIVE_PERMEABILITY(c1,t1) / (DYNAMIC_VISCOSITY_LIQUID_H2O(T0)*GAS_RELATIVE_PERMEABILITY(c1,t1)));
NV_DS(psi_vec, =, C_U(c0,t0),C_V(c0,t0),C_W(c0,t0),*,constant0);
NV_DS(psi_vec, +=, C_U(c1,t1),C_V(c1,t1),C_W(c1,t1),*,constant1);
flux = NV_DOT(psi_vec, A)/2.0; /* Average flux through face */
}
/* ANSYS FLUENT will multiply the returned value by phi_f (the scalar's
value at the face) to get the "complete'' advective term. */
return flux;
}
|