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.
#define CON 1
int phase_domain_index = 0.;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
Thread *ppt = pt[phase_domain_index];
C_UDMI(c,t,0) = C_VOF_G(c,ppt);