CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

error: uninitialized local variable 't' used

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   September 21, 2010, 23:19
Default error: uninitialized local variable 't' used
  #1
Senior Member
 
MASOUD
Join Date: Mar 2009
Posts: 102
Rep Power: 8
MASOUD is on a distinguished road
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;

}
MASOUD is offline   Reply With Quote

Old   June 23, 2011, 17:53
Default
  #2
Member
 
Join Date: Mar 2011
Posts: 38
Rep Power: 6
aleisia is on a distinguished road
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:
Originally Posted by MASOUD View Post
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;

}
aleisia is offline   Reply With Quote

Old   June 24, 2011, 00:59
Default
  #3
Senior Member
 
MASOUD
Join Date: Mar 2009
Posts: 102
Rep Power: 8
MASOUD is on a distinguished road
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)
}
MASOUD is offline   Reply With Quote

Old   November 26, 2012, 06:24
Default
  #4
Senior Member
 
rkhr
Join Date: May 2011
Posts: 211
Rep Power: 7
Kanarya is on a distinguished road
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!
Kanarya is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 15:33
BlockMeshmergePatchPairs hjasak OpenFOAM Native Meshers: blockMesh 11 August 15, 2008 07:36
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02: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


All times are GMT -4. The time now is 03:22.