CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   problem using property udfs in parallel mode (http://www.cfd-online.com/Forums/fluent/65708-problem-using-property-udfs-parallel-mode.html)

EllenW June 23, 2009 17:18

problem using property udfs in parallel mode
 
Hi,

I'm having a problem when trying to use multiple property udfs in the parallel mode:

I'm modeling two gases in species transport, and used two udf's to define their properties (thermal conductivity). The udf is quite simple: to open a file and read in a list of data, then specify the data to cells according to the cell temperature (see the attached code). Two such udfs were written, one for each gas, and they work well in the serial mode.
However, when I tried to use them in the parallel mode, problem occurred. I parallelized the code as attached. If I only apply one udf to one gas, it worked fine, but if I apply both udfs to both gases, then I got this error message:
Error: > (greater-than): invalid argument [2]: wrong type [not a number]
Error object: 1. #quan

Could anyone please help me explain why this happens? Or point out where I did wrong in parallelizing the code? Thank you very much!


The original udf:


#include "udf.h"
FILE *ifp;
int i;
real k_a[100][2];
DEFINE_EXECUTE_ON_LOADING(table_ka, libudfka)
{
real T, k;
ifp = fopen("k_a.txt", "r");
for (i=0;i<100;i++)
{
fscanf(ifp, "%lf %lf", &T, &k);
k_a[i][0] = T;
k_a[i][1] = k;
}
Message("k_a table was loaded.");
fclose(ifp);
}
DEFINE_PROPERTY(cell_ka, cell, thread)
{
real temp1, k1;
temp1 = C_T(cell, thread);
if(temp1<k_a[0][0])
k1 = k_a[0][1];
for (i=1;i<100;i++)
{
if(temp1>=k_a[i-1][0] && temp1<=k_a[i][0])
k1 = (k_a[i][1]-k_a[i-1][1])*(temp1-k_a[i-1][0])/(k_a[i][0]-k_a[i-1][0])+k_a[i-1][1];
}
if(temp1>k_a[99][0])
k1 = k_a[99][1];
return k1;
}


The parallelized udf:

#include "udf.h"
int i;
real C1[100];
real C2[100];
#if !RP_NODE
FILE *ifp1;
DEFINE_EXECUTE_ON_LOADING(table_ka, libudfka)
{
int ii;
real T1, k1;
ifp1 = fopen("k_a.txt", "r");
for (ii=0;ii<99;ii++)
{
fscanf(ifp1, "%lf %lf", &T1, &k1);
C1[ii] = T1;
C2[ii] = k1;
}
host_to_node_real(C1,100);
host_to_node_real(C2,100);
Message("k_a table was loaded.");
fclose (ifp1);
}
#endif
DEFINE_PROPERTY(cell_ka, cell, thread)
{
real temp1, k1;
real k_a[100][2];
for (i=0;i<100;i++)
{
k_a[i][0] = C1[i];
k_a[i][1] = C2[i];
}
#if !RP_HOST
temp1 = C_T(cell, thread);
if(temp1<k_a[0][0])
k1 = k_a[0][1];
for (i=1; i<100; i++)
{
if (temp1>=k_a[i-1][0] && temp1<=k_a[i][0])
k1 = (k_a[i][1]-k_a[i-1][1])*(temp1-k_a[i-1][0])/(k_a[i][0]-k_a[i-1][0])+k_a[i-1][1];
}
if(temp1>k_a[99][0])
k1 = k_a[99][1];
#endif
return k1;
}




Regards,
ellen


All times are GMT -4. The time now is 03:19.