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

Array problems

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 10, 2009, 12:43
Default Array problems
  #1
Malachy
Guest
 
Posts: n/a
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

DEFINE_PROFILE(inlet_velocity,thread,index)
{
FILE *fp;
int i, j;
float radexp[25], a0[13], a[128][13], b[128][13];
float x[ND_ND];
face_t f;
float xcoord, ycoord, zcoord, radcfd;

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

for (i=1; i<N; i++)
{
fscanf(fp, "%f", &radexp[i]);
radexp[i] = radexp[i] * 0.001;
}

for (i=1; i<N; i++)
{
printf("%12.8f ", radexp[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<M; 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)
{
//NB. this is just to return a value, not the bc.
F_CENTROID(x,f,thread);
F_PROFILE(f,thread,index) = 0.02;
}
end_f_loop(f,thread)
}
  Reply With Quote

Old   February 10, 2009, 13:43
Default Re: Array problems
  #2
Malachy
Guest
 
Posts: n/a
Please note I'm having trouble putting in the less than symbol. All i loops are evaluated between 1 and N-1, and all j loops between 1 and M-1.
  Reply With Quote

Old   March 5, 2012, 16:11
Default
  #3
Member
 
Yolk
Join Date: Nov 2011
Posts: 38
Rep Power: 15
Yannian is on a distinguished road
have you succed using array for the inlet boundary?
Yannian
Yannian is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
array in UDF Kamal FLUENT 1 November 7, 2013 02:15
can we initialize an array in UDF? blueberry Fluent UDF and Scheme Programming 2 April 14, 2009 13:00
UDF array problem Malachy FLUENT 0 February 10, 2009 11:41
Array of fields r2d2 OpenFOAM Running, Solving & CFD 11 January 30, 2008 13:40
Why I can not allocate five 256*256 array in VC++ Aspens Main CFD Forum 4 March 1, 2000 05:06


All times are GMT -4. The time now is 04:55.