24小时热门版块排行榜    

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

azhu081127

铜虫 (初入文坛)

[求助] 求解答--UDF中DEFINE_ADJUST报错 已有2人参与

以前使用过简单的DEFINE_PROFILE语句来定义入口边界条件,可能因为语句比较简单,所以没有出现过问题。
但最近在用FLUENT做室内热舒适评价的过程中却遇到诸多问题。为逐步解决这些问题,我决定先从最简单的计算出发,一步步解决。
但是,没想到,下面两个简单的UDF竟然会如此棘手。。。
求好心的朋友们帮忙解答~~感谢万分~~~

一、FLUENT UDF tutorial中关于DEFINE_ADJUST的UDF,求解湍流耗散的体积积分,此UDF与tutorial完全一致。

#include "udf.h"
DEFINE_ADJUST(turb_diss, d)
{
  Thread *t;
  real sum_diss=0.;
  cell_t c;
    thread_loop_c (t,d)
  {
   begin_c_loop (c,t)
       sum_diss += C_D(c,t)*C_VOLUME(c,t);
   end_c_loop (c,t)
  }
   printf("Volume integral of turbulent dissipation: %g\n", sum_diss);
}

(1)若使用Interpret功能,则可以正常运行得出结果。

(2)但若使用Compile功能,则会出现如下错误提示:
# Generating udf_names.c because of makefile turb_diss.obj
udf_names.c
udf_names.c(7) : error C2085: ‘udf_data’ : not in formal parameter list
udf_names.c(7) : error C2143: syntax error : missing ‘;’ before ‘=’
udf_names.c(8) : warning C4138: ‘*/’ found outside of comment
udf_names.c(10) : error C2065: ‘udf_data’ : undeclared identifier

(3)求助:是什么原因造成compile编译出现错误?

二、 对于自己编写一个求解摄氏度的非常简单程序:
#include "udf.h"
DEFINE_ADJUST(temp1, d)
{
  Thread *t;
  real tempa=0.;
  cell_t c;
  thread_loop_c (t,d)
  {
   begin_c_loop (c,t)
       tempa = C_T(c,t) - 273.15;
       C_UDSI(c,t,0)=tempa;
   end_c_loop (c,t)
  }
}

(1)使用Interpret功能时报错:
Chip-exec: temp1: wrong return type: float udf function expected
Chip-exec: temp1: argument 1: incorrect type (36): int expected
Chip-exec: temp1: argument 2: incorrect type (0): pointer expected
Chip-exec: temp1: argument 3: incorrect type (0): int expected
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()

(2)若使用Compile功能,则出现与tutorial case相同的错误,即:
udf_names.c(7) : error C2085: ‘udf_data’ : not in formal parameter list
udf_names.c(7) : error C2143: syntax error : missing ‘;’ before ‘=’
udf_names.c(8) : warning C4138: ‘*/’ found outside of comment
udf_names.c(10) : error C2065: ‘udf_data’ : undeclared identifier

(3)求助:
(3.1) 是什么原因造成了interpret出现错误?
(3.2) 同样,又是什么原因造成compile的错误?
(3.3) 关于user defined scalar(UDS): 在一个DEFINE_ADJUST中,能否通过C_UDSI(c,t,0),C_UDSI(c,t,1),C_UDSI(c,t,2)….. C_UDSI(c,t,i)来同时定义多个不同的UDS?还是说,要定义i个不同的DEFINE_ADJUST,来分别定义多个不同的UDS?
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

azhu081127

铜虫 (初入文坛)

大家请来帮帮忙啊~~~
4楼2016-04-14 18:54:28
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 9 个回答

小七工作室1

新虫 (著名写手)

【答案】应助回帖

感谢参与,应助指数 +1
这个做的比较多,可以交流下
2楼2016-04-14 14:45:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

azhu081127

铜虫 (初入文坛)

引用回帖:
2楼: Originally posted by 小七工作室1 at 2016-04-14 14:45:10
这个做的比较多,可以交流下

你好,CFD模拟方面,我还是新手,很多问题都不是特别明白。
就像我在帖子中写的那样,我原来以为是特别简单的问题,结果却让我毫无头绪。。。
请问,你有没有遇到过类似的问题,你又是怎么解决的?
3楼2016-04-14 15:06:20
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

keeep0394

新虫 (正式写手)

多核还是单核计算?这里面有累加,需注意

发自小木虫IOS客户端
5楼2016-04-14 21:55:42
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0856化工专硕求调剂 +4 董boxing 2026-03-01 4/200 2026-03-01 10:11 by 杨杨杨紫
[考研] 0856求调剂285 +6 吕仔龙 2026-02-28 6/300 2026-03-01 10:03 by wang_dand
[硕博家园] 博士自荐 +6 科研狗111 2026-02-26 10/500 2026-03-01 10:02 by 科研狗111
[考研] 高分子化学与物理调剂 +4 好好好1233 2026-02-28 8/400 2026-03-01 09:26 by 好好好1233
[考研] 290求调剂 +6 材料专硕调剂; 2026-02-28 7/350 2026-03-01 09:21 by L135790
[考研] 272求调剂 +4 材紫有化 2026-02-28 4/200 2026-03-01 09:20 by L135790
[考研] 291分工科求调剂 +5 science饿饿 2026-03-01 5/250 2026-03-01 09:19 by L135790
[论文投稿] Optics letters投稿被拒求助 30+3 luckyry 2026-02-26 4/200 2026-03-01 09:06 by babero
[考研] 284求调剂 +5 天下熯 2026-02-28 5/250 2026-03-01 08:49 by ms629
[考研] 材料类求调剂 +7 wana_kiko 2026-02-28 7/350 2026-03-01 07:55 by ms629
[基金申请] 面上模板改不了页边距吧? +5 ieewxg 2026-02-25 6/300 2026-03-01 00:10 by addressing
[考研] 304求调剂 +3 52hz~~ 2026-02-28 5/250 2026-03-01 00:00 by 52hz~~
[考研] 295求调剂 +5 19171856320 2026-02-28 5/250 2026-02-28 21:39 by gaoxiaoniuma
[考研] 264求调剂 +3 巴拉巴拉根556 2026-02-28 3/150 2026-02-28 21:31 by gaoxiaoniuma
[考研] 311求调剂 +8 南迦720 2026-02-28 8/400 2026-02-28 21:30 by gaoxiaoniuma
[考研] 085600材料工程一志愿中科大总分312求调剂 +8 吃宵夜1 2026-02-28 10/500 2026-02-28 20:27 by L135790
[考研] 298求调剂 +8 人间唯你是清欢 2026-02-28 11/550 2026-02-28 20:26 by L135790
[高分子] 求环氧树脂研发1名 +3 孙xc 2026-02-25 11/550 2026-02-28 16:57 by ichall
[考研] 304求调剂 +5 曼殊2266 2026-02-28 6/300 2026-02-28 12:44 by 迷糊CCPs
[硕博家园] 【博士招生】太原理工大学2026化工博士 +4 N1ce_try 2026-02-24 8/400 2026-02-26 08:40 by N1ce_try
信息提示
请填处理意见