·Ö±ðʹÓÃÈçÏÂÁ½¸öUDF¼ÆËãVOFÖÐÌå»ý·ÖÊýµÄÌݶȣ¬Á½Ö»Çé¿öÏÂÌݶÈÖµ¶¼ÊÇ0£¿
Çë¸ßÊÖÖ¸½Ì£¬UDFÊÇ·ñÓÐʲôÎÊÌ⣿
casÎļþ¼°UDFÔÚ¸½¼þÖС£
UDF2:
#include "udf.h"
DEFINE_ON_DEMAND(on_demand_calc)
{
Domain *subdomain;
/* declare domain pointer since it is not passed as an argument to the DEFINE macro */
Thread *cell_thread;
cell_t cell;
float a1,a2,x[2];
subdomain=Get_Domain(2); /* returns phase with ID=2 domain pointer£¬meanning primary phase*/
/* Loop over all cell threads in the domain */
thread_loop_c(cell_thread,subdomain)
{
/* Loop over all cells */
begin_c_loop(cell,cell_thread)
{
C_UDSI(cell,cell_thread,0)=C_VOF(cell,cell_thread);
}
end_c_loop(cell,cell_thread)
begin_c_loop(cell,cell_thread)
{
C_CENTROID(x,cell,cell_thread);
C_UDMI(cell,cell_thread,0)=NV_MAG(C_UDSI_G(cell,cell_thread,0));
a1=C_VOF(cell,cell_thread);
a2=C_UDMI(cell,cell_thread,0);
printf("location:%f,%f,vof:%f,gradient:%f\n",x[0],x[1],a1,a2);
}
end_c_loop(cell,cell_thread)
}
}
UDF3£º
#include "udf.h"
DEFINE_ON_DEMAND(grad)
{
Domain *mixture_domain, *sub_domain;
Thread *cell_thread;
cell_t cell;
int phase_domain_index;
float a1,a2,x[2];
mixture_domain=Get_Domain(1);
sub_domain_loop(sub_domain,mixture_domain,phase_domain_index)
{
/* loop if primary phase */
/* if (DOMAIN_ID(sub_domain) == 2) */
/* loop over all cell threads in the primary phase domain */
thread_loop_c(cell_thread,sub_domain)
{
/* loop over all cells in primary phase cell threads */
begin_c_loop_all(cell,cell_thread)
{
C_CENTROID(x,cell,cell_thread);
C_UDSI(cell,cell_thread,0)=C_VOF(cell,cell_thread);
C_UDMI(cell,cell_thread,0)=NV_MAG(C_UDSI_G(cell,cell_thread,0));
a1=C_VOF(cell,cell_thread);
a2=C_UDMI(cell,cell_thread,0);
printf("location:%f,%f,vof:%f,gradient:%f\n",x[0],x[1],a1,a2);
}
end_c_loop_all(cell,cell_thread)
}
}
}![]()
Ë®-¿ÕÆøÏà·Ö²¼ |