CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Question about UDF (http://www.cfd-online.com/Forums/fluent/41756-question-about-udf.html)

summer July 17, 2006 15:49

Question about UDF
 
Hello, everyone. Now I am writing a UDF to define the source term in UDS. I have the unsteady term defined as follows: DEFINE_UDS_UNSTEADY(uns_time,c,mix_thread,i,apu,su ) { cell_t c; Thread *mix_thread; real physical_dt; int i=0;

/*find the threads for the gas-bubble(secondary phase)*/ thread_g=THREAD_SUB_THREAD(mix_thread,s_col); /*secondary phase*/

void_g=C_VOF(c,thread_g); /*gas volume fraction*/

physical_dt=RP_Get_Real("physical-time-step");

*apu=-1/3*void_g/physical_dt; /*implicit part*/ phi_old=C_STORAGE_R(c,thread_g,SV_VOF_M1(i)); *su=1/3*phi_old/physical_dt; /*explicit part*/ } And then I want to use it in another macro called DEFINE_SOURCE in the same c file. Could I use apu and su directly? Need I use the User-defined Memory to store them first? Thanks in advance.

greg July 18, 2006 10:13

Re: Question about UDF
 
i don`t know udf`s well but as I remember (u can chack it everything in UDF User guide) you should use user defined memory for such thing. I attached a udf example. Meybe it will help you

#include "udf.h" static real spark_center[ND_ND]={20e-3, 1e-3}; static int fluid_chamber_ID = 2;

DEFINE_ADJUST(adjust, domain) { real vol, xc[ND_ND], dis[ND_ND], radius; cell_t c; Thread * tc; tc = Lookup_Thread(domain, fluid_chamber_ID); radius = RP_Get_Real("spark/radius"); vol = 0; begin_c_loop_int (c, tc) { C_CENTROID(xc, c, tc); NV_VV(dis, =, xc, -, spark_center); if (NV_MAG(dis) < radius) { vol += C_VOLUME(c, tc); } } end_c_loop_int (c, tc) vol = PRF_GRSUM1(vol); begin_c_loop_int (c, tc)

{

/****** THIS IS A PART U NEED I THINK******/

C_UDMI(c, tc, 1) = vol; } end_c_loop_int (c, tc) return; } DEFINE_SOURCE(energy_source, c, t, dS, eqn) { #if !RP_HOST real xc[ND_ND], dis[ND_ND]; real source, radius, vol, CA, rpm, start_CA; rpm = RP_Get_Real("dynamesh/in-cyn/crank-rpm"); start_CA = RP_Get_Real("spark/start-ca"); CA = rpm*CURRENT_TIME*6+RP_Get_Real("dynamesh/in-cyn/crank-start-angle"); if(CA>=start_CA&&CA<(start_CA+RP_Get_Real("spark/duration")*rpm*6)) { radius = RP_Get_Real("spark/radius");

/******* AND AGAIN WHAT U WANT **********/

vol = C_UDMI(c, t, 1); C_CENTROID(xc, c, t); NV_VV(dis, =, xc, -, spark_center); if (NV_MAG(dis) < radius) { source = RP_Get_Real("spark/energy")/RP_Get_Real("spark/duration")/vol; return source; } else { return 0; } } else { return 0; } #endif }

GOOD LUCK!!!! :)


All times are GMT -4. The time now is 04:17.