CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF to find Species mass fraction parallel Linux (https://www.cfd-online.com/Forums/fluent-udf/150621-udf-find-species-mass-fraction-parallel-linux.html)

Schumacher00 March 26, 2015 05:53

UDF to find Species mass fraction parallel Linux
 
Hello Friends

would you please take a look at my Code.I'm confused, where the Problem is.
I receive a warning by the end of compiling " CC defined ,but not used" .I get by running Stack backtrace.

info: Linux/Parallel CPUs/ 3ddp

Thanks in advance
--------------------------------------------------------------
#include "udf.h"
#define BC_ID 5
#define nmrad 54
#define nmtang 2324
static double CC[nmtang*nmrad]={0.};
DEFINE_EXECUTE_AT_END(my_time_averager)
{
#if !RP_HOST
int mm;
double D[nmtang*nmrad];
double r[150000], tt[150000];
double R,tetha_prim,Y,Z;
FILE *fp;
fp = fopen("support-tat-blade1-outlet-Preparation.txt","r");
for (mm=0;(mm<nmtang*nmrad);mm ++)
{
fscanf(fp, "%lf %lf",&r[mm],&tt[mm]);
}
fclose(fp);
for (mm=0;(mm<nmrad);mm++)
{
r[nmtang*nmrad+mm]=r[mm];
tt[nmtang*nmrad+mm]=tt[mm];
}
for (mm=nmrad;(mm<nmrad*(nmtang+1));mm++)
{
r[mm-nmrad] =r[mm];
tt[mm-nmrad]=tt[mm];
}
fp= fopen("support-tat-blade1-outlet-Preparation.txt","w");
for (mm=0;(mm<nmtang*nmrad); mm++)
{
fprintf(fp, "%f\t %f\n", r[mm],tt[mm]);
}
fclose(fp);
double xx[ND_ND];
int numb = N_TIME;
Domain *d = Get_Domain(1);
Thread *t = Lookup_Thread(d,BC_ID), *tc;
face_t f;
Material *m;
int iair;
tc = THREAD_T0(t);
m = THREAD_MATERIAL(tc);
iair = mixture_specie_index(m,"air-2");
begin_f_loop(f,t)
{
F_CENTROID(xx,f,t);
Y=xx[1];
Z=xx[2];
R = sqrt(Y*Y+Z*Z);
tetha_prim = asin(-Z/R)/asin(1.)*90.;
if (Y<0.)
{
tetha_prim = tetha_prim/fabs(tetha_prim)*180.-tetha_prim;
}
for (mm=0;(mm<nmtang*nmrad);mm++)
{
if((fabs(R-r[mm])<0.00009) && (fabs(tetha_prim-tt[mm])<0.00009))
{
D[mm]=F_YI(f,t,iair); /* get the value of species air-2 */
CC[mm]=CC[mm]+D[mm];
}
}
}
end_f_loop(f,t)
if(numb==3)
{
fp = fopen("C-support-tat-blade1-outlet.txt","w");
for (mm=0;(mm<nmtang*nmrad);m++)
{
CC[mm]=(1/3)*CC[mm];
fprintf(fp, "%f\n", CC[mm]);
}
fclose(fp);
}
#endif
}

`e` March 26, 2015 05:57

What error message are you getting? Should your line saving to the text file be "C:\" instead of "C-"?

Schumacher00 March 26, 2015 06:02

Hi 'e'

Thanks for your quick response.

I get a warnning by compiling ' CC defined but not used'.By Running the calculation I get Stack backtrace .

Code gets compiled and loaded without any other Problem.

C- is just included by the name of the file,it's not an address.

pakk March 26, 2015 07:56

If RP_HOST is set, the preprocessor reduces your code to:

Code:

static double CC[2324*54]={0.};
DEFINE_EXECUTE_AT_END(my_time_averager)
{
}

As you can see, in that case CC is defined, but never used.

Schumacher00 March 26, 2015 09:15

Thanks Pakk

So, I'm just not sure if I define static double CC[m*n] inside the EXECUTE macro, the calculated values for CC elements will be preserved at the end of each time step.
Moreover I have to exclude the Host CPU from Calculation task ,because I'm running fluent on parallel setting.

Right now, i just moved the defined static vaariable to below line of RP_HOST.Again Stack Backtrace... :(

What is the solution?

pakk March 26, 2015 09:19

You want to have a solution, but you should first explain what the problem is.

Until now, you have only said that you see a warning when you compile. Is that a problem for you? In that case, make it
Code:

#if !RP_HOST
static double CC[2324*54]={0.};
#endif

Or is something else than the warning the problem? You talk about "stack backtrace", but I have no idea what that is.

Schumacher00 March 26, 2015 09:47

================================================== ============================
Stack backtrace generated for node id 0 (pid = 13244) on signal 11 :
================================================== ============================
================================================== ============================
================================================== ============================
Stack backtrace generated for node id 1 (pid = 13245) on signal 11 :
Stack backtrace generated for node id 5 (pid = 13249) on signal 11 :
Stack backtrace generated for node id 7 (pid = 13251) on signal 11 :
================================================== ============================
================================================== ============================
================================================== ============================
================================================== ============================
Stack backtrace generated for node id 3 (pid = 13247) on signal 11 :
Stack backtrace generated for node id 2 (pid = 13246) on signal 11 :
Stack backtrace generated for node id 6 (pid = 13250) on signal 11 :
Stack backtrace generated for node id 4 (pid = 13248) on signal 11 :
2: /lib64/libc.so.6() [0x3db1232920]
6: /lib64/libc.so.6(fscanf+0x88) [0x3db1262e08]
2: /lib64/libc.so.6(_IO_vfscanf+0x64) [0x3db12544c4]
6: libudf/lnamd64/3ddp_node/libudf.so(my_time_averager+0x5b) [0x7fe03bfb6ceb]
4: /--/--/--/fluent/1450/ansys_inc/v145/fluent/fluent14.5.0/lnamd64/3ddp_node/fluent_mpi.14.5.0() [0x1aedbfc]
Check the file fluenterror.log for details.
2: /lib64/libc.so.6(fscanf+0x88) [0x3db1262e08]
Please include this information with any bug report you file on this issue!
4: /lib64/libc.so.6() [0x3db1232920]
2: libudf/lnamd64/3ddp_node/libudf.so(my_time_averager+0x5b) [0x7f05dc83eceb]
4: /lib64/libc.so.6(_IO_vfscanf+0x64) [0x3db12544c4]
Check the file fluenterror.log for details.
================================================== ============================
Please include this information with any bug report you file on this issue!
4: /lib64/libc.so.6(fscanf+0x88) [0x3db1262e08]
================================================== ============================
4: libudf/lnamd64/3ddp_node/libudf.so(my_time_averager+0x5b) [0x7f811d5bcceb]
Check the file fluenterror.log for details.
Please include this information with any bug report you file on this issue!
================================================== ============================
3: /--/--/--/fluent/1450/ansys_inc/v145/fluent/fluent14.5.0/lnamd64/3ddp_node/fluent_mpi.14.5.0() [0x1ae9cc4]
3: /--/--/--/fluent/1450/ansys_inc/v145/fluent/fluent14.5.0/lnamd64/3ddp_node/fluent_mpi.14.5.0() [0x1aedbfc]
3: /lib64/libc.so.6() [0x3db1232920]
3: /lib6 The fluent process could not be started.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
This error occures exatly by the execution of EXECUTE_AT_END. (end of the first time step)

Like I wrote ,I moved the lines but the same error apears.

1.I wrote out the .prof file to calculate the radial and angular coordinates of my Face Centrids.
2.Ordered them as my desired and saved as (support-tat... .txt).
3. in UDF defined Radius and angle just like the principle of my ordering in previous step to be calculated in begin/end_f_loop.
4. Now in Calculation if R(step3)==RR(Step2) && tetha(step3)==tetha(step2), do get the value of my "mass fraction of Specie " of that ceratin face.
5.Save the values of "mass fraction of specie" of all faces in CC array at the end(when times step number is for example 3).

pakk March 26, 2015 09:56

Try to isolate the problem.
For example: put
Code:

Message("Code runs till point A.");
on several places in your code (replacing A by different letters of the alphabet.)
If you see on your screen:

Quote:

Code runs till point A.
Code runs till point A.
Code runs till point B.
Code runs till point C.
(Fluent error)
Then the problem is between C and D.


All times are GMT -4. The time now is 07:37.