|
[Sponsors] |
March 2, 2015, 02:38 |
New to UDF
|
#1 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Hi,
I am new to fluent UDF. I need to compute shock and viscous regions using the following sensor equations. My question is how to write udf for these two? Any help would be appreciated. Shivakumar |
|
March 2, 2015, 09:10 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
If you hope that somebody will read this, and will give you the UDF code, I predict that this will probably not happen. (Although I might be wrong...)
A better approach would be the following: "Hi, I am new to fluent UDF. I need to compute shock and viscous regions using the following sensor equations. I have looked into the Fluent manual, and found the UDF manual, and my first attempt to a udf was this: ...insert your code here... Unfortunately, this did not work, because when I tried to compile it, Fluent said there was an error in line 5, but I don't understand that. Can anybody help me understand what is wrong with my code, and give me hints to get a working code for those two equations? Any help would be appreciated. Shivakumar" |
|
March 5, 2015, 22:51 |
|
#3 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Start with reading the section for DEFINE_SOURCE in the UDF manual. Next, you need to extract the values of the cell variables in those equations using macros such as C_NUT for turbulent viscosity.
|
|
March 6, 2015, 04:55 |
|
#4 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thanks for the reply. I have written a program for the first equation( 1st thread ) and getting compilation error as udf is not compiled. The program looks like this. Please help.
#include "udf.h" #define a 340.26 DEFINE_ON_DEMAND(shock_sensor) { Domain *d; Thread *t; cell_t c; d=Get_Domain(1); real f_shock, velocity; thread_loop_c(t,d) { begin_c_loop(c,t) { velocity=(C_U(c,t)+C_V(c,t)); f_shock = (velocity*C_P_G(c,t))/(a*abs(C_P_G(c,t))); if(f_shock>=1) { C_UDMI(c,t,0)=f_shock; } } end_c_loop(c,t) } } |
|
March 6, 2015, 05:07 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
And which compilation error do you get?
|
|
March 6, 2015, 05:27 |
|
#6 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thanks for your speedy response.
The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64). The operation completed successfully. C:\libudf\win64\2ddp_host\libudf.dll Is this program is correct according to that equation? Thanks |
|
March 6, 2015, 05:41 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
That is the load error, not the compilation error. Which error do you see when you click "build"?
|
|
March 6, 2015, 06:11 |
|
#8 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Not understanding this...
1 file(s) copied. Copied C:\Users\NAL\Desktop\shiva\RAE2822\Un_str/C:\Users\NAL\Desktop\shiva\RAE2822\Un_str\shock_se nsor.c to libudf\src (system "copy "C:\PROGRA~1\ANSYSI~1\v140\fluent"\fluent14.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp_host\makefile" ") 1 file(s) copied. (chdir "libudf")() (chdir "win64\2ddp_host")() 'nmake' is not recognized as an internal or external command, operable program or batch file. 'nmake' is not recognized as an internal or external command, operable program or batch file. (system "copy "C:\PROGRA~1\ANSYSI~1\v140\fluent"\fluent14.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp_node\makefile" ") 1 file(s) copied. (chdir "libudf")() (chdir "win64\2ddp_node")() 'nmake' is not recognized as an internal or external command, operable program or batch file. 'nmake' is not recognized as an internal or external command, operable program or batch file. Done. Opening library "C:\Users\NAL\Desktop\shiva\RAE2822\Un_str\libudf" ... Primitive Error at Node 0: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64). The operation completed successfully. C:\Users\NAL\Desktop\shiva\libudf\win64\2ddp_node\ libudf.dll Primitive Error at Node 1: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64). The system cannot find the file specified. C:\Users\NAL\Desktop\shiva\libudf\win64\2ddp_node\ libudf.dll Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64). The operation completed successfully. C:\Users\NAL\Desktop\shiva\RAE2822\Un_str\libudf\w in64\2ddp_host\libudf.dll Error Object: #f |
|
March 6, 2015, 06:20 |
|
#9 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Your problem is not the code, but that your computer has no compiler installed. Or at least not in the correct way, Fluent can not find the compiler.
I don't know much about how to set up Fluent for compiling, but search on this forum for "'nmake' is not recognized as an internal or external command", and you will find more of those questions with helpful answers. |
|
March 6, 2015, 06:34 |
|
#10 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thank you very much. I will install compiler, but how? which?
shivakumar |
|
March 6, 2015, 07:10 |
|
#11 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
Maybe this is what you are searching:
http://www.cfd-online.com/Wiki/Fluen..._32bit_systems
__________________
Google is your friend and the same for the search button! |
|
March 6, 2015, 13:16 |
|
#12 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thank you very much for the quick response.. That is helpful.
|
|
March 9, 2015, 13:55 |
|
#13 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
I had gone through the steps but still getting the errors while building. The error is
> Deleted old libudf\win64\2ddp\libudf.dll 1 file(s) copied. Copied C:\Users\Mallikarjun\Desktop\New folder\C\compile_it\shock_sensor.c to libudf\src (system "copy "C:\PROGRA~1\ANSYSI~1\v140\fluent"\fluent14.0.0\sr c\makefile_nt.udf "libudf\win64\2ddp\makefile" ") 1 file(s) copied. (chdir "libudf")() (chdir "win64\2ddp")() # Generating ud_io1.h shock_sensor.c ..\..\src\shock_sensor.c(11) : error C2275: 'real' : illegal use of this type as an expression c:\program files\ansys inc\v140\fluent\fluent14.0.0\src\global.h(167) : see declaration of 'real' ..\..\src\shock_sensor.c(11) : error C2146: syntax error : missing ';' before identifier 'f_shock' ..\..\src\shock_sensor.c(11) : error C2065: 'f_shock' : undeclared identifier ..\..\src\shock_sensor.c(11) : error C2065: 'velocity' : undeclared identifier ..\..\src\shock_sensor.c(16) : error C2065: 'velocity' : undeclared identifier ..\..\src\shock_sensor.c(17) : error C2065: 'f_shock' : undeclared identifier ..\..\src\shock_sensor.c(17) : error C2065: 'velocity' : undeclared identifier ..\..\src\shock_sensor.c(17) : error C2297: '*' : illegal, right operand has type 'real [2]' ..\..\src\shock_sensor.c(17) : warning C4047: 'function' : 'int' differs in levels of indirection from 'real [2]' ..\..\src\shock_sensor.c(17) : warning C4024: 'abs' : different types for formal and actual parameter 1 ..\..\src\shock_sensor.c(19) : error C2065: 'f_shock' : undeclared identifier ..\..\src\shock_sensor.c(21) : error C2440: '=' : cannot convert from 'void (*)(void)' to 'real' Done. Thanks Shivakumar |
|
March 10, 2015, 07:31 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I think you are declaring a variable too late.
Code:
d=Get_Domain(1); <-- an assignment real f_shock, velocity; <-- a declaration |
|
March 10, 2015, 13:10 |
|
#15 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thanks for the reply. Nice suggestion. I did and worked well but with 3 errors.
# Generating ud_io1.h shock_sensor.c ..\..\src\shock_sensor.c(18) : error C2297: '*' : illegal, right operand has type 'real [2]' ..\..\src\shock_sensor.c(18) : error C2440: 'function' : cannot convert from 'real [2]' to 'double' ..\..\src\shock_sensor.c(18) : warning C4024: 'fabs' : different types for formal and actual parameter 1 Done. |
|
March 10, 2015, 16:40 |
|
#16 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
You're trying to evaluate a vector (real array: 'velocity') and scalar with a multiplication operator. The C_U(c,t) macro returns a vector quantity, either select one dimension, C_U(c,t)[0], or determine the magnitude of the 'velocity' vector.
|
|
March 11, 2015, 04:43 |
|
#17 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
The problem is indeed that he/she is trying to multiply a vector with a scalar, but here 'velocity' is the scalar. C_U(c,t) returns the x-component of velocity, so is a scalar (in the programming definition of scalar, not in the physical definition of scalar, since it depends on the coordinate system). The vector in this problem is C_P_G, the gradient of the pressure. At this point, there is no advice we can give you (shivakumar) with respect to programming, because the problem is in your equation. Which part of the pressure gradient do you want? Magnitude? X-component? Sum of X and Y-component? They all can be programmed. |
||
March 11, 2015, 05:35 |
|
#18 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Ok, C_P_G is the gradient of pressure which of course is a vector quantity. I was thinking of P_VEL(p)[i] for the DPM where the velocity components are taken from the single macro rather than having an individual macro for each component (C_U, C_V and C_W for the fluid phase). Woops, I thought Fluent would have more consistent naming conventions...
|
|
March 11, 2015, 12:39 |
|
#19 |
Senior Member
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13 |
Thank you for your valuable responses.. Yes, the velocity vector is multiplied with the gradient of pressure. Since I am new to this udf, confusing which macro to use and all..
I tried using array C_U(c,t)[0] and still got the errors.. Let me share the whole paper which I am referring to you. http://www.researchgate.net/profile/...9ffb000000.pdf Thank you Shivakumar |
|
March 11, 2015, 17:51 |
|
#20 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
Firstly, from our discussion above, the C_U macro gives only the x-component of the local cell velocity. There is no need to call the first element of the array C_U; namely C_U(c,t)[0].
The equation you're using has the dot product of the velocity vector (bold text style represents a vector quantity) with the gradient of pressure (del P). There may or may not be a dot product function available within Fluent/C. Otherwise, if you're working with 3D cartesian coordinates you could manually perform this operation yielding the following numerator for the f_shock evaluation: Code:
(C_U(c,t)*C_P_G(c,t)[0] + C_V(c,t)*C_P_G(c,t)[1] + C_W(c,t)*C_P_G(c,t)[2]) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 08:26 |
Source Term UDF VS Porous Media Model | pchoopanya | Fluent UDF and Scheme Programming | 1 | August 28, 2013 07:12 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 22:38 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 05:03 |