CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

problem printf fluent

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 4, 2010, 04:50
Default problem printf fluent
  #1
New Member
 
marie
Join Date: May 2010
Posts: 21
Rep Power: 7
marye is on a distinguished road
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!


marye is offline   Reply With Quote

Old   June 4, 2010, 10:46
Default
  #2
Senior Member
 
Join Date: Nov 2009
Posts: 411
Rep Power: 10
DoHander is on a distinguished road
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
DoHander is offline   Reply With Quote

Old   June 7, 2010, 05:19
Default
  #3
New Member
 
marie
Join Date: May 2010
Posts: 21
Rep Power: 7
marye is on a distinguished road
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...


marye is offline   Reply With Quote

Reply

Tags
fluent, pritnf

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
Problem running Fluent on amd64 Manfred FLUENT 10 March 23, 2013 07:47
Fluent boundary conditions problem bobo FLUENT 2 July 3, 2009 06:28
Fluent parallel license problem brothershuai Main CFD Forum 0 July 1, 2009 15:41
Problem in running fluent 6.3 (64 bit) on ubuntu 8.1 (64 bit) Mir5 FLUENT 3 April 29, 2009 10:32
Fluent problem Z FLUENT 1 April 8, 2005 04:22


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