CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Reading table file (https://www.cfd-online.com/Forums/fluent/30327-reading-table-file.html)

MON September 20, 2002 14:19

Reading table file
 
Hi Shital

First, i write a program on C++(((EssaiC.cpp))using some standard C-language attributes(fscan...).this program can read the data from table_file to an array called table[i] [j]. this program run and can read the array table[i][j] ********* ********* /********EssaiC.cpp*****/ #include<iostream.h> #include<fstream.h> #include<stdio.h> main(void)

{

int i,j;

float table[10][20];

FILE *fichier;

float temp;

fichier = fopen("Meteo.txt","r");

for (i=0;i<3 ;i++)

{ for (j=0;j<1;j++)

{

fscanf(fichier,"%f", &temp);

table[i][j] =temp;

cout << "\nla valeur de i\t" << i;

cout << "\nle valeur j\t" << j;

cout << "\n\nla valeur de table est:\t" << table[i][j];

}

}

fclose(fichier); return 0;

******* ******* Where Meteo.txt is the data file **** **** **** "Meteo.txt"( array [3,3]) 1 2 3 4 5 6 7 8 9 ***** ***** i complie the EssaiC an i can read the values of the arrayarray [3,3]: ***** ***** I write a UDF (UDf profille)(((EssaiFluent.cpp)))using the same standard C-language attributes as EssaiC.i can compile with success but i can't read the array: ***** ***** Essai Fluent #include"udf.h" DEFINE_PROFILE(PERTE_ATM,thread,position) {

face_t f;

FILE *fichier;

real x[ND_ND];

int i,j;

float table[10][20];

fichier = fopen("Meteo.txt","r");

for (i = 0 ; i<1 ;i++)

{

for (j = 0;j<2;j++)

{

fscanf(fichier,"%f \t",&table[i][j]);

printf("\\n\n %f \n",table[i][j]);

fclose(fichier);

begin_f_loop (f,thread)

{

F_PROFILE (f,thread,position)=100*table[i][j]+table[i+1][j]+;;

}

}

}

end_f_loop(f,thread) }

i compile the UDF witout error but when i will print the value of the array .(look the UDF Define profile)but the UDF (Define profile ) can't read correctly the value from data file(Meteo.txt).

What the error in my own UDF? Thanks in advance.

Ridha


All times are GMT -4. The time now is 11:23.