24小时热门版块排行榜    

Znn3bq.jpeg
北京石油化工学院2026年研究生招生接收调剂公告
查看: 2390  |  回复: 7

cougabin

铜虫 (正式写手)

[求助] fluent中求解两相边界曲率的udf 已有1人参与

望提供求解两相边界曲率的udf代码,
或者提供求解散度的方法,
亦或提出一些合理化建议。
非常感谢
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xingfuww

专家顾问 (正式写手)

UDF 只是工具  首先你得在数学上写的出方程!! 不然别期待电脑会自动给你算。
2楼2016-08-30 16:33:52
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

范学成

金虫 (小有名气)

【答案】应助回帖

感谢参与,应助指数 +1
3 读取VOF梯度方法1
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"
DEFINE_ADJUST(store_VOF_gradient, domain)
{
Thread *t;
Thread *ppt;
Thread **pt;
cell_t c;
int phase_domain_index=1;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate);
mp_thread_loop_c (t,domain,pt)
{
if (FLUID_THREAD_P(t))
{
ppt = pt[phase_domain_index];
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];
C_UDMI(c,t,1) = C_VOF_G(c,ppt)[1];
C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];
}
end_c_loop (c,t)
}
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
}
上例利用了一些帮助上无法查到的FLUENT函数手动设置VOF梯度计算,Alloc_Storage_Vars,
Scalar_Reconstruction,Scalar_Derivatives这些函数的大概功能可以猜到,但是没有详细说明。


4 读取VOF梯度方法2
将VOF赋值给UDS变量,然后通过C_UDSI_G间接求得梯度。
下例是FLUENT帮助文档中给出的一个例子:
将VOF赋值给UDS;进行一次迭代计算,但不计算UDS方程;尽管未计算UDS方程,仍可以得到梯度值,并将其赋值给UDM用于显示。
# include "udf.h"
# define domain_ID 2

DEFINE_ADJUST(adjust_gradient, domain)
{
    Thread *t;
    cell_t c;
    face_t f;
    domain = Get_Domain(domain_ID);
    /* Fill UDS with the variable. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
         {
         C_UDSI(c,t,0) = C_VOF(c,t);
         }
      end_c_loop (c,t)
      }
    thread_loop_f (t,domain)
      {
      if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
        begin_f_loop (f,t)
         {
         F_UDSI(f,t,0) = F_VOF(f,t);
         }
      end_f_loop (f,t)
      }
}

DEFINE_ON_DEMAND(store_gradient)
{  Domain *domain;
    cell_t c;
    Thread *t;
    domain=Get_Domain(1);
    /* Fill the UDM with magnitude of gradient. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
       {
         C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
       }
      end_c_loop (c,t)
      }
}
3楼2016-08-31 09:38:58
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

范学成

金虫 (小有名气)

【答案】应助回帖

3 读取VOF梯度方法1
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"
DEFINE_ADJUST(store_VOF_gradient, domain)
{
Thread *t;
Thread *ppt;
Thread **pt;
cell_t c;
int phase_domain_index=1;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate);
mp_thread_loop_c (t,domain,pt)
{
if (FLUID_THREAD_P(t))
{
ppt = pt[phase_domain_index];
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];
C_UDMI(c,t,1) = C_VOF_G(c,ppt)[1];
C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];
}
end_c_loop (c,t)
}
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
}
上例利用了一些帮助上无法查到的FLUENT函数手动设置VOF梯度计算,Alloc_Storage_Vars,
Scalar_Reconstruction,Scalar_Derivatives这些函数的大概功能可以猜到,但是没有详细说明。



4 读取VOF梯度方法2
将VOF赋值给UDS变量,然后通过C_UDSI_G间接求得梯度。
下例是FLUENT帮助文档中给出的一个例子:
将VOF赋值给UDS;进行一次迭代计算,但不计算UDS方程;尽管未计算UDS方程,仍可以得到梯度值,并将其赋值给UDM用于显示。
# include "udf.h"
# define domain_ID 2

DEFINE_ADJUST(adjust_gradient, domain)
{
    Thread *t;
    cell_t c;
    face_t f;
    domain = Get_Domain(domain_ID);
    /* Fill UDS with the variable. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
         {
         C_UDSI(c,t,0) = C_VOF(c,t);
         }
      end_c_loop (c,t)
      }
    thread_loop_f (t,domain)
      {
      if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
        begin_f_loop (f,t)
         {
         F_UDSI(f,t,0) = F_VOF(f,t);
         }
      end_f_loop (f,t)
      }
}

DEFINE_ON_DEMAND(store_gradient)
{  Domain *domain;
    cell_t c;
    Thread *t;
    domain=Get_Domain(1);
    /* Fill the UDM with magnitude of gradient. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
       {
         C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
       }
      end_c_loop (c,t)
      }
}
4楼2016-08-31 09:40:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

范学成

金虫 (小有名气)

【答案】应助回帖

读取VOF梯度方法1
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"
DEFINE_ADJUST(store_VOF_gradient, domain)
{
Thread *t;
Thread *ppt;
Thread **pt;
cell_t c;
int phase_domain_index=1;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate);
mp_thread_loop_c (t,domain,pt)
{
if (FLUID_THREAD_P(t))
{
ppt = pt[phase_domain_index];
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];
C_UDMI(c,t,1) = C_VOF_G(c,ppt)[1];
C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];
}
end_c_loop (c,t)
}
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
}
上例利用了一些帮助上无法查到的FLUENT函数手动设置VOF梯度计算,Alloc_Storage_Vars,
Scalar_Reconstruction,Scalar_Derivatives这些函数的大概功能可以猜到,但是没有详细说明。






2读取VOF梯度方法2
将VOF赋值给UDS变量,然后通过C_UDSI_G间接求得梯度。
下例是FLUENT帮助文档中给出的一个例子:
将VOF赋值给UDS;进行一次迭代计算,但不计算UDS方程;尽管未计算UDS方程,仍可以得到梯度值,并将其赋值给UDM用于显示。
# include "udf.h"
# define domain_ID 2

DEFINE_ADJUST(adjust_gradient, domain)
{
    Thread *t;
    cell_t c;
    face_t f;
    domain = Get_Domain(domain_ID);
    /* Fill UDS with the variable. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
         {
         C_UDSI(c,t,0) = C_VOF(c,t);
         }
      end_c_loop (c,t)
      }
    thread_loop_f (t,domain)
      {
      if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
        begin_f_loop (f,t)
         {
         F_UDSI(f,t,0) = F_VOF(f,t);
         }
      end_f_loop (f,t)
      }
}

DEFINE_ON_DEMAND(store_gradient)
{  Domain *domain;
    cell_t c;
    Thread *t;
    domain=Get_Domain(1);
    /* Fill the UDM with magnitude of gradient. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
       {
         C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
       }
      end_c_loop (c,t)
      }
}
5楼2016-08-31 09:41:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

hitzhwan

禁虫 (著名写手)

本帖内容被屏蔽

6楼2017-10-19 20:57:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

范学成

金虫 (小有名气)

引用回帖:
6楼: Originally posted by hitzhwan at 2017-10-19 20:57:06
为什么有乱码啊?...

3 读取VOF梯度方法1
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"
DEFINE_ADJUST(store_VOF_gradient, domain)
{
Thread *t;
Thread *ppt;
Thread **pt;
cell_t c;
int phase_domain_index=1;
Domain *pDomain = DOMAIN_SUB_DOMAIN(domain,phase_domain_index);
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate);
mp_thread_loop_c (t,domain,pt)
{
if (FLUID_THREAD_P(t))
{
ppt = pt[phase_domain_index];
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];
C_UDMI(c,t,1) = C_VOF_G(c,ppt)[1];
C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];
}
end_c_loop (c,t)
}
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NULL);
}
上例利用了一些帮助上无法查到的FLUENT函数手动设置VOF梯度计算,Alloc_Storage_Vars,
Scalar_Reconstruction,Scalar_Derivatives这些函数的大概功能可以猜到,但是没有详细说明。


4 读取VOF梯度方法2
将VOF赋值给UDS变量,然后通过C_UDSI_G间接求得梯度。
下例是FLUENT帮助文档中给出的一个例子:
将VOF赋值给UDS;进行一次迭代计算,但不计算UDS方程;尽管未计算UDS方程,仍可以得到梯度值,并将其赋值给UDM用于显示。
# include "udf.h"
# define domain_ID 2

DEFINE_ADJUST(adjust_gradient, domain)
{
    Thread *t;
    cell_t c;
    face_t f;
    domain = Get_Domain(domain_ID);
    /* Fill UDS with the variable. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
         {
         C_UDSI(c,t,0) = C_VOF(c,t);
         }
      end_c_loop (c,t)
      }
    thread_loop_f (t,domain)
      {
      if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
        begin_f_loop (f,t)
         {
         F_UDSI(f,t,0) = F_VOF(f,t);
         }
      end_f_loop (f,t)
      }
}

DEFINE_ON_DEMAND(store_gradient)
{  Domain *domain;
    cell_t c;
    Thread *t;
    domain=Get_Domain(1);
    /* Fill the UDM with magnitude of gradient. */
    thread_loop_c (t,domain)
      {
      begin_c_loop (c,t)
       {
         C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
       }
      end_c_loop (c,t)
      }
}

发自小木虫IOS客户端
7楼2017-10-24 23:47:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

hitzhwan

禁虫 (著名写手)

本帖内容被屏蔽

8楼2017-10-25 14:03:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 cougabin 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料科学与工程320求调剂,080500 +9 黄瓜味薯片 2026-04-06 9/450 2026-04-08 00:46 by JourneyLucky
[考研] 368化学求调剂 +4 wwwwabcde 2026-04-07 5/250 2026-04-07 22:51 by wwwwabcde
[考研] 调剂 +18 不逢春 2026-04-05 19/950 2026-04-07 22:04 by lijunpoly
[考研] 285求调剂 +17 AZMK 2026-04-02 18/900 2026-04-07 20:31 by 蓝云思雨
[考研] 085602调剂 初试总分335 +3 19123253302 2026-04-06 3/150 2026-04-07 18:00 by jp9609
[考研] 283求调剂 +18 A child 2026-04-04 18/900 2026-04-07 12:30 by 1018329917
[考研] 一志愿生物与医药,296分,求调剂 +11 66鹿 2026-04-03 13/650 2026-04-06 21:45 by 52305043001
[考研] 生物与医药求调剂 +7 heguanhua 2026-04-05 8/400 2026-04-06 18:41 by macy2011
[考研] 材料调剂 +5 小刘同学吖吖 2026-04-06 5/250 2026-04-06 18:34 by sherry_1901
[考研] (调剂)一志愿报考哈尔滨工业大学0857资源与环境专业378分考生 +7 狠狠加油 2026-04-05 8/400 2026-04-06 16:52 by momo皓
[考研] 一志愿河北工业大学材料工程,初试344求专硕调剂 +6 15933906766 2026-04-05 6/300 2026-04-06 13:21 by 无际的草原
[考研] 301求调剂 +7 细胞相关蛋白 2026-04-03 7/350 2026-04-06 11:47 by lijunpoly
[考研] 284求调剂 +7 徐同学_001 2026-04-04 13/650 2026-04-05 17:19 by yulian1987
[考博] 申博 +7 IQwQl 2026-04-04 7/350 2026-04-04 23:32 by mumin1990
[考研] 306求调剂 +3 hyb上名工 2026-04-02 3/150 2026-04-04 18:12 by 热情沙漠
[考研] 350一志愿北京航空航天大学08500材料科学与工程求调剂 +5 kjnasfss 2026-04-03 5/250 2026-04-03 22:29 by 无际的草原
[考研] 专硕 351 086100 也是考的材科基 本科也是材料 +8 202451007219 2026-04-02 8/400 2026-04-03 09:50 by 蓝云思雨
[考研] 农学考研求调剂 +3 dkdkxm 2026-04-01 3/150 2026-04-02 16:04 by wangjagri
[考研] 求调剂推荐 +3 南山南@ 2026-04-01 3/150 2026-04-02 12:09 by xiaoranmu
[考研] 一志愿北交材料工程总分358 +5 cs0106 2026-04-01 7/350 2026-04-01 11:45 by wangjy2002
信息提示
请填处理意见