|
[Sponsors] |
March 22, 2005, 12:30 |
UDF Help
|
#1 |
Guest
Posts: n/a
|
Below is the plain C code for my heat flux UDF. I have no idea how to change this into something Fluent can use (I didn't write this code, I don't know any C!). The heat flux should be the same across the whole face at any given time and follow the equation Q=15E09*sin(t(pi/13E-09)).
Please could someone convert this into something useable by Fluent 6.1.1.8. It shouldn't take much time for someone who knows what they're doing. Thankyou. #include <math.h> double Q(double t) { double A, PI, B, C; unsigned int badReturn = -1; A = pow(10., 9.); PI = 3.14159265; B = pow(10., -9.); C = (15 * B); if(t < 0 || t > C) return double(badReturn); return A * sin(t*(PI/C)); } |
|
March 22, 2005, 14:56 |
Re: UDF Help
|
#2 |
Guest
Posts: n/a
|
The flux described by the C code you posted is:
Q = 15*10^9 sin(t*pi/(15*10^-9)) if t <= 15*10^-9 The function returns -1 if t < 0 (Never, time is never negative!) or if t > 15*10^-9. I think you want to have the source only for t <= 15*10^-9, and no source after this time. If so the code is the following: #include "udf.h" DEFINE_SOURCE(heat_source,c,t,dS,eqn) { real a,b,c,t, source; /* Getting the current time in seconds */ t = CURRENT_TIME; /* Calculating a, b and c */ a = pow(10., 9); b = pow(10., -9); c = 15.*b; /* Calculating the source term */ if (t <= c) { source = a*sin(t*M_PI/c); } else { source = 0.; } dS[eqn] = 0.; return source; } I hope it works. Regards, ap |
|
March 22, 2005, 15:49 |
Re: UDF Help
|
#3 |
Guest
Posts: n/a
|
Thankyou for your swift response. When I try to interpret the .c file which I copy/pasted the code into I get the following error:
cpp -IC:\fluent.inc\fluent6.1/src -IC:\fluent.inc\fluent6.1/cortex/src -IC:\fluent.inc\fluent6.1/client/src -IC:\fluent.inc\fluent6.1/multiport/src -I. -DUDFCONFIG_H="<udfconfig.h>" [.c file address] Error: [.c file address]: line 1: parse error. Any idea what could be causing this? |
|
March 24, 2005, 07:12 |
Re: UDF Help
|
#4 |
Guest
Posts: n/a
|
Sorry, I made a mistake in the definition of the DEFINE_SOURCE.
The following code is properly interpreted by FLUENT. #include "udf.h" DEFINE_SOURCE(heat_source,cell,thread,dS,eqn) { real a,b,c,t, source; /* Getting the current time in seconds */ t = CURRENT_TIME; /* Calculating a, b and c */ a = pow(10., 9); b = pow(10., -9); c = 15.*b; /* Calculating the source term */ if (t <= c) { source = a*sin(t*M_PI/c); } else { source = 0.; } dS[eqn] = 0.; return source; } Best regards, ap |
|
March 29, 2005, 04:45 |
Re: UDF Help
|
#5 |
Guest
Posts: n/a
|
I still get the same error. Any other possibilities?
|
|
March 29, 2005, 07:04 |
Re: UDF Help
|
#6 |
Guest
Posts: n/a
|
Can you e-mail me the file you're trying to compile?
Best regards, ap |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 07:37 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 22:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 21:38 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 04:03 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 04:01 |