找回密码
 注册
查看: 2234|回复: 0

请高手指点一下UDF编译错误

[复制链接]
发表于 2006-3-19 14:36:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
我编译UDF中文说明中DPM的一个例子,名称为UDF for extending postprocessing of wall impacts 的那个。编译按步骤作的,但出现错误,请版主赐教。
错误提示为:
Error: D:\\320\302\275\250\316\304\274\376\274\320\v.c: line 88: P_USER_REAL: undeclared variable
是何原因?
第line88:  P_USER_REAL(p,0) = 0;
全部程序为:
/**********************************************************************/
/* UDF for extending postprocessing of wall impacts */
/**********************************************************************/
#include "udf.h"
#define MIN_IMPACT_VELO 0.1000
Domain *domain;
enum /* Enumeration of used User Defined Memory Locations. */
{
NUM_OF_HITS, /* Number of particle hits into wall face considered.*/
AVG_DIAMETER, /* Average diameter of particles that hit the wall. */
AVG_RADI_VELO, /* Average radial velocity of "" "" ------------ */
NUM_OF_USED_UDM
};
int UDM_checked = 0; /* Availability of UDMLs checked? */
void reset_UDM_s(void); /* Function to follow below. */
int
check_for_UDM(void) /* Check for UDMLs'; availability... */
{
Thread *t;
if (UDM_checked)
return UDM_checked;
if (!rp_axi)
Internal_Error("UDF-Error: only valid for 2d-axisymmetric cases!\n");
thread_loop_c(t, domain) /* We require all cell threads to.. */
{                  /* provide space in memory for UDML */
/*if (FLUID_THREAD_P(t)) */
if (NULLP(THREAD_STORAGE(t,SV_UDM_I)))
return 0;
}
UDM_checked = 1; /* To make the following work properly... */
reset_UDM_s(); /* This line will only be executed once, */
return UDM_checked; /* because check_for_UDM checks... */
} /* ...for UDM_checked first. */
void
reset_UDM_s(void)
{  
Thread *t;
cell_t c;
face_t f;
int i;
if (!check_for_UDM()) /* Don';t do it, if memory is not available. */
return;
CX_Message("Resetting User Defined Memory...\n");
thread_loop_f(t, domain)
{
if (NNULLP(THREAD_STORAGE(t,SV_UDM_I)))
{
begin_f_loop(f, t)
{
for (i = 0; i < NUM_OF_USED_UDM; i++)
F_UDMI(f, t, i) = 0.;
}
end_f_loop(f, t)
}
else
{
CX_Message(" Skipping FACE thread no. %d..\n", THREAD_ID(t));
}
}
thread_loop_c(t, domain)
{
if (NNULLP(THREAD_STORAGE(t,SV_UDM_I)))
{
begin_c_loop(c, t)
{
for (i = 0; i < NUM_OF_USED_UDM; i++)
C_UDMI(c, t, i) = 0.;
}
end_c_loop(c, t)
}
else
{
CX_Message(" Skipping CELL thread no. %d..\n", THREAD_ID(t));
}
}               /* Skipping Cell Threads can happen if the user */
/* uses reset_UDM prior to initializing. */
CX_Message(" --- Done.\n");  
}
DEFINE_DPM_SCALAR_UPDATE(dpm_scalup, c, t, if_init, p)
{ if (if_init)
P_USER_REAL(p,0) = 0; /* Simple initialization. Used later for
* stopping trajectory calculation */
}
DEFINE_DPM_EROSION(dpm_accr, p, t, f, normal, alpha, Vmag, Mdot)
{
real A[ND_ND], area;
int num_in_data;
Thread *t0;
cell_t c0;
real radi_pos[2], radius, imp_vel[2], vel_ortho;
/* The following is ONLY valid for 2d-axisymmetric calculations!!! */
/* Additional effort is necessary because DPM tracking is done in */
/* THREE dimensions for TWO-dimensional axisymmetric calculations. */
radi_pos[0] = p->state.pos[1];   /* Radial location vector. */
radi_pos[1] = p->state.pos[2];   /* (Y and Z in 0 and 1...) */
radius = NV_MAG(radi_pos);
NV_VS(radi_pos, =, radi_pos, /, radius);
/* Normalized radius direction vector.*/
imp_vel[0] = P_VEL(p)[0];    /* Axial particle velocity component. */
imp_vel[1] = NVD_DOT(radi_pos, P_VEL(p)[1], P_VEL(p)[2], 0.);
/* Dot product of normalized radius vector and y & z components */
/* of particle velocity vector gives _radial_ particle velocity */
/* component */
vel_ortho = NV_DOT(imp_vel, normal); /*velocity orthogonal to wall */
if (vel_ortho < MIN_IMPACT_VELO) /* See above, MIN_IMPACT_VELO */
return;
if (!UDM_checked)      /* We will need some UDM';s, */
if (!check_for_UDM())   /* so check for their availability.. */
return;              /* (Using int variable for speed, could */
/* even just call check_for UDFM().) */
c0 = F_C0(f, t);
t0 = F_C0_THREAD(f, t);  
num_in_data = F_UDMI(f, t, NUM_OF_HITS);
/* Add particle to statistics: Calculate...:
current_particle_property +
earlier_particles_averaged_property * number_of_earlier_particles
-----------------------------------------------------------------
number_of_earlier_particles + 1 */
/* Average diameter of particles that hit the particular wall face:*/
F_UDMI(f, t, AVG_DIAMETER) = (P_DIAM(p)
+ num_in_data * F_UDMI(f, t, AVG_DIAMETER))
/ (num_in_data + 1);
C_UDMI(c0,t0,AVG_DIAMETER) = F_UDMI(f, t, AVG_DIAMETER);
/* Average velocity normal to wall of particles hitting the wall:*/
F_UDMI(f, t, AVG_RADI_VELO) = (vel_ortho
+ num_in_data * F_UDMI(f, t, AVG_RADI_VELO))
/ (num_in_data + 1);
C_UDMI(c0,t0,AVG_RADI_VELO) = F_UDMI(f, t, AVG_RADI_VELO);
F_UDMI(f, t, NUM_OF_HITS) = num_in_data + 1;
C_UDMI(c0,t0,NUM_OF_HITS) = num_in_data + 1;
F_AREA(A, f, t);
area = NV_MAG(A);
F_STORAGE_R(f,t,SV_DPMS_ACCRETION) += Mdot / area;
/* copied from source. */
P_USER_REAL(p,0) = 1.; /* "Evaporate" */
}
DEFINE_DPM_LAW(stop_dpm_law, p, if_cpld)
{
if (0. < P_USER_REAL(p,0))
P_MASS(p) = 0.;          /* "Evaporate" */
}
DEFINE_ON_DEMAND(reset_UDM)
{
/* assign domain pointer with global domain */
domain = Get_Domain(1);
reset_UDM_s();  
}  
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表