CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF array problem (https://www.cfd-online.com/Forums/fluent/50527-udf-array-problem.html)

 Malachy February 10, 2009 11:41

UDF array problem

Colleagues,

I would be interesed in any suggestions on the following. I am using Fluent 12 beta release. Below is part of a udf to define a periodic boundary condition at the inlet. I've had this bc working in earlier versions of fluent. My problem concerns the initiaisation of a number arrays at the beginning of the routine.

The routine starts by intialising the arrays radexp, a0, a and b. The routine compiles, builds and loads ok using ms visual c++ 2008.

On intialising the flow field using the compute from 'inlet' the routine appears to read (from file) and write (to screen) the arrays radexp, a0, a and b correctly. However when I try to write a after reading b the elements of a become jumbled. This coding worked fine on versions of fluent prior to 6.4. Any help, suggestions greatly appreciated. I have tried reading and writing the arrays using pointers but I get the same result.

#include "udf.h"

#define M 128 #define N 13

FILE *fp;

int i, j;

real x[ND_ND];

face_t f;

fp = fopen("PBFFT12.txt","r");

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

{

}

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

{

}

printf("\n");

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

{

fscanf(fp, "%f", &a0[i]);

}

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

{

printf("%12.8f ", a0[i]);

}

printf("\n");

for (j=1; j<M; j++)

{

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

{

fscanf(fp, "%f", &a[j][i]);

}

}

for (j=1; j<3; j++)

{

printf("%4d ", j);

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

{

printf("%12.8f ", a[j][i]);

}

printf("\n");

}

for (j=1; j<M; j++)

{

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

{

fscanf(fp, "%f", &b[j][i]);

}

}

for (j=1; j<M; j++)

{

printf("%4d ", j);

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

{

printf("%12.8f ", b[j][i]);

}

printf("\n");

}

for (j=1; j<M; j++)

{

printf("%4d ", j);

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

{

printf("%12.8f ", a[j][i]);

}

printf("\n");

}

fclose(fp);

begin_f_loop(f,thread) /* loops over all faces in the thread passed in the DEFINE macro argument */

{

// get the co-ordinates of tri-face centre