|
[Sponsors] |
How to solve parse error error in UDF fluent for #DEFINE_INIT? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 10, 2018, 22:48 |
How to solve parse error error in UDF fluent for #DEFINE_INIT?
|
#1 |
Senior Member
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18 |
Dear all,
I am new in UDF. I am trying to make different initial guess of temperature distribution in solid by using #DEFINE_INIT CODE in Fluent 17.2. I took the whole code from UDF Fluent Customization sample. I just make little modification. The case is 2D and the solid is in y- direction. Do you have any advice? However when the code is interpreted the error shows Error: E:/profile_temp.c: line 8: parse error. Thank you for your help Here is my code /************************************************** ********************* UDF for initializing flow field variables ************************************************** **********************/ #include "udf.h" #define d 5 DEFINE_INIT(temp_prof_init,d) { cell_t c; Thread *t; real xc[ND_ND]; /* loop over all cell threads in the domain */ thread_loop_c(t,d) { /* loop over all cells */ begin_c_loop_all(c,t) { C_CENTROID(xc,c,t); y = xc[1] if (y < 0) /* y < 0 */ C_T(c,t) = 10.578*y +302.26; else if (y <-5 ) C_T(c,t) = 4.6277*y + 300.46; /* y < -5 */ else C_T(c,t) = 290; } end_c_loop_all(c,t) } }
__________________
Now Or Never!!! |
|
June 11, 2018, 12:32 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Teguh,
Out of paranoia, I recommend you delete the blank line after the DEFINE_INIT line. However, the problem is the "#define d 5" -- as you probably know, this is a preprocessor directive. It is basically a "find and replace". I am not sure what you intended this to achieve, but the result is that "DEFINE_INIT(my_init_func,d)" becomes "DEFINE_INIT(my_init_func,5)", which is not valid. Fluent needs a variable name d (and arranges for it to have type Domain*). Good luck! Ed |
|
June 13, 2018, 00:31 |
How to make DEFINE_INIT works only in solid zone?
|
#3 |
Senior Member
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18 |
Dear obscureed,
Thank you for your suggestion. I have repaired the code. It works if the only one zone. Actually, I have two zones (Solid and Liquid zone). If I do not define zone ID the initial temperature of solid and fluid will be same. I attach the inital temperature and zone ID (Zone ID 4 is solid and zone ID -1 is liquid. I want to make the DEFINE_INIT works only in solid zone. What should I do for this problem? Thank you for your help Here is my new code /************************************************** ********************* UDF for initializing flow field variables ************************************************** **********************/ #include "udf.h" DEFINE_INIT(my_init_func,domain) { cell_t c; Thread *t; real xc[ND_ND]; real y; /* loop over all cell threads in the domain */ thread_loop_c(t,domain) { /* loop over all cells */ begin_c_loop_all(c,t) { C_CENTROID(xc,c,t); y = xc[1]; if ( y >= -0.293) /* 12-13 */ C_T(c,t) = 300; else if ( y >= -0.984) /* 12-13 */ C_T(c,t) = 290; else if ( y >= -2.992) /* 12-13 */ C_T(c,t) = 280; else if ( y >= -9.98) /* 12-13 */ C_T(c,t) = 270; else C_T(c,t) = 260; } end_c_loop_all(c,t) } }
__________________
Now Or Never!!! |
|
June 13, 2018, 05:56 |
|
#4 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Teguh,
In UDFs, a "thread" is a cell zone or a face zone. (This becomes more complicated in multiphase models, but it will be OK for now.) So you are asking about how to find a specific thread, based on its ID number. For this, you do not want "thread_loop_c(t,domain){ /*... use t ...*/ }", which repeatedly evaluates the contents with each possible cell thread in t. Instead you want Code:
t = Lookup_Thread(domain, 4); /*... use t ...*/ Good luck! Ed |
|
June 18, 2018, 09:14 |
|
#5 |
Senior Member
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18 |
Dear obscureed,
Thank you for your advice. It works good on several time. But, in the initial condition contour, fluent makes the same temperature field in every threat. How to solve that? Best regards
__________________
Now Or Never!!! |
|
June 18, 2018, 10:56 |
|
#6 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Teguh,
I do not completely understand your question, but it sounds like you need to debug your own UDF code. Good luck! Ed |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic contact angle issue: fluent UDF couldn't set the correct contact angle | FelixJJ | FLUENT | 2 | October 20, 2021 03:39 |
line 1 parse error UDF Fluent | violethill | Fluent UDF and Scheme Programming | 1 | February 25, 2018 22:01 |
UDF code help solve reaction rate equation palm oil | zirkov | Fluent UDF and Scheme Programming | 0 | February 13, 2017 11:34 |
write code UDF Fluent solve kinetic reaction rate equation palm oil | zirkov | FLUENT | 0 | February 13, 2017 11:16 |
fluent udf problem: write specific data for every iteration in a file. | nnvoro | Fluent UDF and Scheme Programming | 1 | May 27, 2013 16:26 |