#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
/**************************************************************/
/* UDF for specifying an interfacail area density */
/**************************************************************/
DEFINE_ADJUST(area_density, domain)
{
Thread *t;
Thread **pt;
cell_t c;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,P_PHASE);
real voidx, voidy, voidz=0;
real evap_rate = 0.0;
real int_area = 0.0;
real h_t_rate = 0.0;
{
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG,
Vof_Deriv_Accumulate);
}
{
Alloc_Storage_Vars(domain, SV_T_RG, SV_T_G, SV_NULL);
T_derivatives(domain);
Free_Storage_Vars(domain, SV_T_RG, SV_NULL);
}
mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *tp = pt[P_PHASE];
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = (C_VOF_G(c,tp)[0]*C_T_G(c,t)[0]+
C_VOF_G(c,tp)[1]*C_T_G(c,t)[1]+C_VOF_G(c,tp)[2]*C_T_G(c,t)[2]);
C_UDMI(c,t,0) = (C_VOF_G(c,tp)[0]*C_T_G(c,t)[0]+
C_VOF_G(c,tp)[1]*C_T_G(c,t)[1]);
C_UDMI(c,t,3) = NV_MAG(C_VOF_G(c,tp))*C_VOLUME(c,t);
if(C_VOF(c,tp)>0 && C_VOF(c,tp)<1)
{evap_rate = evap_rate + C_UDMI(c, t, 4);
int_area = int_area + C_UDMI(c,t,3);
h_t_rate = h_t_rate + C_UDMI(c,t,6); }
C_UDMI(c,t,7) = C_UDMI(c,t,6)/C_UDMI(c,t,3);
}
end_c_loop (c,t)
}
/* real avg_ht_rate = h_t_rate/int_area;*/
/* if(N_ITER%30==0)
printf ("%e\n",evap_rate);*/
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
Free_Storage_Vars(domain, SV_T_G, SV_NULL);
}
DEFINE_SOURCE(gas, cell, thread, dS, eqn)
{
real x[ND_ND];
real source;
Thread *tm = THREAD_SUPER_THREAD(thread);
Thread **pt = THREAD_SUB_THREADS(tm);
real Kl = C_K_L(cell, pt[1])*C_VOF(cell, pt[1]),
Kg = C_K_L(cell, pt[0])*C_VOF(cell, pt[0]);
real L = 2270e3;
source = -(Kl+Kg)*C_UDMI(cell,tm,0) / L;
C_UDMI(cell, tm, 1) = source;
C_UDMI(cell,tm,4) = source*C_VOLUME(cell,tm);
C_UDMI(cell,tm,5) = C_VOLUME(cell,tm);
C_UDMI(cell, tm, 2) = -source*L;
C_UDMI(cell,tm,6) = source*L*C_VOLUME(cell,tm);
dS[eqn] =0;
return source;
}
DEFINE_SOURCE(liquid, cell, thread, dS, eqn)
{
real x[ND_ND];
real source;
Thread *tm = THREAD_SUPER_THREAD(thread);
Thread **pt = THREAD_SUB_THREADS(tm);
source = -C_UDMI(cell, tm, 1);
dS[eqn] = 0;
return source;
}
DEFINE_SOURCE(energy, cell, thread, dS, eqn)
{
real x[ND_ND];
real source;
Thread *tm = thread;
source = C_UDMI(cell, tm, 2);
dS[eqn] = 0;
return source;
}
DEFINE_SOURCE(energy_tsat, cell, thread, dS, eqn)
{
real x[ND_ND];
real source;
Thread *tm = thread;
Thread **pt = THREAD_SUB_THREADS(tm);
if(C_VOF(cell, pt[1]) == 0)
{
source = pow(10,30)*(373.15 - C_T(cell,tm));
dS[eqn] = -pow(10,30);
}
else source = 0.0;
return source;
} |