Fluids

Fluids

Having a problem transferring data between macros in parallel mode

    • m.shafiee1374
      Subscriber

      Hello,

      I'm using an "execute on loading" macro to read data from a text file, store them in an array on the host process and then send them to nodes to be used inside an "adjust" macro for computation. Here is a simplified version of the code that I've written:

      #include "udf.h"
      real a[10][10] ;
      DEFINE_EXECUTE_ON_LOADING(import,libname)
      {
      #if RP_HOST
      /*A code that reads data from data.txt , then stores it in the array "a" */
      #endif
      host_to_node_real(a, 10*10) ;
      Message("\n Node : %d, a[1][1] = %f \n", myid, a[1][1]) ; /*This works and prints the value from all the processes*/
      }
      DEFINE_ADJUST(calc, domain)
      {
       Message("\n Node : %d, a[1][1] = %f \n", myid, a[1][1]) ; /*This only prints the value from the host,but not the compute nodes*/
      #if !RP_HOST
      /*Uses cell velocity values and "a" to do something, which wont work properly*/
      #endif
      }

      So as pointed out by the comments above, its seems like nodes can not remember the values passed on to them from a previous macro???? Or am I missing something? How to fix it?

      Best regards,

      Mohammad

       

    • Surya Deb
      Ansys Employee

      Hello, 

      Can you check by using the following macro? Since a is defined as a global array, it should not lose the data.

      #if RP_NODE
      Message("\n Node : %d, a[1][1] = %f \n", myid, a[1][1]) ;
      #endif

      Regards,

      SD

       

    • m.shafiee1374
      Subscriber

      Hi,

      I did what you asked but again, it did not print anything from the nodes:

      first picture is the result of "execute on loading" macro and second one is from the first iteration of the solution (result of define adjust macro).

    • Surya Deb
      Ansys Employee

      Hello, 

      It is difficult to understand the issue without further testing. Did you test it with a single dimensional array as well?

      Also, check the link below for more specific lower level message passing macros in Fluent. You can test by passing the data to say compute node 0 and printing it.

      https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v222/en/flu_udf/flu_udf_sec_using_udfs_parallel.html%23flu_udf_sec_communicate_processes

      Regards,

      SD

    • m.shafiee1374
      Subscriber

      Hi,

      I tried sending a one dimensional array but the results were the same.

      And for your second suggestion, I altered my code like this:

       

      include “udf.h”
      real a[10][10] ;
      DEFINE_EXECUTE_ON_LOADING(import,libname)
      {
      int nodeid ;
      #if RP_HOST
      /*A code that reads data from data.txt , then stores it in the array “a” */
      #endif
      if(I_AM_NODE_HOST_P)
      {
        compute_node_loop(nodeid) ;
        {
            PRF_CSEND_REAL(nodeid, a,  10*10, myid) ;
        }
      }
      if(!I_AM_NODE_HOST_P)
      {
        PRF_CRECV_REAL(NODE_HOST, a,  10*10, NODE_HOST) ;
      }
      Message(“\nI am node %d : a[1][1] = %f\n”, myid, a[1][1]) ; /*Execution is stuck here*/
      Message(“\n “);
      }
      DEFINE_ADJUST(calc, domain)
      {
       Message(“\n Node : %d, a[1][1] = %f \n”, myid, a[1][1]) ;
      #if !RP_HOST
      /*Uses cell velocity values and “a” to do something, which wont work properly*/
      #endif
      }

       


      But now even the execute on loading macro is not executed completely and gives the following error:

       

      this only prints the value from the host process.

      p.s. In my code, line 124 is where "PRF_CSEND_REAL" is.

       

Viewing 4 reply threads
  • You must be logged in to reply to this topic.