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

problem using property udfs in parallel mode

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 23, 2009, 17:18
Default problem using property udfs in parallel mode
  #1
New Member
 
Ellen
Join Date: Mar 2009
Posts: 11
Rep Power: 17
EllenW is on a distinguished road
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
EllenW 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
RSH problem for parallel running in CFX Nicola CFX 5 June 18, 2012 18:31
problem with parallel system tahere FLUENT 2 December 27, 2008 18:44
URGENT UDF's erosion_macro problem alex FLUENT 7 October 18, 2005 18:18
Problem using parallel Fluent Gustavo FLUENT 0 June 27, 2004 23:12
PROBLEM IN PARALLEL PROGRAMMING WITH MPI Niavarani Main CFD Forum 1 April 20, 2004 06:51


All times are GMT -4. The time now is 12:01.