关于在DEFINE_DPM_OUTPUT中使用Cell Macros的问题
请问坛友有没有在DEFINE_DPM_OUTPUT中使用Cell macros的经历?我在里面使用C_STRAIN_RATE_MAG(c,t)时遇到了问题。我用TP_CELL(tp)取的c(只用这个宏时是没有问题的),t在DEFINE_DPM_OUTPUT的输入形参里我就直接用了。然后Console报错Process xxxx: Received signal SIGSEGV.并且fluent停止工作。在想是不是DEFINE_DPM_OUTPUT形参表里的Thread* t和C_STRAIN_RATE_MAG所要的Thread* t并不一样?下附出现问题的代码。将与s有关的两行(第28行,第17行)注释掉后挂载使用是没有问题的。#include "udf.h"
#include "dpm_types.h"
#include "mem.h"
/******************************************************************/
/* UDF that samples discrete phase size and velocity distributions*/
/* within the domain. */
/******************************************************************/
#define REMOVE_PARTICLES FALSE
DEFINE_DPM_OUTPUT(hemocellOutput,header,fp,tp,t,plane)
{
#if RP_2D
return;
#else
cell_t c;
real s;
if(header)
{
par_fprintf_head(fp," ID, time, x-velocity, ");
par_fprintf_head(fp,"y-velocity, z-velocity, ");
par_fprintf_head(fp,"x-position, y-position, ");
par_fprintf_head(fp,"z-position, strain rate \n");
}
if(NULLP(tp))
return;
c = TP_CELL(tp);
s = C_STRAIN_RATE_MAG(c,t);
par_fprintf(fp,"%d %" int64_fmt " %" int64_fmt ", %e, %f, %f, %f, %f, %f, %f,\n",
P_INJ_ID(TP_INJECTION(tp)), TP_ID(tp), TP_ID(tp), TP_TIME(tp),TP_VEL(tp),
TP_VEL(tp),TP_VEL(tp),TP_POS(tp),TP_POS(tp),TP_POS(tp));
#endif
#if REMOVE_PARTICLES
MARK_TP(tp, P_FL_REMOVED);
#endif
}
已解决,此tread非彼thread
#include "udf.h"
#include "dpm_types.h"
#include "mem.h"
/******************************************************************/
/* UDF that samples discrete phase size and velocity distributions*/
/* within the domain. */
/******************************************************************/
#define REMOVE_PARTICLES FALSE
Domain *domain1;
DEFINE_DPM_OUTPUT(hemocellOutput,header,fp,tp,t,plane)
{
#if RP_2D
return;
#else
cell_t c;
real s;
int zone_ID = 3;
Thread *thread_name = Lookup_Thread(domain1,zone_ID);
if(header)
{
par_fprintf_head(fp," ID, time, x-velocity, ");
par_fprintf_head(fp,"y-velocity, z-velocity, ");
par_fprintf_head(fp,"x-position, y-position, ");
par_fprintf_head(fp,"z-position, strain rate \n");
}
if(NULLP(tp))
return;
c = TP_CELL(tp);
s = C_STRAIN_RATE_MAG(c,thread_name);
par_fprintf(fp,"%d %" int64_fmt " %" int64_fmt ", %e, %f, %f, %f, %f, %f, %f, %f \n",
P_INJ_ID(TP_INJECTION(tp)), TP_ID(tp), TP_ID(tp), TP_TIME(tp),TP_VEL(tp),
TP_VEL(tp),TP_VEL(tp),TP_POS(tp),TP_POS(tp),TP_POS(tp),s);
#endif
#if REMOVE_PARTICLES
MARK_TP(tp, P_FL_REMOVED);
#endif
}
DEFINE_ON_DEMAND(my_udf)
{
Domain *domain; /* domain is declared as a variable*/
domain = Get_Domain(1);/* returns fluid domain pointer */
domain1 = domain;
}
页:
[1]