CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Problem with UDF on a Linux machine (Red Hat)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By spring

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2009, 11:55
Default Problem with UDF on a Linux machine (Red Hat)
  #1
New Member
 
Iaroslav
Join Date: May 2009
Posts: 16
Rep Power: 17
Iaroslav is on a distinguished road
Hello everyone,

I have written a simple UDF (DEFINE_TURBULENT_VISCOSITY) to modify the eddy viscosity calculated by the standard k-e model. I have run several simulations in Windows Vista with Fluent interpreting my UDF with no problems at all. However, when I try to run the same simulation on the Linux machine (Red Hat) I am getting an eeror message that informs me of a syntax error on line 2. Here is my UDF:

#include "udf.h"

DEFINE_TURBULENT_VISCOSITY(custom_mu_t, c, t)
{
real mu_t;
real s_11;
real s_12;
real s_22;
real s_g;
real div_vel;
real mach_g;
real l_g;
real alpha;
real c_mu;

real rho = C_R(c,t);
real k = C_K(c,t);
real d = C_D(c,t);
real temper = C_T(c,t);
real dudx = C_DUDX(c,t);
real dvdy = C_DVDY(c,t);
real dudy = C_DUDY(c,t);
real dvdx = C_DVDX(c,t);

s_11 = dudx;
s_22 = dvdy;
s_12 = 0.5*(dudy+dvdx);
div_vel = dudx+dvdy;

s_g = sqrt(2*((SQR(s_11)+2*SQR(s_12)+SQR(s_22))-1/3*SQR(div_vel)));

alpha = sqrt(1.4*287*temper);
l_g = 0.09*pow(k,1.5)/d;
mach_g = s_g*l_g/alpha;
c_mu = 0.07*exp(-0.4*mach_g);

mu_t = c_mu*rho*SQR(k)/d;

return mu_t;
}

Any help would really be appreciated as my Linux machine is much better at running simulations than my Windows laptop.

Thank you,
Iaroslav
Iaroslav is offline   Reply With Quote

Old   June 9, 2009, 14:20
Default
  #2
Member
 
Join Date: Mar 2009
Location: Istanbul, Turkiye
Posts: 47
Rep Power: 17
gemini is on a distinguished road
try

dos2unix filename

command in console. it may help to you.

try web search for dos2unix for its description
gemini is offline   Reply With Quote

Old   June 9, 2009, 15:07
Default
  #3
New Member
 
Iaroslav
Join Date: May 2009
Posts: 16
Rep Power: 17
Iaroslav is on a distinguished road
Thanks for the reply.

Unfortunately this did not solve my problem. First, I get the message "problems converting file mu_t.c" and then I get the same error message "syntax error on line 2". Furthermore, I don't know why this is happening in the first place since its a c course file and the only header I am using is udf.h.

Thanks,
Iaroslav
Iaroslav is offline   Reply With Quote

Old   June 9, 2009, 15:20
Default
  #4
Member
 
Join Date: Mar 2009
Location: Istanbul, Turkiye
Posts: 47
Rep Power: 17
gemini is on a distinguished road
I copied your function and it was was succesfully intepereted by FLUENT on my machine (64 bit OpenSUSE 11.1 on AMDX2-7750 4GBRAM). Maybe you should try another computer.

Regards.

Gemini
gemini is offline   Reply With Quote

Old   June 9, 2009, 15:38
Default
  #5
New Member
 
Iaroslav
Join Date: May 2009
Posts: 16
Rep Power: 17
Iaroslav is on a distinguished road
Thank you for the help Gemini,

I got it working my creating a completely new C file on my Linux system.

Many thanks,
Iaroslav
Iaroslav is offline   Reply With Quote

Old   May 12, 2010, 08:43
Default same problem
  #6
Member
 
Sarah
Join Date: Apr 2010
Location: Munich
Posts: 30
Rep Power: 16
spring is on a distinguished road
Hi Iaroslave,

I have the same problem. I got a udf file which I wrote in a text file with the ending .c, so that it would become a C file. When interpreting it in fluent in windows XP it is interpreted with no problems. But when I try to interpret it in fluent in linux it always shows me a syntax error in line 1, which by the way is empty.
Here is the code:

/************************************************** ********************
UDFprofile3D.c
UDF for specifying a steady-state velocity profile boundary condition
************************************************** ********************/

#include "udf.h" /* must be at the beginning of every UDF */

/* constants: */
#define R 8. /* inlet radius [mm] (with actual scaling in Fluent applied!) */
#define VFLOW 15. /* effective volume flow [l/min] */
#define POWER 1./7. /* 1/7 power law defining turbulent profile */


DEFINE_PROFILE(velocity_y,thread,index)
{
double PI;
real Umax; /* maximal inlet velocity */
real x[ND_ND]; /* this will hold the position vector every single face centroid */
real r;
face_t f;

PI = acos(-1.);
Umax = pow(10.,3.)*VFLOW/PI/pow((R),2.)/49.;

begin_f_loop(f,thread) /* loops over all faces in the thread passed
in the DEFINE macro argument */
{
F_CENTROID(x,f,thread);
r = sqrt(pow((1000*x[0]),2.)+pow((1000*x[2]),2.));
F_PROFILE(f,thread,index) = Umax*pow((1.-r/R),POWER);
}
end_f_loop(f,thread)
}


You said, that you solved this problem by writing a complete new C file in linux. I opend a file and copied my code into this file and then I added the ending .c, but it still doesn't work when I try to interprete it. Did I do something wrong? Can you please tell me in detail how you solved your problem, because I have EXACTLY the same problem you had.

And I also need to work on the linux machine because it is faster in running simulations (although I realy hate hate hate linux!).

Thanks,...
BigMc likes this.
spring is offline   Reply With Quote

Old   March 7, 2017, 14:15
Unhappy Dam Linux
  #7
New Member
 
Mike McManuc
Join Date: Nov 2016
Posts: 9
Rep Power: 10
BigMc is on a distinguished road
Hi,

I know this is an old post, but I have the exact same issue,

and I was hoping someone who may have solved it is still active on this Forum.

I tried dos2unix "myfilepath" but still get the line 1 syntax error.

I also tried nano "myfilepath" through my linux system to check for any irregular characters and there is none.
BigMc is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Compiled UDF problem 4 Wave tank tutorial Shane FLUENT 1 September 3, 2010 03:32
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 11:16
parallel UDF problem kerem FLUENT 2 June 20, 2006 07:56
Running Fluent on Red Hat Linux WS version 4 Bob FLUENT 1 September 4, 2005 06:01
Works in Red Hat Linux 6.2 with Alpha Processer? hongchan FLUENT 1 December 24, 2001 18:32


All times are GMT -4. The time now is 23:57.