|
|

楼主 |
发表于 2010-9-26 08:37:10
|
显示全部楼层
/*********************************************************/
/*add the electricity field using the user-defined scalar*/
/*********************************************************/
#include "udf.h"
/*define which user-defined scalars to use*/
#define DIELECTRIC_CONSTANT (1.00005)
#define CAPACITANCE (0.05)
#define REAL_CONSTANT (1.0)
#define ion_move (2.3E-5)
enum
{
VOLT,/*define voltage*/
ELE_CHARG_DENSITY,/*define charge quantity*/
N_REQUIRED_UDS
};
/*user define the memory*/
enum
{
E_X,
E_Y,
E_Z,
E_M,
N_REQUIRED_UDM
};
#define C_VOLT(c,t) C_UDSI(c,t,VOLT)
#define C_VOLT_G(c,t) C_UDSI_G(c,t,VOLT)
#define Q C_UDSI(c,t,ELE_CHARG_DENSITY)
#define C_EX(c,t) C_UDMI(c,t,E_X)
#define C_EY(c,t) C_UDMI(c,t,E_Y)
#define C_EZ(c,t) C_UDMI(c,t,E_Z)
#define C_EE(c,t) C_UDMI(c,t,E_M)
DEFINE_DIFFUSIVITY(volt_diffusivity,c,t,i)
{
real diffusivity;
diffusivity=1.0;
return diffusivity;
}
DEFINE_SOURCE(voltage_source,c,t,dS,eqn) /*define the source*/
{
real volt_source;
volt_source=Q/DIELECTRIC_CONSTANT;
dS[eqn]=0;
return volt_source;
}
DEFINE_UDS_FLUX(current_density,f,t,i)
/*define the current flux*/
{
Thread *t0,*t1=NULL;
cell_t c0,c1=-1;
real NV_VEC(current);
real NV_VEC(A);
/* neighboring cells of face f, and their (corresponding) threads */
t0=F_C0_THREAD(f,t);
c0=F_C0(f,t);
if (NULL!= F_C1_THREAD(f,t))
/* Alternative: if (! BOUNDARY_FACE_THREAD_P(t)) */
{
t1=F_C1_THREAD(f,t);
c1=F_C1(f,t);
}
else
{
t1=NULL;
c1=-1;
}
/* If Face lies at domain boundary, use face values; */
/* If Face lies IN the domain, use average of adjacent cells. */
if (NULL==t1)
/* Alternative: if (BOUNDARY_FACE_THREAD_P(t)) */
{
NV_D(ion_vel, =, F_U(f,t), F_V(f,t), F_W(f,t));
NV_NV(current,=,ion_move*electricity_intensity,+,ion_vel)
}
else
{
NV_D(ion_vel, =, C_U(c0,t0), C_V(c0,t0), C_W(c0,t0));
NV_D(current, =, ion_move*electricity_intensity,+,ion_vel)
}
/* Now ion_vel contains our "ion_vel" from above. */
/* Next, get the face normal vector: */
F_AREA(A, f, t);
/* Finally, return the dot product of both. */
/* Fluent will multiply the returned value */
/* by phi_f (the scalar's value at the face) */
/* to get the "complete" advective term*/
return NV_DOT(current, A);
void update_E(Domain *domain)
{
Thread* t;
cell_t c;
real dVolt[ND_ND];
thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
NV_V(dVolt,=,C_VOLT_G(c,t));
ND_VEC(C_EX(c,t)=-dVolt[0],C_EY(c,t)=-dVolt[1],C_EZ(c,t)=-dVolt[2]);
C_EE(c,t)=NV_MAG(dVolt);
}
end_c_loop(c,t);
}
这是我的UDF语句,希望各位高手帮忙看看,找找错误!编译已经成功,而且在FLUENT操作界面上,自定义函数已经可见。可是在进行插值计算时,出现下列错误提示:
Error:
FlUENT received fatal signal (ACCESS_VIOLATION)
1.Note exact event leading to error
2.Save case/data under new name
3.Exit program and restart to continue
4.Report error to your distributor |
|