CFD Online Logo CFD Online URL
Home > Forums > FLUENT

UDF error from Windows to Linux

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   January 8, 2008, 15:10
Default UDF error from Windows to Linux
Posts: n/a
I've written an interpreted UDF on Windows and it works well. Then I need to lunch my computation on a Linux machine, but there, it doesn't work anymore. The compilation is OK but when the implementation starts (when loading my .cas and .dat file), I get a strange error message: "fluent 6.3.26 received a fatal signal (BUS ERROR)." I also have a strange message in the console: "Stack backtrace generated for process id 21289 on signal 1: Please include this information with any bug report you file on this issue!"

Please Help me!!! Here my UDF:

#include "udf.h" /************************************************** **************************/ /****************define the constants:***************************************/ /************************************************** **************************/ FILE *fp;

#define V_d 0.015 /*volume of deposit*/ #define R 287.0 /*id. gas cst. for air*/ #define gam 1.4 /*ratio of spec. heat*/ #define cp R*gam/(gam-1) /*spec. heat*/ #define p_atm 1.01325e5 /*atm. pressure*/

/* variables used to compute new boundary condition (GLOBAL!!)*/

real m_d2; /*mass inside deposit(after)*/

real p_d2; /*pressure inside deposit(after)*/

real T_d2; /*temperature inside deposit(after)*/

/* variable for applying macro only at first iteration (GLOBAL!!)*/ int last_ts = -1; int counter = 0;

DEFINE_PROFILE(pressure_realiment,t,i) { /************************************************** **************************/ /*****************define the variables***************************************/ /************************************************** **************************/

/* fluent variable */

face_t f; /*face variablenly face, thread already provided as argument*/

/* variables used to initialize the mass-area averaged function loop */

real A_3D = 0.0; /* total area */

real ma_sum = 0.0; /*mass-area sum*/

real p_sum = 0.0; /*pressure sum*/

real T_sum = 0.0; /*temperature sum*/

real mf_sum = 0.0; /*mass flow sum*/

real A[ND_ND]; /*array of all face area*/

real mf_i; /*local mass flow through each face*/

int warning = 0; /*cell number with zero-mass flow*/

/* variables used to compute new boundary condition*/

real m_d1; /*mass inside deposit(first)*/

real p_3D; /*pressure out of 3D*/

real T_3D; /*temperature out of 3D*/

real mf_3D; /*mass flow out of 3D*/

real mf_v; /*mass flow though valve*/

real p_d1; /*pressure inside deposit(first)*/

real T_d1; /*temperature inside deposit*/

real A_ef; /*effective area of valve*/

real exp_arg; /*argument of exp-function*/

/*index of timesteps*/

int n = RP_Get_Integer("time-step");

real dt = RP_Get_Real("physical-time-step");

if (n==17200) /*begins at timestep 17200*/ { n=0; } else { n=n-17200; }

if (n*dt < 0.005) { A_ef = 1.6184e-4; } else { A_ef = 1.6184e-4 - (n*dt-0.005)*1.8496e-4; }

printf("\nlast_ts=%i\n",last_ts); if (n!=last_ts) { counter =counter + 1; printf("\napplying macro for the %ith time \n",counter); last_ts = n;

printf("\n##### OUTPUT OF 3D SIMULATION: #####\n");

printf("current timestep n=%i\n",n);

printf("timestep size dt=%f\n",dt);

/************************************************** **************************/ /***********compute the average value (i.e. the sum)*************************/ /************************************************** **************************/



/*obtain the area (=vector) of each face*/


/*substitute local mass flow variable*/

mf_i = F_FLUX(f,t);

/*warning if zero mass flow in cellossible division by zero!*/

if (mf_i == 0.)


warning = warning+1;

printf("\n::::: WARNING: THERE IS A ZERO MASS FLOW IN CELL %i :::::\n",warning);


p_sum = p_sum + ((F_P(f,t)+p_atm) * NV_MAG(A) * mf_i);

T_sum = T_sum + (F_T(f,t) * NV_MAG(A) * mf_i);

ma_sum = ma_sum + NV_MAG(A)*mf_i;

A_3D = A_3D + NV_MAG(A); /*tot area of 3D outlet boundary*/

mf_sum = mf_sum + mf_i; /*tot mass flow*/



/* warning to avoid division by zero */

if (ma_sum==0)


printf("\n::::: WARNING: THERE IS A ZERO TOTAL MASS FLOW :::::\n");


/*assign them to the averaged values: */

p_3D=p_sum/ma_sum; /*mass-area averaged pressure out of 3D*/

T_3D=T_sum/ma_sum; /*mass-area averaged temperature out of 3D*/

mf_3D= mf_sum; /*mass flow out of 3D*/

/* write result in console */





/************************************************** **************************/ /*****************initialise the pressure in deposit ************************/ /************************************************** **************************/

if (n==0 || n==1) /*only at the 2 first timesteps: because BC doesn't work at the first one (why???)*/


p_d1 = p_3D; /*pressure of deposit = 3D*/

T_d1 = T_3D; /*temp. of deposit = 3D*/







p_d1 = p_d2;

T_d1 = T_d2;


/************************************************** **************************/ /******************compute the new values************************************/ /************************************************** **************************/

printf("\n##### RESULTS OF THE PREVIOUS SIMULATION: #####\n");

mf_v = A_ef*p_d1/sqrt(R*T_d1)*sqrt(2*gam/(gam-1))*sqrt(pow(p_atm/p_d1,2/gam)-pow(p_atm/p_d1,(gam+1)/gam));

m_d1 = p_d1*V_d/R/T_d1; /*mass inside deposit*/

m_d2 = m_d1+(mf_3D-mf_v)*dt;

/*argument of exp-function*/ exp_arg = mf_3D*dt/p_d1/V_d*(0.5*SQR(mf_3D*R*T_3D/p_3D/A_3D) + cp*(T_3D-T_d1));

T_d2 = T_d1*pow(m_d2/m_d1*exp(exp_arg),gam-1);

p_d2 = m_d2*R*T_d2/V_d;








printf("p_d2=%f (=REALIMENT)\n\n",p_d2);

/*write the results in a txt. file*/

/*write column titles*/

if (n==0)


fp = fopen("deposit_output.txt","a");

fprintf(fp,"tstep\tTd_1\tp_d1\tm_d1\tmf_v\tm_d2\tT _d2\tp_d2\tT_3D\tp_3D\tmf_3D\tA_ef\n");



fp = fopen("deposit_output.txt","a");

fprintf(fp,"%d\t%12.6f\t%12.6f\t%12.6f\t%12.6f\t%1 2.6f\t%12.6f\t%12.6f\t%12.6f\t%12.6f\t%12.6f\t%12. 6f\n",

n,T_d1,p_d1,m_d1,mf_v,m_d2,T_d2,p_d2,T_3D,p_3D,mf_ 3D,A_ef);


/************************************************** **************************/ /***********define the new pressure value over the whole face****************/ /************************************************** **************************/

begin_f_loop(f,t) /*loop over the whole boundary */


F_PROFILE(f,t,i) = p_d2-p_atm; /*output for re-alimentation */

/*printf("p_outlet= %f\n",F_P(f,t));*/


end_f_loop(f,t) }

else {printf("\nnot applying macro!!!\n");}


  Reply With Quote

Old   January 9, 2008, 02:46
Default Re: UDF error from Windows to Linux
Posts: n/a
the error doesn't come form your udf, but from the program you used to edit your udf. There are certainly hidden caracter in your windows version. Re-edit it with another windows program, like ultraedit, or anything else, which enable you to save the source, readable from unix.
  Reply With Quote

Old   January 9, 2008, 07:13
Default Re: UDF error from Windows to Linux
Posts: n/a
No! I have already checked this issue and converted my UDF using the "dos2ux" command. The proof is that when I use :"Define->User Define Function->Interpreted" it is compiled without any problem. The error messages come when I implement the UDF as Boundary Condition (using "Define->Boundary Condition-> Pressure outlet-> udf pressure_realiment"). But thanks for the info anyway!
  Reply With Quote

Old   January 10, 2008, 05:02
Default Re: UDF error from Windows to Linux
Posts: n/a
I found the problem by myself: it only comes from this line:

fprintf(fp,"tstep\tTd_1\tp_d1\tm_d1\tmf_v\tm_d2\tT _d2\tp_d2\tT_3D\tp_3D\tmf_3D\tA_ef\n");

The problem is that my string is too long!!! It seems to be limited at 28 characters ONLY!!! But the fact is that it prints them all in my txt.file but produces this Faltal Bus Error although!!! So I resloved the problem but I don't really understand what happens and I just would like to understand, just for my "programming general culture"...
  Reply With Quote


Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parallel run of OpenFOAM in linux and windows side by side m2montazari OpenFOAM Running, Solving & CFD 5 June 24, 2011 03:26
UDF works in Windows but not on Linux? nha1g08 FLUENT 0 April 9, 2011 13:15
Dual Boot Windows and Linux and Go Open Source andyj Main CFD Forum 2 October 21, 2010 16:49
STAR on Windows vs Linux HM Siemens 5 September 19, 2006 15:53
udf cannot run in windows but can in linux ra shmi FLUENT 2 February 14, 2006 13:12

All times are GMT -4. The time now is 10:03.