|
[Sponsors] |
June 4, 2010, 05:50 |
problem printf fluent
|
#1 |
New Member
marie
Join Date: May 2010
Posts: 21
Rep Power: 16 |
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, 11:46 |
|
#2 |
Senior Member
Join Date: Nov 2009
Posts: 411
Rep Power: 20 |
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, 06:19 |
|
#3 |
New Member
marie
Join Date: May 2010
Posts: 21
Rep Power: 16 |
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 |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem running Fluent on amd64 | Manfred | FLUENT | 10 | March 23, 2013 07:47 |
Fluent boundary conditions problem | bobo | FLUENT | 2 | July 3, 2009 07:28 |
Fluent parallel license problem | brothershuai | Main CFD Forum | 0 | July 1, 2009 16:41 |
Problem in running fluent 6.3 (64 bit) on ubuntu 8.1 (64 bit) | Mir5 | FLUENT | 3 | April 29, 2009 11:32 |
Fluent problem | Z | FLUENT | 1 | April 8, 2005 05:22 |