|
[Sponsors] |
June 24, 2021, 13:13 |
Osi udf
|
#1 |
Senior Member
Ali reza
Join Date: Mar 2014
Posts: 110
Rep Power: 12 |
Hi
I found this UDF online (I am not very familiar with UDF coding) and I used it to calculate OSI. I am using ANSYS-Fluent 2021. I used 5 memories for the UDM and run the simulation. All the values out of these UDMs are zero. Any suggestions? Code:
/****************************************************** Oscillatory shear index ******************************************************/ #include "udf.h" #include "math.h" #include "storage.h" #include "sg_udms.h" #define domain_ID 1 #define zone_ID 1 /* Initialize the UDM value to zero in complete domain */ DEFINE_INIT(meminit,domain) { Thread *c_thread; cell_t c; thread_loop_c(c_thread,domain) { begin_c_loop(c, c_thread) { C_UDMI(c,c_thread,0)= 0; C_UDMI(c,c_thread,1)= 0; C_UDMI(c,c_thread,2)= 0; C_UDMI(c,c_thread,3)= 0; C_UDMI(c,c_thread,4)= 0; } end_c_loop(c, c_thread) } } /* Calculate wall shear stress and store them in UDM */ DEFINE_EXECUTE_AT_END(OSI) { Domain *domain; real area; face_t f; real A[ND_ND]; cell_t c, c0; Thread *t,*t0, *c_thread; real wallshear [ND_ND]; domain = Get_Domain(domain_ID); t = Lookup_Thread(domain,zone_ID); begin_f_loop(f, t) { F_AREA(A,f,t); area = NV_MAG(A); NV_V(wallshear,=,F_STORAGE_R_N3V(f,t, SV_WALL_SHEAR)); c0 = F_C0(f,t); t0 = THREAD_T0(t); C_UDMI(c0,t0,0) = NV_MAG(wallshear)/area; C_UDMI(c0,t0,1) = -wallshear[0]/area; C_UDMI(c0,t0,2) = -wallshear[1]/area; C_UDMI(c0,t0,3) = -wallshear[2]/area; C_UDMI(c0,t0,4) = (1.-sqrt(C_UDMI(c0,t0,1)*C_UDMI(c0,t0,1) + C_UDMI(c0,t0,2)*C_UDMI(c0,t0,2) + C_UDMI(c0,t0,3)*C_UDMI(c0,t0,3))/C_UDMI(c0,t0,0))/2; } end_f_loop(f,t) } |
|
June 24, 2021, 14:12 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Maybe you did not hook the execute_at_end?
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
June 24, 2021, 16:36 |
|
#3 |
Senior Member
Ali reza
Join Date: Mar 2014
Posts: 110
Rep Power: 12 |
Thank you for the response. Is it a line or something that I am missing in the code or you mean running the CFD and having the UDF compiled? I compiled it with no error and ran the CFD simulation with no problem.
|
|
June 25, 2021, 01:34 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
After compiling the UDF, you have to tell Fluent to use it. This is called hooking. Look in the manual, it is explained below every example of a UDF.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
June 25, 2021, 01:57 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
compile UDF
load compiled library (in console you will see the list of available functions, you've loaded) in interface: user defined-> function hooks -> initialization -> choose you function -> ok execute at end -> choose you function -> ok ->ok
__________________
best regards ****************************** press LIKE if this message was helpful |
|
August 23, 2022, 01:45 |
Compilation warning
|
#6 |
New Member
Md Asif Equbal
Join Date: Aug 2022
Location: India
Posts: 15
Rep Power: 4 |
After compilation of UDF, one warning is generated on console screen.
'unsigned long' [-Wint-to-void-pointer-cast] return ( (void * POINTER_32) (unsigned long) (UNLONG_PTR) P); I want to know where is the problem. If anyone help it must be appreciated. Thanks in advance. |
|
August 23, 2022, 04:07 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
in case you need help you should provide the whole information:
full log output warnings usually don't lead to problems with running the code
__________________
best regards ****************************** press LIKE if this message was helpful |
|
August 24, 2022, 14:53 |
|
#8 |
New Member
Md Asif Equbal
Join Date: Aug 2022
Location: India
Posts: 15
Rep Power: 4 |
Dear AlexanderZ,
After compilation and hooking the UDF when I start the simulation the fluent exits without showing any error. Try so many times but not succeeded. I am using Ansys 2022R1. Can anyone help what is the actual problem. Here is the screenshot of the Fluent. Last edited by mep20108@tezu.ac.in; August 25, 2022 at 23:39. |
|
October 24, 2022, 01:41 |
|
#9 | |
New Member
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4 |
Quote:
|
||
October 24, 2022, 07:01 |
|
#10 |
New Member
Md Asif Equbal
Join Date: Aug 2022
Location: India
Posts: 15
Rep Power: 4 |
Dear shima,
First you set user defined memory (UDM). In this case it is 5. Make sure you have also changed zone Id as per your boundary where you want apply OSI. After that you can go for hooking. I did in similar way it solved my problem. Hope it works for you too. |
|
October 24, 2022, 08:38 |
|
#11 | |
New Member
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4 |
Quote:
I set the number of memories But Where is the "Zone id" in fluent? And exactly what should i do? Last edited by sara9310; October 24, 2022 at 16:10. |
||
October 31, 2022, 02:46 |
|
#12 |
New Member
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5 |
zone id for each component, you can see it in the boundary condition
|
|
October 31, 2022, 03:50 |
|
#13 |
New Member
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4 |
||
November 1, 2022, 05:44 |
|
#14 |
New Member
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5 |
||
November 1, 2022, 12:34 |
|
#15 | |
New Member
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4 |
Quote:
I wrote real zone_ID = 21; But when i complie udf; 2 error is showing: 1) missing ';' before constant 2) 'real' : illegal use of this type as an expression How can i solve these problems?! |
||
November 2, 2022, 00:24 |
|
#16 |
New Member
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5 |
can you post your UDF code here, so that the expert members take a look and suggest any changes.
|
|
November 2, 2022, 01:49 |
|
#17 | |
New Member
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4 |
Quote:
I upload udf file. When I compile this udf, for two line: real domain_ID=1; real zone_ID=21; These errors appear: 1) missing ';' before constant 2) 'real' : illegal use of this type as an expression |
||
November 2, 2022, 02:07 |
|
#18 | |
New Member
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5 |
Quote:
delete line numbers 54 (real domain_ID = 1 and 55 (real zone_ID = ? from your UDF code and try to run it. I am quite sure this time you will run it successfully. All the best |
||
November 2, 2022, 03:51 |
|
#19 | |
New Member
shima mohammadi
Join Date: Oct 2022
Posts: 14
Rep Power: 4 |
Quote:
Some body tell me zone id should specify in code; how can I solve this problem? Last edited by sara9310; November 2, 2022 at 05:35. |
||
November 2, 2022, 06:01 |
|
#20 | |
New Member
Suraj Shembekar
Join Date: Feb 2021
Location: India
Posts: 18
Rep Power: 5 |
Quote:
Yes, the zone ID should be specified in the code for the component on which you would like to see the OSI contours in CFD post. (mostly, people use to see the OSI contours on the "wall", so the zone ID of the wall should be specified within the code). |
||
Tags |
ansys-fluent, osi, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
udf for one dimensional linear motion based on force | maccheese | Fluent UDF and Scheme Programming | 2 | September 1, 2019 03:18 |
can anyone help me about the udf of dynamic contact angle in FLUENT? | Albert Lee | FLUENT | 0 | July 1, 2018 09:21 |
Save output of udf in another udf! | JuanJoMex | FLUENT | 0 | February 8, 2018 13:43 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |