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/)
-   -   PARALLELIZING UDF - node to host error (https://www.cfd-online.com/Forums/fluent-udf/95705-parallelizing-udf-node-host-error.html)

Bionico December 29, 2011 10:56

PARALLELIZING UDF - node to host error
 
Hi everybody,
I'm trying to parallelize my udf: there are a DEFINE_ADJUST and a DEFINE_PROFILE (that depends on the first)
I put the basic compiler directives like #if !RP_HOST but I had some problem!

this is my UDF:

Code:


#include "udf.h"
real tm=0.00;
DEFINE_ADJUST(tsensor,d)
{
 
 real trif=0.0;
 real nt;
 
#if !RP_HOST
 real trif_coordinate[ND_ND];
 real x,y,z;
 
 Thread *t=Lookup_Thread(d,120573);
 cell_t c;
 printf("Node è %d", myid);
 nt=0.0;
 
 begin_c_loop(c,t)
  {
  C_CENTROID(trif_coordinate,c,t);
 
  x=trif_coordinate[0];
  y=trif_coordinate[1];
  z=trif_coordinate[2];
 
  if (sqrt(ND_SUM(pow(x+1.900,2.),pow(y+1.000,2.),pow(z-1.400,2.))) < 0.04)
    {
    trif=trif + C_T(c,t);
    nt=nt+1.0; 
    printf("trif somma = %f\n", trif); 
    printf("nr celle = %f\n", nt); 
    }
  }
 end_c_loop(c,t)
 
 #if RP_NODE
 trif=PRF_GRSUM1(trif);
 nt=PRF_GRSUM1(nt);
 printf("trif = %f\n", trif);
 printf("nt = %f\n", nt);
 #endif
 
#endif
 
node_to_host_real_2(trif,nt);
 
#if !RP_NODE
 if (nt!=0)
  {
    tm=trif/nt;
  }
 printf("tm vale %f\n", tm);
#endif
 
}
 
 
DEFINE_PROFILE(twall, thread, position)
{
 real tlim;
 face_t f;
 tlim=291.65;
  if (tm>tlim)
 
  begin_f_loop(f,thread)
 {
    F_PROFILE(f, thread, position) = 291.15-(tm-291.15); 
 }
  end_f_loop(f, thread)
 
 else
 
 begin_f_loop(f,thread)
 {
    F_PROFILE(f, thread, position) = 291.15;   
 }
  end_f_loop(f, thread)
}

It gives me this error

ERROR: /Fluent/..../.... line 175: function "mpnode_to_host_double_2" not found (pc=19)
ERROR: /Fluent/..../.... line 175: function "mpnode_to_host_double_2" not found (pc=399)
ERROR: /Fluent/..../.... line 175: function "mpnode_to_host_double_2" not found (pc=399)
...
etc...

why the macro node_to_host does not work?

Sixkillers December 29, 2011 13:54

Working for me (Fluent header files version 12.1 & GCC 4.6.2). Are you compiling or interpreting it?

Bionico December 29, 2011 14:23

Interpreting! Should I compile my udf?

Sixkillers December 29, 2011 17:36

Definitely! Interpreted UDF are useful only for very simple problems. The only their advantage is you don't need to bother with configuration of a compiler. On the other hand compiled UDF can use whole potential of C programming language and also their performance is better. Here is lovely tutorial how to setup a compiler on a Windows platform.

Bionico December 29, 2011 18:25

Thank you! I'll try to compile my UDF! :)
Can you give me some advice for Linux platform?

Sixkillers December 30, 2011 17:57

For compiling on Linux systems just follow Fluent's UDF manual. It is really straightforward. Basically it consists of 2 files, which you need to customize. Personally I prefer compiling on Linux machines, because it is working out of the box and with little extra effort you can link an UDF against external libraries (e.g. GSL) and use it in your code.


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