CFD Online Logo CFD Online URL
Home > Forums > FLUENT

compatibility problem of UDF on LINUX

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

LinkBack Thread Tools Display Modes
Old   December 18, 2007, 05:41
Default compatibility problem of UDF on LINUX
Posts: n/a
I wrote a UDF for defining a transient pressure boundary condition and it works perfectly on Windows Platform. The issue is that I must start the computation on a computer with more CPU that is on a Linux Platform and it doesn't work anymore at all!!! Here my UDF: (For testing it, I use a simple right tube: I can send you the .cas and .dat file if you want. My e-mail:

#include "udf.h"

/************************************************** *******/ /****************define the constants:***************************************/ /*******************************************/

FILE *fp;

#define A_ef 5.0e-3 /*effective area of valve*/ #define V_d 5.0 /*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 exp_arg; /*argument of exp-function*/

/*index of timesteps*/ int n = RP_Get_Integer("time-step"); real dt = RP_Get_Real("physical-time-step");

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)*************************/ /*********************************************/

begin_f_loop(f,t) { /*obtain the area (=vector) of each face*/ F_AREA(A,f,t);

/*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) * 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*/

} end_f_loop(f,t)

/* 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*/

/* test: write result in console */ printf("A_3D=%f\n",A_3D); printf("mf_3D=%f\n",mf_3D); printf("T_3D=%f\n",T_3D); printf("p_3D=%f\n",p_3D);

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

if (n==0 || n==1) /*only at the 2 first timesteps:because boundary condition doesn't work at onlt the first one (???)*/ { p_d1 = p_3D; /*pressure of deposit = 3D*/ T_d1 = T_3D; /*temp. of deposit = 3D*/ printf("\n::::: TEMPERATURE AND PRESSURE INITIALIZED AT FIRST TIMESTEP :::::\n"); printf("p_d1=%f\n",p_d1); printf("T_d1=%f\n",T_d1); } else { p_d1 = p_d2; /*takes the output value of the last timestep*/ 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_d1=%f\n",p_d1); printf("T_d1=%f\n",T_d1); printf("m_d1=%f\n",m_d1); printf("\n##### RESULTS OF THE COMPUTATION (REALIMENT FOR THE NEXT TIMESTEP): #####\n"); printf("mf_v=%f\n",mf_v); printf("m_d2=%f\n",m_d2); printf("T_d2=%f\n",T_d2); 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\n"); fclose(fp); }

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\n", n,T_d1,p_d1,m_d1,mf_v,m_d2,T_d2,p_d2,T_3D,p_3D,mf_ 3D); fclose(fp);

/************************************************** */ /***********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; /*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   December 18, 2007, 06:16
Default Re: compatibility problem of UDF on LINUX
Posts: n/a
hi, save your UDF with a different name and deletes all the libudf in your working directory before compiling. It is a problem of text editor
  Reply With Quote

Old   December 18, 2007, 06:29
Default Re: compatibility problem of UDF on LINUX
Posts: n/a
You should also check the end-of-line delimiter (try notepad++ for example). In this text editor, you will change EOF to UNIX. Also, when you compile on unix, you use generally use the gcc compiler instead of visual c++ which might be less tolerant to coding abuses (even if vs seems more restrictive in my own limited experience).
  Reply With Quote

Old   December 18, 2007, 07:29
Default Re: compatibility problem of UDF on LINUX
Posts: n/a
Thanks very much. Now I can compile it without problem. But compiling is a point, activating it in Fluent is another issue. On windows it works perfectly and here when I define my UDF in by (pressure outlet) Boundary Conditions I get the error message: fatal signal (Bus Error) Error Object: #f

  Reply With Quote

Old   December 19, 2007, 05:58
Default Re: compatibility problem of UDF on LINUX
Posts: n/a
Next time just do binairy transfer between your systems. Think this wil help a lot for the futher. Are you compiling on a Linux system or on an Unix? This can give problems if you try to run it in parallel.

  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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 32 May 8, 2015 06:05
UDF using problem, error happens-heip!! Michael FLUENT 1 December 9, 2008 08:51
udf compiling problem akr FLUENT 3 August 22, 2007 07:14
UDF PROBLEM anant FLUENT 2 January 17, 2007 01:15
I have problem of UDF with turbulent premx source. Z FLUENT 0 February 16, 2005 04:34

All times are GMT -4. The time now is 01:55.