24小时热门版块排行榜    

查看: 2293  |  回复: 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 的主题更新
信息提示
请填处理意见