Fluids

Fluids

Fluent UDF: How to print messages immediately rather than all at once at the end

TAGGED: 

    • K
      Subscriber

      I have a UDF define_on_demand macro that takes a while to run (over a minute). Throughout the code, I have placed Message() commands that provide updates on where the calculation is up to. However, it seems that the messages are not printed as they come, but rather all at once after the calculation has finished.

      Is there a way to print the messages as they come? Not sure if it's relevant, but the code is run in serial so there is no need for message passing between compute nodes.

    • SRP
      Subscriber

      Hi,

      Can you try DEFINE_EXECUTE_AT_END macro to print message?

      If possible can you share your UDF code, it will aid in an improved understanding of the problem?

      Thank you.

    • K
      Subscriber

      There are no iterations being performed. The UDF is just executed to solve for something based on the mesh (e.g. suppose it is calculating the average x-component of all the cell centroids or something). I’m unable to share it, but I’ve provided an example code below:

      DEFINE_ON_DEMAND(compute_variable) {
      #if !RP_HOST

      Domain *domain;
      Thread *t;
      cell_t c;
      domain = Get_Domain(ROOT_DOMAIN_ID);
      thread_loop_c(t,domain) {
      begin_c_loop(c,t) {
      /* Do something that might take 10s. */
      Message("Analyzed cell %d\n",c);
      }
      end_c_loop(c,tc)
      }

      #endif
      }

      The code takes a few minutes to run, so the messages are there to provide an update for the user. However, it does not spit out the messages as it is running, but rather just dumps all the messages in one go at the end.

       

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