找回密码
 注册
查看: 2648|回复: 1

关于在DEFINE_DPM_OUTPUT中使用Cell Macros的问题

[复制链接]
发表于 2021-4-9 10:16:07 | 显示全部楼层 |阅读模式

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

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

x

请问坛友有没有在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行)注释掉后挂载使用是没有问题的。

  1. #include "udf.h"
  2. #include "dpm_types.h"
  3. #include "mem.h"
  4. /******************************************************************/
  5. /* UDF that samples discrete phase size and velocity distributions*/
  6. /* within the domain.            */
  7. /******************************************************************/
  8. #define REMOVE_PARTICLES FALSE

  9. DEFINE_DPM_OUTPUT(hemocellOutput,header,fp,tp,t,plane)
  10. {
  11.          #if RP_2D
  12.                 return;
  13.          #else
  14.                  
  15.     cell_t c;
  16.         real s;
  17.     if(header)
  18.     {
  19.       par_fprintf_head(fp," ID, time, x-velocity[m/s], ");
  20.       par_fprintf_head(fp,"y-velocity[m/s], z-velocity[m/s], ");
  21.       par_fprintf_head(fp,"x-position[m], y-position[m], ");
  22.       par_fprintf_head(fp,"z-position[m], strain rate \n");
  23.     }
  24.     if(NULLP(tp))
  25.       return;
  26.         c = TP_CELL(tp);
  27.         s = C_STRAIN_RATE_MAG(c,t);
  28.         par_fprintf(fp,"%d %" int64_fmt " %" int64_fmt ", %e, %f, %f, %f, %f, %f, %f,  \n",
  29.    P_INJ_ID(TP_INJECTION(tp)), TP_ID(tp), TP_ID(tp), TP_TIME(tp),TP_VEL(tp)[0],
  30.   TP_VEL(tp)[1],TP_VEL(tp)[2],TP_POS(tp)[0],TP_POS(tp)[1],TP_POS(tp)[2]);
  31.          #endif

  32.    #if REMOVE_PARTICLES
  33.       MARK_TP(tp, P_FL_REMOVED);
  34.    #endif
  35. }
复制代码



 楼主| 发表于 2021-4-9 16:59:50 | 显示全部楼层
已解决,此tread非彼thread
  1. #include "udf.h"
  2. #include "dpm_types.h"
  3. #include "mem.h"
  4. /******************************************************************/
  5. /* UDF that samples discrete phase size and velocity distributions*/
  6. /* within the domain.            */
  7. /******************************************************************/
  8. #define REMOVE_PARTICLES FALSE
  9. Domain *domain1;

  10. DEFINE_DPM_OUTPUT(hemocellOutput,header,fp,tp,t,plane)
  11. {
  12.          #if RP_2D
  13.                 return;
  14.          #else
  15.                  
  16.     cell_t c;
  17.         real s;

  18.     int zone_ID = 3;
  19.     Thread *thread_name = Lookup_Thread(domain1,zone_ID);
  20.        
  21.     if(header)
  22.     {
  23.       par_fprintf_head(fp," ID, time, x-velocity[m/s], ");
  24.       par_fprintf_head(fp,"y-velocity[m/s], z-velocity[m/s], ");
  25.       par_fprintf_head(fp,"x-position[m], y-position[m], ");
  26.       par_fprintf_head(fp,"z-position[m], strain rate \n");
  27.     }
  28.     if(NULLP(tp))
  29.       return;
  30.         c = TP_CELL(tp);
  31.         s = C_STRAIN_RATE_MAG(c,thread_name);
  32.         par_fprintf(fp,"%d %" int64_fmt " %" int64_fmt ", %e, %f, %f, %f, %f, %f, %f, %f \n",
  33.    P_INJ_ID(TP_INJECTION(tp)), TP_ID(tp), TP_ID(tp), TP_TIME(tp),TP_VEL(tp)[0],
  34.   TP_VEL(tp)[1],TP_VEL(tp)[2],TP_POS(tp)[0],TP_POS(tp)[1],TP_POS(tp)[2],s);
  35.          #endif

  36.    #if REMOVE_PARTICLES
  37.       MARK_TP(tp, P_FL_REMOVED);
  38.    #endif
  39. }

  40. DEFINE_ON_DEMAND(my_udf)
  41. {
  42.     Domain *domain;          /* domain is declared as a variable  */
  43.     domain = Get_Domain(1);  /* returns fluid domain pointer      */
  44.     domain1 = domain;
  45. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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