Fluids

Fluids

Can’t use UDF report value in expressions

Tagged: , , ,

    • Francisco Acosta
      Subscriber

      Hi,

      I have a report defined with DEFINE_REPORT_DEFINITION_FN in a UDF. I can plot this report within Fluent, but when I try to use it elsewhere (e.g. within an expression), its value is always zero.

      I tried to solve this issue by defining another DEFINE_REPORT_DEFINITION_FN that reads the first report using Get_Report_Definition_Values. I can then use this second report everywhere, without getting zero. However, I still have an issue in the first iteration or time step: this second report is zero. For example, if for the first 3 iterations/time steps the 1st report values are [1,2,3], the second report values are [0,2,3].

      Could someone clarify this behaviour? How can I directly use the value of the report created by the first udf?

       

      The two UDFs are as follows, and im running a parallel fluent sim:

      DEFINE_REPORT_DEFINITION_FN(report1) 
      {
      #if RP_HOST 
      real value = 0;
      // do some stuff and set the value of value
      // Everything is done in host beacuse it's just a file reading operation
      return value;
      #endif
      // Note that everythin is done by host and value is not available for the nodes
      // I tried defininf value for all nodes and hosts and after setting its value in host passing it to nodes
      // with host_to_node_real_1 but fluent crushes when i try to do this
      }
       
      DEFINE_REPORT_DEFINITION_FN(report2) // 
      {
      real val = 0;
      // Get the value of the report named 'report1', of size 1 (scalar)
      real *values;
      values = (real *)malloc(sizeof(real) * 1);
      int rv = Get_Report_Definition_Values("report1", 1, NULL, values, NULL, NULL);
      val = values[0];
      free(values);
      // Make the value available to host
      node_to_host_real_1(val);
      return val;
      }
       
       
      Thanks in advance!
    • Rob
      Ansys Employee

      Read the documentation section  https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v231/en/flu_udf/flu_udf_GeneralSolverDEFINE.html%23flu_udf_sec_report_defintion    The DEFINE_REPORT_DEFINITION_FN returns a number. 

      The other behaviour may be down to when data is created and updated when you start a calculation. Not everything is known at the start of iteration/timestep zero so it's possible Fluent doesn't calculate "stuff" to avoid returning nonsense values. Without asking I can't be sure, and if I ask I won't be able to report on here as it's probably not documented. 

    • Francisco Acosta
      Subscriber

      Thank you for your answer.

       

      I know that DEFINE_REPORT_DEFINITION_FN returns a number ; thats the behaviour I expect.  Other than the issue at the first time step, what I don't get is why I can't use the value of the report that uses that definition anywhere other than its own plot. For example, when I try to use the report value in an expression, I always get zero. 

    • Rob
      Ansys Employee

      I know expressions are still evolving so it's possible it's not available at present. I generally use either expressions or UDFs for a task. 

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