Using the gradient of volume fraction effectlively


The gradient of volume fraction is not stored by default. Trying to use the macro C_VOF_G results in segmentation violation. Here is an adjust function that allocates memory for vof gradients and stores that in user defined memory (in the example only the x component of the gradient has been stored). The value is stored in UDMs because the memory for volume fraction gradient is freed in the adjust function too.
These UDMs could be used in other UDFs to use the volume fraction gradients.
This UDF should only be compiled.
#include "udf.h"
#define CON 1

DEFINE_ADJUST(store_gradient, domain)
{
Thread *t;
Thread **pt;
cell_t c;
int phase_domain_index = 0.;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
{
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);
}


mp_thread_loop_c (t,domain,pt)
if (FLUID_THREAD_P(t))
{
Thread *ppt = pt[phase_domain_index];

begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];
}
end_c_loop (c,t)
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
}



Show Form
No comments yet. Be the first to add a comment!