problem printf fluent

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

 June 4, 2010, 04:50 problem printf fluent #1 New Member   marie Join Date: May 2010 Posts: 21 Rep Power: 8 Hi, I need to create a UDF function. I've written a program in C but the result is not correct. So I've decided to check each step. And I've realised that this simple program : #include"udf.h" #include"mem.h" #include"stdio.h" DEFINE_PROPERTY(cell_visco, cell, thread) { int I[3][3]; int i,j; real mu_lam; real vitesse = C_U(cell, thread); I[0][0] = 1; I[0][1] = 2; I[0][2] = 2; I[1][0] = 2; I[1][1] = 2; I[1][2] = 2; I[2][0] = 2; I[2][1] = 2; I[2][2] = 1; for(i=0; i<3; i++) { for (j=0; j<3; j++) printf("I[%d][%d] = %d \n", i , j, I[i][j]); } if (vitesse>0.000001) mu_lam = 2.; else mu_lam = 40.; } return an incorrect matrix I : I[0][0] = 1 I[0][1] = 2 I[0][2] = 2 I[1][0] = 2 I[1][1] = 1 I[1][2] = 2 I[2][0] = 0 I[2][1] = 2 I[2][2] = 1 If I change the values of the matrix I, the result printed in Fluent is incorrect for I[1][1] and I[2][0] but correct for the other terms. If anyone could help me... thank you so much!

 June 4, 2010, 10:46 #2 Senior Member   Join Date: Nov 2009 Posts: 411 Rep Power: 12 Your code is absolutely correct, here is a truncated version that will compile independently: #include"stdio.h" int main() { int I[3][3]; int i,j; I[0][0] = 1; I[0][1] = 2; I[0][2] = 2; I[1][0] = 2; I[1][1] = 2; I[1][2] = 2; I[2][0] = 2; I[2][1] = 2; I[2][2] = 1; for(i=0; i<3; i++) { for (j=0; j<3; j++) printf("I[%d][%d] = %d \n", i , j, I[i][j]); } return 0; } and the results: =============== C:\Users\Dol\Desktop\tste>a.exe I[0][0] = 1 I[0][1] = 2 I[0][2] = 2 I[1][0] = 2 I[1][1] = 2 I[1][2] = 2 I[2][0] = 2 I[2][1] = 2 I[2][2] = 1 C:\Users\Do\Desktop\tste> =============== Probably you have a problem in some other place. A suggestion will be to use Message function instead of printf, Message is a Fluent's own replacement for printf. Hope this will help, Do

 June 7, 2010, 05:19 #3 New Member   marie Join Date: May 2010 Posts: 21 Rep Power: 8 Hi, Thank you for your answer. I tried with the function Message but I have this error :CX_Message : no function prototype And in the user guide, I found "It is recommended that you use Message instead of printf in compiled UDFs (UNIX only)" But I do not use UNIX... Moreover if I write int main() in my program, it doesn't work anymore...

 Tags fluent, pritnf

 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 Manfred FLUENT 10 March 23, 2013 07:47 bobo FLUENT 2 July 3, 2009 06:28 brothershuai Main CFD Forum 0 July 1, 2009 15:41 Mir5 FLUENT 3 April 29, 2009 10:32 Z FLUENT 1 April 8, 2005 04:22

All times are GMT -4. The time now is 15:02.