24小时热门版块排行榜    

查看: 2321  |  回复: 8
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

chang.z.s

铜虫 (小有名气)

[求助] 用udf实现coupled边界固体区域中温度最值提取

物理问题是想 提取  耦合边界固体区域中心面上温度最大值曲线和最小值取消(非稳态)。monitor可实现监控某一点或某面的平均值随时间变化,但想得到的点比较多就考虑用udf,但一直没成功过。
主要疑问在于:
d=Get_Domain(1); 对单相流体获得的是所有流体区域,边界的固体区域如何获得?
我在udf加了 t = Lookup_Thread(d,12); (12是固体壁面区域在boundary conditon 中的zone id)来获得固体域的thread,但udf没成功,是否是因为在d 是流体域不能得到固体的thread。如果这样的话,如何得到固体域呢?
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

chang.z.s

铜虫 (小有名气)

引用回帖:
5楼: Originally posted by stryhood at 2013-10-22 20:17:09
thread和cell loop之后,应该是全部循环的,看了你的代码应该是不用for循环的...

for 是为了得到多个(250)点在时间进程上的最大值和最小值,这个地方是比较低效,全域循环只找出一个点。
6楼2013-10-25 15:52:22
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 9 个回答

chang.z.s

铜虫 (小有名气)

自顶一下 把代码贴出来,写的很挫 请高手指教

DEFINE_EXECUTE_AT_END(excutend_twminmax)
{
Domain *d;
/* declare domain pointer since it is not passed as an argument to the DEFINE macro */
Thread *t;
cell_t c;
real temptf,ctime1;
int i;
FILE *twminmax;
real x[ND_ND];       
real twmin0[100]={0}; real twmax0[100]={0}; real twmin[100]={0}; real twmax[100]={0}; //####grid is 500####only for this mesh;
real times0[100]={0}; real timeb0[100]={0}; real times[100]={0}; real timeb[100]={0};
i=0;
d=Get_Domain(1); // all fluid zone
t = Lookup_Thread(d,12);// ########pay attention to this part ,id of insert####### zone_ID 5
ctime1 = RP_Get_Real("flow-time";

for(i=0;i<250;i++)
{
thread_loop_c(t,d)
/* Compute max, min, volume-averaged temperature */
/* Loop over all cells */
{
        begin_c_loop(c,t)
        {
temptf = C_T(c,t);
C_CENTROID(x,c,t);

if ((fabs(x[1]-1.04)<0.02)&&(fabs(x[0]-(i+1)*0.02)<0.01))
{
                       
        if (ctime1<=1)
        {
        twmin=temptf;   //   temperature at current time
        twmax=temptf;
        times=ctime1;
        timeb=ctime1;
        }
               
        if ((twmin0<twmin)&&(ctime1>1))// initial state skip these two
                {
                twmin=twmin0;
                times=times0;
                }

        if ((twmax0>twmax)&&(ctime1>1))
                {
                twmax=twmax0;
                timeb=timeb0;
                }
       
}
        twmin0=twmin; // 0  temperature at last time step, save the last time step data
        twmax0=twmax;
        times0=times;
        timeb0=timeb;

}
    end_c_loop(c,t)
}

}
/* write the data of twmin adn twmax */
twminmax=fopen("twminmax.txt","w";
for(i=0;i<250;i++)
{
fprintf(twminmax,"%g %g %g %g %g\n", ctime1, twmin, times, twmax, timeb);
}
Message("twmin[100];%g\n",twmin[100]);
fclose(twminmax);
}
2楼2013-10-18 15:41:29
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

stryhood

至尊木虫 (著名写手)

【答案】应助回帖


臭水沟: 金币+1, 谢谢交流~ 2013-10-25 20:30:17
loop thread和loop cell都用,你限定一下固体区域的坐标,应该能行
3楼2013-10-21 08:58:34
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

chang.z.s

铜虫 (小有名气)

引用回帖:
3楼: Originally posted by stryhood at 2013-10-21 08:58:34
loop thread和loop cell都用,你限定一下固体区域的坐标,应该能行

udf里是这样处理的 同时thread和cell的循环都有找固体区域的某个位置,
但最后输出都是初值

thread_loop_c(t,d)
/* Compute max, min, volume-averaged temperature */
/* Loop over all cells */
{
        begin_c_loop(c,t)

不确定是不是 if ((fabs(x[1]-1.04)<0.02)&&(fabs(x[0]-(i+1)*0.02)<0.01)) 判断太严格,根本没执行,这种可能也不大。
4楼2013-10-22 16:16:54
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见