|
[Sponsors] |
September 22, 2010, 00:19 |
error: uninitialized local variable 't' used
|
#1 |
Senior Member
MASOUD
Join Date: Mar 2009
Posts: 102
Rep Power: 17 |
Hi,
I get the following error: warning C4700: uninitialized local variable 't' used warning C4700: uninitialized local variable 'c' used When I compile the UDF (for line 65) What could be the reason? Here is the code: *************************** #include "udf.h" #include "sg.h" /* Define which user-defined scalars to use. */ enum { E_CHARGE_UDS, C_CHARGE_UDS, N_REQUIRED_UDS }; static real ACT_AREA_A=270; static real ACT_AREA_C=300; static real REF_EXCH_CURR_A=2.1; static real REF_EXCH_CURR_C=0.40; static real REV_POT=1.02; static real MW_H2=0.032; static real MW_H2O=0.032; static real MW_O2=0.032; static real MW_CO2=0.044; static real MW_N2=0.032; static real MW_MIX; static real X_H2; static real X_H2O; static real X_O2; static real X_CO2; static real X_N2; static real ALPHA_A=1.5; static real ALPHA_C=0.5; static real NO_ELEC=2; static real FARADAY=96485; static real UNI_GAS_CONS=8.314; static real STOCH_H2=-1; static real STOCH_H2O=1; static real STOCH_O2=-0.5; static real STOCH_CO2_A=1; static real STOCH_CO2_C=-1; static real RXN_RATE_A; static real RXN_RATE_C; static real Z_A; static real ZZ_A; static real ZZZ_A; static real Z_C; static real ZZ_C; static real ZZZ_C; static real source; static real u=0.0; static real domain_ID=30; DEFINE_ADJUST(SUR,d) { u+=0.001; } DEFINE_ADJUST(UDM,d) { Thread *t; cell_t c; MW_MIX=MW_H2*C_YI(c,t,0)+MW_O2*C_YI(c,t,1)+MW_CO2* C_YI(c,t,2)+MW_H2O*C_YI(c,t,3)+MW_N2*C_YI(c,t,4); X_H2=C_YI(c,t,0)*MW_H2/MW_MIX; X_O2=C_YI(c,t,1)*MW_O2/MW_MIX; X_CO2=C_YI(c,t,2)*MW_CO2/MW_MIX; X_H2O=C_YI(c,t,3)*MW_H2O/MW_MIX; X_N2=C_YI(c,t,4)*MW_N2/MW_MIX; Z_A=ACT_AREA_A*REF_EXCH_CURR_A*(pow((X_H2),0.25)); ZZ_A=exp((ALPHA_A*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t))); ZZZ_A=exp(-(ALPHA_C*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t))); RXN_RATE_A=Z_A*(ZZ_A-ZZZ_A); C_UDMI(c,t,0)=RXN_RATE_A; Z_C=ACT_AREA_C*REF_EXCH_CURR_C*pow(X_O2,0.375)*pow (X_CO2,(-1.25)); ZZ_C=exp((ALPHA_A*FARADAY*(-(C_UDSI(c,t,0)-C_UDSI(c,t,1)-REV_POT)))/(UNI_GAS_CONS*C_T(c,t))); ZZZ_C=exp(-(ALPHA_C*FARADAY*(-(C_UDSI(c,t,0)-C_UDSI(c,t,1)-REV_POT)))/(UNI_GAS_CONS*C_T(c,t))); RXN_RATE_C=Z_C*(ZZ_C-ZZZ_C); C_UDMI(c,t,1)=RXN_RATE_C; } |
|
June 23, 2011, 18:53 |
|
#2 | |
Member
Join Date: Mar 2011
Posts: 38
Rep Power: 15 |
Hi, have you figured out the way to eliminate the
"warning C4700: uninitialized local variable 't' used warning C4700: uninitialized local variable 'c' used"? I have the same problem in mu UDF, can you please share your experience with me? Thanks! Quote:
|
||
June 24, 2011, 01:59 |
|
#3 |
Senior Member
MASOUD
Join Date: Mar 2009
Posts: 102
Rep Power: 17 |
Yes, I had not included the looping macro.
Here is the corrected version of the above UDF with some changes: ==================== DEFINE_ADJUST(CUR_DEN_A,d) { cell_t c; Thread *t= Lookup_Thread(d,ID_A); double CURR_D_A; double Z_A; double ZZ_A; double ZZZ_A; double OV_P_A; double MW_MIX_A; double X_H2; double X_H2O; double X_CO2_A; if (FLUID_THREAD_P(t)) begin_c_loop(c,t) { /*MW_MIX=(C_R(c,t)*UNI_GAS_CONS*C_T(c,t))/C_P(c,t);*/ MW_MIX_A=1/((C_YI(c,t,0)/MW_H2)+(C_YI(c,t,2)/MW_CO2)+(C_YI(c,t,3)/MW_H2O) ); X_H2=C_YI(c,t,0)*MW_MIX_A/MW_H2; X_CO2_A=C_YI(c,t,2)*MW_MIX_A/MW_CO2; X_H2O=1-(X_CO2_A+X_H2); Z_A=ACT_AREA_A*REF_EXCH_CURR_A*(pow((X_H2),0.25))* (pow((X_H2O),0.25))*(pow((X_CO2_A),0.25)); OV_P_A=C_UDSI(c,t,0)-C_UDSI(c,t,1); ZZ_A=exp(ALPHA_AA*FARADAY*OV_P_A/(UNI_GAS_CONS*C_T(c,t))); ZZZ_A=exp(-ALPHA_CA*FARADAY*OV_P_A/(UNI_GAS_CONS*C_T(c,t))); CURR_D_A=Z_A*(ZZ_A-ZZZ_A); C_UDMI(c,t,13)=OV_P_A; C_UDMI(c,t,14)=Z_A; C_UDMI(c,t,15)=ZZ_A; C_UDMI(c,t,16)=ZZZ_A; C_UDMI(c,t,0)=u*CURR_D_A; } end_c_loop(c,t) } |
|
November 26, 2012, 06:24 |
|
#4 |
Senior Member
Join Date: May 2011
Posts: 231
Rep Power: 16 |
hi,
I have the same error with following code: #include "udf.h" DEFINE_EXECUTE_AT_END(measure_mass_flow) { float mass_flow, abs_v; Domain *d; Thread *t; cell_t c; mass_flow=0.; /* Get the domain 1 (Mixture) */ d = Get_Domain(1); abs_v=sqrt(C_U(c,t)*C_U(c,t)+C_V(c,t)*C_V(c,t)); thread_loop_c(t, d) { if( THREAD_ID(t) == 5 ) { begin_c_loop(c, t) { mass_flow+=C_R(c,t)*abs_v ; mass_flow=C_UDMI(c,t,0); } end_c_loop(c,t) } printf("mass_flow in outlet:%f/n",mass_flow); } } can you help me? thanks in advance! |
|
October 14, 2016, 05:59 |
hi
|
#5 |
New Member
SARA
Join Date: Jul 2016
Posts: 2
Rep Power: 0 |
i have the same problem with my code
can u help me? thanks. here is my code: #include "udf.h" DEFINE_PROFILE(slip_ncond_x,face_thread,i) // x velocity for non conductive wall { real zeta_p; Thread *t; cell_t c; zeta_p = -0.2*(C_T(c, t) - 273) - 78.2; face_t f; cell_t neig; Thread *cell_thread; Domain *domain = Get_Domain(1); real vel,normal_magnitude,E_normal_x,E_normal_y,E_repai red_x,E_repaired_y; real NV_VEC(A); real mu=0.001003; real eps0=8.85e-12; real eps=80.1; //cell_thread=THREAD_T1(face_thread); cell_thread=THREAD_T0(face_thread); begin_f_loop(f,face_thread) { neig=F_C0(f,face_thread); // Repair E component values............................................ .................................................. ... F_AREA(A,f,face_thread); //Message("x is %g\n", A[0]); normal_magnitude=pow( pow(A[0],2)+pow(A[1],2),0.5); if ( NULL != THREAD_STORAGE(cell_thread,SV_UDS_I(0)) && NULL != T_STORAGE_R_NV(cell_thread,SV_UDSI_G(0)) ) { E_normal_x=ND_DOT(-C_UDSI_G(neig,cell_thread,0)[0],-C_UDSI_G(neig,cell_thread,0)[1],0,A[0],A[1],0)/pow(normal_magnitude,2)*A[0]; E_normal_y=ND_DOT(-C_UDSI_G(neig,cell_thread,0)[0],-C_UDSI_G(neig,cell_thread,0)[1],0,A[0],A[1],0)/pow(normal_magnitude,2)*A[1]; E_repaired_x=-C_UDSI_G(neig,cell_thread,0)[0]-E_normal_x; E_repaired_y=-C_UDSI_G(neig,cell_thread,0)[1]-E_normal_y; } else E_repaired_x = 0 ; //.................................................. .................................................. ........................ F_PROFILE(f,face_thread,i)=-eps0*eps*zeta_p*E_repaired_x/mu; } end_f_loop(f,face_thread) } |
|
October 17, 2016, 05:24 |
|
#6 |
Member
Join Date: Jun 2016
Posts: 66
Rep Power: 11 |
You are trying to use thread t in C_T(c,t) but the program does not know what t is since you did not specify it anywhere. If you want to access temperature value C_T(c,t) in every cell of a thread (which I suppose you would like to do), then you need to use looping macro begin_c_loop(c,t) first which will loop over all cells of a specified thread. And you need to specify the thread still. Maybe cell_thread is what you want to use?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
[blockMesh] BlockMeshmergePatchPairs | hjasak | OpenFOAM Meshing & Mesh Conversion | 11 | August 15, 2008 08:36 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |
Replace periodic by inlet-outlet pair | lego | CFX | 3 | November 5, 2002 21:09 |