Best practices to transfer variable between two DEFINE_FUNCTION
Hello everyone,
I would like to know the best practices for transferring a variables between two define functions with UDM in parallel mode. Why is it so hard ? Most of the time I receive segmentation fault. What is the proper procedure when UDMs are used? Example, should i define memory first, initialize and then load UDF or I can load UDF and then initialize. I would like to learn the nuances as it is very depressing and boring when we get segmentation fault. |
Quote:
what are you trying to do? Start with single-core |
THREAD_SHADOW and F_SHADOW for shadow velocity inlet
Dear Alexander,
Thank you for your reply. Indeed, I made a logical error. I would like to access the call face and thread of one velocity inlet inside another. I used tle=THREAD_SHADOW(tve); fle=F_SHADOW(fve,tve); for this purpose. le- liquid evaporator and ve - vapor evaporator. They are shadow to each other but velocity inlet boundary as I am simulating liquid-vapor interface in heat pipe where I need to assign radial velocity and temperature. I am receiving the following error. D:\leonard validation\libudfaabvvvbcccddaa\src\pipe.c(19) : warning C4700: uninitialized local variable 'fve' used D:\leonard validation\libudfaabvvvbcccddaa\src\pipe.c(125) : warning C4700: uninitialized local variable 'fve' used Is there a workaround for this problem to access the cell face id and thread id of another shadow boundary (not wall)? I have attached my UDF. your help would be greatly appreciated. #include "udf.h" Thread *tve; Thread *tle; Thread *t0; Thread *t0_s; DEFINE_INIT(my_init_udf,d) { #if !RP_HOST face_t fve; face_t fle; cell_t c0; cell_t c0_s; { begin_c_loop(c0,t0) { tve=Lookup_Thread(Get_Domain(1),20); c0 = F_C0(fve,tve); t0 = F_C0_THREAD(fve,tve); C_UDMI(c0,t0,0) = 0.0; Message("first udmi is %g\n", C_UDMI(c0,t0,0)); } end_c_loop(c0, t0); } { begin_c_loop(c0_s,t0_s) { tve=Lookup_Thread(Get_Domain(1),20); tle=THREAD_SHADOW(tve); fle=F_SHADOW(fve,tve); c0_s = F_C0(fle,tle); t0_s = F_C0_THREAD(fle,tle); C_UDMI(c0_s,t0_s,1) = 0.0; Message("first udmi is %g\n", C_UDMI(c0_s,t0_s,1)); } end_c_loop(c0_s, t0_s); } # endif } DEFINE_ADJUST(pipe, domain) { #if !RP_HOST face_t fve; face_t fle; cell_t c0; cell_t c0_s; real temp_cell_ve, press_cell_ve, rho_cell_ve; real rho_cell_le; real hfg = 2360000.0; real R = 8314.0; real M = 18.015; real RR; real s = 0.03; real po = 101325.0; real to = 373.0; real ti = 324.7278; real p_op = 13450.0; real a1, a2, a3; real mdot; real pi; real vel_ve, vel_le; begin_f_loop(fve, tve) { tve=Lookup_Thread(Get_Domain(1),20); tle=THREAD_SHADOW(tve); fle=F_SHADOW(fve,tve); c0 = F_C0(fve,tve); t0 = F_C0_THREAD(fve,tve); c0_s = F_C0(fle,tle); t0_s = F_C0_THREAD(fle,tle); temp_cell_ve = C_T(c0,t0); press_cell_ve = C_P(c0,t0); rho_cell_ve = C_R(c0,t0); rho_cell_le = C_R(c0_s,t0_s); RR = R/M; pi = po*exp((hfg/RR)*((1/to)-(1/ti))); a1 = (2.0*s)/(2.0-s); a2 = 1/sqrt(2*M_PI*RR); a3 = ((p_op+press_cell_ve)/sqrt(temp_cell_ve))-(pi/sqrt(ti)); mdot = a1*a2*a3; vel_ve=mdot/rho_cell_ve; vel_le=mdot/rho_cell_le; C_UDMI(c0,t0,0)=vel_ve; C_UDMI(c0_s,t0_s,1)=-vel_le; Message("vel_ve is %g\n", C_UDMI(c0,t0,0)); Message("vel_le is %g\n", C_UDMI(c0_s,t0_s,0)); } end_f_loop(fve, tve) #endif } DEFINE_PROFILE(vaporside_velocity, t, i) { #if !RP_HOST face_t fve; face_t fle; cell_t c0; begin_f_loop(fve, tve) { tve=Lookup_Thread(Get_Domain(1),20); c0 = F_C0(fve,tve); t0 = F_C0_THREAD(fve,tve); F_PROFILE(fve, tve, i) = C_UDMI(c0,t0,0); Message("vel_ve profile is %g\n", C_UDMI(c0,t0,0)); } end_f_loop(fve, tve) #endif } DEFINE_PROFILE(liquidside_velocity, t, i) { #if !RP_HOST face_t fve; face_t fle; cell_t c0_s; begin_f_loop(fle, tle) { tve=Lookup_Thread(Get_Domain(1),20); tle=THREAD_SHADOW(tve); fle=F_SHADOW(fve,tve); c0_s = F_C0(fle,tle); t0_s = F_C0_THREAD(fle,tle); F_PROFILE(fle, tle, i) = C_UDMI(c0_s,t0_s,1); Message("vel_le profile is %g\n", C_UDMI(c0_s,t0_s,1)); } end_f_loop(fle, tle) #endif } |
All times are GMT -4. The time now is 01:39. |