|
[Sponsors] |
Can any tell me which is right for the below codes? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
December 23, 2020, 21:35 |
Can any tell me which is right for the below codes?
|
#1 |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
Can any tell me which is right for the below codes?
The first one: #include "udf.h" DEFINE_PROFILE(hf_change,thread,position) { face_t f; real time,heat_flux1,heat_flux2; heat_flux1 = 0; heat_flux2 = 500; time=CURRENT_TIME; begin_f_loop(f,thread) { if (time<0.0001) { F_PROFILE(f,thread,position)=heat_flux1; } else if (time>=0.0001) { F_PROFILE(f,thread,position)=heat_flux2; } } end_f_loop(f,thread) } The second one: #include "udf.h" DEFINE_PROFILE(hf_change,thread,position) { face_t f; real time,heat_flux1,heat_flux2; heat_flux1 = 0; heat_flux2 = 500; begin_f_loop(f,thread) { time=CURRENT_TIME; if (time<0.0001) { F_PROFILE(f,thread,position)=heat_flux1; } else if (time>=0.0001) { F_PROFILE(f,thread,position)=heat_flux2; } } end_f_loop(f,thread) } |
|
December 24, 2020, 01:11 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
first one is better, cause you will execute macro CURRENT_TIME once (outside of the loop). So in case you have few hundred millions of finite cells in model, you will feel the effect.
But both wold give same result.
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 24, 2020, 03:47 |
|
#3 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
It's even possible that the compiler is smart enough to put it out of the loop, and give you identical compiled code.
So I would say: use the one you expect to still understand two years from now. My version would be like this: Code:
#include "udf.h" DEFINE_PROFILE(hf_change,thread,position) { face_t f; const real heat_flux1 = 0; const real heat_flux2 = 500; const real switch time = 0.0001; const real time = CURRENT_TIME; const real hf = time<switch_time?heat_flux1:heat_flux2; begin_f_loop(f,thread) { F_PROFILE(f,thread,position)=hf; } end_f_loop(f,thread) } |
|
December 24, 2020, 10:00 |
Hi,pakk, thank you for your help, I have a question ,is there any wrong with the belo
|
#4 | |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
Quote:
Hi,pakk, thank you for your help, I have a question ,is there any wrong with the below code, there is a "?" here, is that right? const real hf = time<switch_time?heat_flux1:heat_flux2; When I use your code to compile, it gives the following error, what is the reason? ************************************************** ************************** ************************************************** ************************** ** WARNING: Automatically switched to run in parallel -t1 mode. ** ** Detected non-parallelized UDF usage, enabling parallel usage. ** ** If you encounter any issues, please re-run with -t0 flag. ** ************************************************** ************************** ************************************************** **************************Creating user_nt.udf file for 2ddp_host ... (system "copy "D:\PROGRA~1\ANSYSI~1\v190\fluent"\fluent19.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_host\makefile" ") ÒѸ´ÖÆ 1 ¸öÎļþ¡£ (chdir "libudf")(chdir "win64\2ddp_host")# Generating ud_io1.h wallheat.c ..\..\src\wallheat.c(8) : error C2143: Óï·¨´íÎó : ȱÉÙ¡°;¡±(ÔÚ¡°switch¡±µÄÇ°Ãæ) ..\..\src\wallheat.c(8) : error C2059: Óï·¨´íÎó:¡°¿ÕÉùÃ÷¡± ..\..\src\wallheat.c(8) : error C2061: Óï·¨´íÎó: ±êʶ·û¡°time¡± ..\..\src\wallheat.c(9) : error C2143: Óï·¨´íÎó : ȱÉÙ¡°;¡±(ÔÚ¡°const¡±µÄÇ°Ãæ) ..\..\src\wallheat.c(10) : error C2143: Óï·¨´íÎó : ȱÉÙ¡°;¡±(ÔÚ¡°ÀàÐÍ¡±µÄÇ°Ãæ) ..\..\src\wallheat.c(13) : error C2065: ¡°hf¡±: δÉùÃ÷µÄ±êʶ·û ************************************************** ************************** ************************************************** ************************** ** WARNING: Automatically switched to run in parallel -t1 mode. ** ** Detected non-parallelized UDF usage, enabling parallel usage. ** ** If you encounter any issues, please re-run with -t0 flag. ** ************************************************** ************************** ************************************************** **************************Creating user_nt.udf file for 2ddp_node ... (system "copy "D:\PROGRA~1\ANSYSI~1\v190\fluent"\fluent19.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_node\makefile" ") ÒѸ´ÖÆ 1 ¸öÎļþ¡£ (chdir "libudf")(chdir "win64\2ddp_node")# Generating ud_io1.h wallheat.c ..\..\src\wallheat.c(8) : error C2143: Óï·¨´íÎó : ȱÉÙ¡°;¡±(ÔÚ¡°switch¡±µÄÇ°Ãæ) ..\..\src\wallheat.c(8) : error C2059: Óï·¨´íÎó:¡°¿ÕÉùÃ÷¡± ..\..\src\wallheat.c(8) : error C2061: Óï·¨´íÎó: ±êʶ·û¡°time¡± ..\..\src\wallheat.c(9) : error C2143: Óï·¨´íÎó : ȱÉÙ¡°;¡±(ÔÚ¡°const¡±µÄÇ°Ãæ) ..\..\src\wallheat.c(10) : error C2143: Óï·¨´íÎó : ȱÉÙ¡°;¡±(ÔÚ¡°ÀàÐÍ¡±µÄÇ°Ãæ) ..\..\src\wallheat.c(13) : error C2065: ¡°hf¡±: δÉùÃ÷µÄ±êʶ·û Done. Last edited by hitzhwan; December 24, 2020 at 11:21. |
||
December 24, 2020, 12:19 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
There should be an underscore between switch and time, sorry. Not in the line you quote, but in line 8.
But if you don't understand my code:don't use it. If you don't understand it, you can not maintain it. |
|
December 24, 2020, 12:45 |
Thank you ,Pakk, you are right , after I add a underscore, it has no error. But it s
|
#6 |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
Thank you ,Pakk, you are right , after I add a underscore, it has no error. But it still cannot change the heat flux. I think the code is not too difficult to understand, does there has other thing should I do before I run? Would you please tell me how to process it, thank you so much.
|
|
December 24, 2020, 13:36 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
How did you investigate that the heat Flux did not change?
|
|
December 24, 2020, 13:39 |
I monitor the heat flux in the wall and plot it in the console.
|
#8 |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
||
December 24, 2020, 14:17 |
|
#9 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
Change heatflux1 to 1000, just to see if you see a difference.
|
|
December 24, 2020, 16:11 |
There is no difference, the heat flux is still 0, it shows the codes does not work.
|
#10 |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
||
December 24, 2020, 20:01 |
|
#11 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
No, it shows that
- the code is not used (did you really apply it to the BC? And really this version?) - OR your method to get heat flux is wrong. Do you see temperatures changing? |
|
December 24, 2020, 21:26 |
Yes,the code is applied on the BC,I use the compiled method, and I Hook it by the Dr
|
#12 |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
Yes,the code is applied on the BC,I use the compiled method, and I Hook it by the Drop-down menu. Can you use it in your computer?
|
|
December 25, 2020, 14:57 |
|
#13 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
No, I don't have Fluent on my pc.
|
|
December 27, 2020, 23:36 |
|
#14 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
everything works well.
and monitor works well either: in surface report definition window area-weight average -> wall fluxes -> total surface heat flux
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 28, 2020, 12:56 |
Have you run it in your pc? which code do you use?
|
#15 |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
||
December 29, 2020, 01:51 |
|
#16 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
I've used code of Pakk, but all of them works.
1. compile code 2. load compiled library 3. select any wall -> thermal tab -> heat flux -> select udf function instead of constant run transient simulation
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 29, 2020, 11:24 |
You mean the below code you load work? Why I have some errors when I load it by the s
|
#17 | |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
Quote:
You mean the below code you load work? Why I have some errors when I load it by the same process, what fluent edition do you use? Would you please send me your case and udf to me, I want to try more, thank you so much . #include "udf.h" DEFINE_PROFILE(hf_change,thread,position) { face_t f; const real heat_flux1 = 0; const real heat_flux2 = 500; const real switch time = 0.0001; const real time = CURRENT_TIME; const real hf = time<switch_time?heat_flux1:heat_flux2; begin_f_loop(f,thread) { F_PROFILE(f,thread,position)=hf; } end_f_loop(f,thread) } |
||
December 30, 2020, 05:41 |
|
#18 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Unfortunately, I'm not able to send you any files.
This is not the problem of version, code is simple and should work in any version. I recommend you to make new test simple geometry: rectangular, make it solid, not fluid make new source file (with other name) and compile it again load and apply UDF, run transient simulation most likely, you didn't compile the code
__________________
best regards ****************************** press LIKE if this message was helpful |
|
December 30, 2020, 12:09 |
why to make it solid, not fluid?
|
#19 | |
Senior Member
Join Date: Dec 2017
Posts: 387
Rep Power: 9 |
Quote:
|
||
December 30, 2020, 06:20 |
|
#20 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 |
Quote:
|
||
Tags |
udf |
|
|