当前位置: 首页 > 仿真模拟 >DPM宏命令Begin_particle_cell_loop(p,c,t)的使用问题

DPM宏命令Begin_particle_cell_loop(p,c,t)的使用问题

作者 keen_xq
来源: 小木虫 250 5 举报帖子
+关注

各位同学 有没有使用Fluent中 这个 begin_particle_cell_loop(p,c,t)宏呢,该宏出现在DEFINE_DPM_SPRAY_COLLIDE中,看帮助上的解释,该宏应该是遍历单元中所有的颗粒。我想用该宏求出单元中 颗粒的体积分数,命令如下。 该命令在编译中没问题,计算时崩溃。我调试过多次,最后发现 begin_particle_cell_loop(pi,c,t)不能再DEFINE_DPM_DRAG中使用,一旦使用,求解就没办法进行,我也尝试在其他宏 如DEFINE_DPM_SCALE_UPDATA 和DEFINE_DPM_BODY_FORCE中调用均失败。有没有大牛使用过该宏,求指点迷津,被折磨了好久了。


DEFINE_DPM_DRAG(particle_drag_force,Re,p)
{
        real dd,Vsum=0.0;
        cell_t c=P_CELL(p);
        Thread *t =P_CELL_THREAD(p);
        Particle *pi;
        begin_particle_cell_loop(pi,c,t)
        {
                Vsum+=M_PI*pow(P_DIAM(pi),3.0)/6.0;
        }end_particle_cell_loop(pi,c,t)

        C_UDMI(c,t,0)=Vsum/C_VOLUME(c,t);  //求体相积分数;//
        if(C_UDMI(c,t,0)>1)
                C_UDMI(c,t,0)=1.0;

        if(Dragsign==1)
                dd=Cdrag_force1(p,Re);
        else if(Dragsign==2)
                dd=Cdrag_force2(p,Re);
        else if(Dragsign==3)
                dd=Cdrag_force3(p,Re);
        else if(Dragsign==4)
                dd=Cdrag_force4(p,Re);
        else
                dd=Cdrag_force5(p,Re);
        return dd*pow(1-C_UDMI(c,t,0),5.0/3.0)/pow(1-C_UDMI(c,t,0),2.0);
} 返回小木虫查看更多

今日热帖
  • 精华评论
  • liukan12

    你的理解有误区 实际上这个宏需要先要把particle在cell中间建立索引列表 所以需要先把particle封装一下 就是说 首先你需要一个particle bin
    否则你是会报错的
    其实一个单元内的颗粒总数是有简单的求法的

  • keen_xq

    膜拜大神。请问大神,你所说的particle bin如何创建,或者如何得到?在fluent UDF 手册中关于这个宏我只发现在DEFINE_DPM_SPRAY_COLLIDE中存在,关于这个宏的介绍也是一笔带过。大神,你能详细说下,或则推荐个资料吗,udf手册中的介绍很不详细,有很多都需要自己结合程序推出是什么意思。。大神,我udf的目的是想遍历每个流体单元中所有的气泡,通过累加其体积然后求得气相的体积分数。大神,你能推荐下简单的方法吗?不胜感激。。还有金币奉上

  • 钱潇

    引用回帖:
    4楼: Originally posted by keen_xq at 2019-06-16 00:15:38
    膜拜大神。请问大神,你所说的particle bin如何创建,或者如何得到?在fluent UDF 手册中关于这个宏我只发现在DEFINE_DPM_SPRAY_COLLIDE中存在,关于这个宏的介绍也是一笔带过。大神,你能详细说下,或则推荐个资料 ...

    请问楼主解决这个问题了吗,我也是希望通过UDF获得流体域的气液比,结果,出各种问题

  • 钱潇

    引用回帖:
    5楼: Originally posted by 钱潇 at 2020-05-19 16:44:38
    请问楼主解决这个问题了吗,我也是希望通过UDF获得流体域的气液比,结果,出各种问题...

    There is a loop available for looping over all the particles in a cell. But it does not work if used directly. Actually the array to bin the particles in the cell is not allocated by default. It has to be done before using this loop and then it will run ok.

    So, at the top of the routine, please put,

    Alloc_Storage_Vars(domain, SV_DPM_PARTICLE_BIN, SV_NULL);
    bin_particles_in_cells(domain);

    and at the botton, free up the memory with,

    Free_Storage_Vars(domain, SV_DPM_PARTICLE_BIN, SV_NULL);
    I am attaching my test UDF. It worked nicely for a simple 2d case in Linux.

    #include "udf.h"
    #include "surf.h"

    DEFINE_ON_DEMAND(cell)
    {

    Domain *d=Get_Domain(1);
    cell_t c;
    int id;
    Particle *p;

    Thread *c_thread=Lookup_Thread(d,2); /*In my case 2 was the id of the fluid thread. Please change this number accordingly */

    Alloc_Storage_Vars(d, SV_DPM_PARTICLE_BIN, SV_NULL);
    bin_particles_in_cells(d);

    begin_c_loop(c, c_thread)

    {
    /* Message("Cell_index=%dn",c);*/
    begin_particle_cell_loop(p,c,c_thread)
    {
    id=p->part_id;
    Message(" cell index=%d part_id=%d ",c,id);
    }
    end_particle_cell_loop(p,c,c_thread)
    }

    end_c_loop(c, c_thread)

    Free_Storage_Vars(d, SV_DPM_PARTICLE_BIN, SV_NULL);

    }

猜你喜欢