# udf for pressure variation with time

 User Name Remember Me Password
 Register Blogs Members List Search Today's Posts Mark Forums Read

April 30, 2014, 04:29
udf for pressure variation with time
#1
New Member

laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 5
i have been working on designing a udf for systolic and diastolic pressure variations. so far i have compiled it in C but fluent gives me error in line 5 . if anybody can detect that error
i have attached my udf .
regards
Attached Files
 Untitled1.c (412 Bytes, 24 views)

 April 30, 2014, 08:42 #2 Senior Member   François Grégoire Join Date: Jan 2010 Location: Laval University, Canada Posts: 389 Rep Power: 10 So you meant pressure variation with space and not time? There are typos in your udf, you didn't give any value to y, etc. Start with this example from UDF manual 15.0 and insert your else-if conditions: 2.3.19.3. Example 1 - Pressure Profile Code: ```/*********************************************************************** UDF for specifying steady-state parabolic pressure profile boundary profile for a turbine vane ************************************************************************/ #include "udf.h" DEFINE_PROFILE(pressure_profile,t,i) { real x[ND_ND]; /* this will hold the position vector */ real y; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); y = x[1]; F_PROFILE(f,t,i) = 1.1e5 - y*y/(.0745*.0745)*0.1e5; } end_f_loop(f,t) }```

 May 5, 2014, 03:41 #3 New Member   laraib syed Join Date: Apr 2014 Posts: 13 Rep Power: 5 the pressure variation is with time and i gave the initial value for time = 0.005 sec even that didnt work. udf does not run after line 5. nd y is time .

 May 5, 2014, 03:42 #4 New Member   laraib syed Join Date: Apr 2014 Posts: 13 Rep Power: 5 i started off with the same example and derived the udf i have posted ..but now its not running

 May 5, 2014, 07:09 #5 Senior Member   François Grégoire Join Date: Jan 2010 Location: Laval University, Canada Posts: 389 Rep Power: 10 Then you have to define y like this in your udf: real y = CURRENT_TIME;

May 8, 2014, 04:30
#6
New Member

laraib syed
Join Date: Apr 2014
Posts: 13
Rep Power: 5
thank you so much . my udf runs now and is detected at the inlet pressure options.
but the solution does not initialize and gives errors that i am unable to comprehend
i have attached an image of the errors
kindly if u can have a look.
and secondly do i need to start my fluent via SDK? as it is already interpreting the udf .
Attached Images
 Untitled.jpg (31.0 KB, 9 views)

 May 8, 2014, 06:52 #7 Senior Member   François Grégoire Join Date: Jan 2010 Location: Laval University, Canada Posts: 389 Rep Power: 10 It's hard to say because I don't really know what you tried... In the udf that you attached in your 1st post, it looks like you are using y for 2 things: position and time. You should define y as position: real y; .... then inside the f_loop: y = x[1]; And define another variable as time: real t = CURRENT_TIME; Good luck

 May 8, 2014, 10:09 #8 New Member   laraib syed Join Date: Apr 2014 Posts: 13 Rep Power: 5 i dont intend to give y two variables the equations i have used are with respect to time . so y is time not position . so i do not need to define y=x[1], as this represents position. if u can kindly let me know the changes i have to make to make y only time varying regards

 May 8, 2014, 10:17 #9 Senior Member   François Grégoire Join Date: Jan 2010 Location: Laval University, Canada Posts: 389 Rep Power: 10 show us your udf please, not in an attached file, directly in a reply

 May 10, 2014, 00:34 #10 New Member   laraib syed Join Date: Apr 2014 Posts: 13 Rep Power: 5 # include "udf.h" #DEFINE_PROFILE(pressure_profile,t,i) { real x[ND_ND] real y= CURRENT_TIME; face_t f; } begin_f_loop(f,t); { F_CENTROID(x,f,t); if (y>0.005 && y<=0.4); F_profile(f,t,i)=(-492.9*y^4+1224.3*y^3-1081.8*y^2+357.6*y+64.2); else if (y>0.4 && y<=0.46); F_profile(f,t,i)= (100*y+60); else F_profile(f,t,i)=(14195*y^4-11116*y^3+2087*y^2+106*y+70.9); end_f_loop(f,t) } here is my udf. will appreciate any input regards

 May 10, 2014, 01:13 #11 Senior Member   François Grégoire Join Date: Jan 2010 Location: Laval University, Canada Posts: 389 Rep Power: 10 inspect the braces compared to the example in post #2...

 May 13, 2014, 04:32 #12 New Member   laraib syed Join Date: Apr 2014 Posts: 13 Rep Power: 5 the udf runs in visual studio giving no errors or warnings. now i am going to download SDK. i hope fluent reads it this time thank you for ur help

May 13, 2014, 08:09
#13
Senior Member

François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 389
Rep Power: 10
Quote:
 Originally Posted by laraib # include "udf.h" #DEFINE_PROFILE(pressure_profile,t,i) { real x[ND_ND] real y= CURRENT_TIME; face_t f; } what's that brace for??? begin_f_loop(f,t); { F_CENTROID(x,f,t); if (y>0.005 && y<=0.4); F_profile(f,t,i)=(-492.9*y^4+1224.3*y^3-1081.8*y^2+357.6*y+64.2); else if (y>0.4 && y<=0.46); F_profile(f,t,i)= (100*y+60); else F_profile(f,t,i)=(14195*y^4-11116*y^3+2087*y^2+106*y+70.9); } missing brace here end_f_loop(f,t) } here is my udf. will appreciate any input regards

I don't know about running UDFs in VS, but I can tell you that it's preferable to follow the UDF Manual syntax if you want your udf to work.

 May 13, 2014, 11:56 #14 New Member   laraib syed Join Date: Apr 2014 Posts: 13 Rep Power: 5 # include "udf.h" #DEFINE_PROFILE(pressure_profile,t,i) { real x[ND_ND] real y= CURRENT_TIME; face_t f; } this brace is closure for the parameters above.its correct in syntax begin_f_loop(f, t); { F_CENTROID(x, f, t); if (y > 0.005 && y <= 0.4); F_profile(f, t, i) = (-492.9*y ^ 4 + 1224.3*y ^ 3 - 1081.8*y ^ 2 + 357.6*y + 64.2); else if (y > 0.4 && y <= 0.46); F_profile(f, t, i) = (100 * y + 60); else F_profile(f, t, i) = (14195 * y ^ 4 - 11116 * y ^ 3 + 2087 * y ^ 2 + 106 * y + 70.9); }brace not required here otherwise it gives errors end_f_loop(f,t) }

May 13, 2014, 12:22
#15
Senior Member

François Grégoire
Join Date: Jan 2010
Location: Laval University, Canada
Posts: 389
Rep Power: 10
Quote:
 Originally Posted by laraib # include "udf.h" #DEFINE_PROFILE(pressure_profile,t,i) { real x[ND_ND] real y= CURRENT_TIME; face_t f; } this brace is closure for the parameters above.its correct in syntax No, because the corresponding opening brace opens the body of the DEFINE_PROFILE function, not some parameters declaration. And it's probably useless and a bad programming practice to define parameters within braces, think I've never seen that. begin_f_loop(f, t); { F_CENTROID(x, f, t); if (y > 0.005 && y <= 0.4); F_profile(f, t, i) = (-492.9*y ^ 4 + 1224.3*y ^ 3 - 1081.8*y ^ 2 + 357.6*y + 64.2); else if (y > 0.4 && y <= 0.46); F_profile(f, t, i) = (100 * y + 60); else F_profile(f, t, i) = (14195 * y ^ 4 - 11116 * y ^ 3 + 2087 * y ^ 2 + 106 * y + 70.9); }brace not required here otherwise it gives errors You need to read the UDF Manual, the set of commands in looping macros are always within braces. end_f_loop(f,t) }
Last post from me, good luck.

 May 14, 2014, 12:17 #16 Senior Member   Andrew Kokemoor Join Date: Aug 2013 Posts: 122 Rep Power: 7 Macfly is right about the braces. The variable declarations and the f_loop are both part of the define macro. Closing your brace after the variable declarations says that the macro ends here, and your loop isn't part of anything. Using Visual Studio to decide whether your code will run or not won't tell you anything useful; UDFs are not programs, they are chunks of code that Fluent uses to compile libraries.

 May 16, 2014, 00:58 #17 New Member   laraib syed Join Date: Apr 2014 Posts: 13 Rep Power: 5 i have changed the braces as suggested by macfly. but still the problem previals that the solution does not initialize

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 14:12 gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58 Komon Fluent UDF and Scheme Programming 1 April 1, 2012 19:53 m9819348 OpenFOAM Running, Solving & CFD 7 October 27, 2007 00:36 skabilan OpenFOAM Running, Solving & CFD 12 September 17, 2007 17:48