Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

Hooking DEFINE_ON_DEMAND for HPC simulations

    • Ramesh Chandra Mishra
      Subscriber

      Hi

      I have to run simulations on HPC involving a UDF.

      Now, a part of my code uses DEFINE_ON_DEMAND macro. Since I am compiling my UDF on HPC, I have to use TUI commands to hook the UDF. I am tried the following commands but it givs error even though UDF is compiled successfully.

      /define/user-defined/execute-on-demand "ach_udf::libudf"

      or

      /define/user-defined/execute-on-demand " udf" "ach_udf::libudf"

      Am I missing something? 

       

    • Ramesh Chandra Mishra
      Subscriber

      Also, Please note that I haven't compiled the UDF in my case file because I am directly compiling it on the cluster and using tui commands in journal file to hook UDF. 

    • Rob
      Forum Moderator

      If you run through the TUI command in stages the first return from Fluent is asking for the function name - what did you call the DEFINE_ON_DEMAND macro? 

    • Ramesh Chandra Mishra
      Subscriber

      "ach_udf::libudf"

    • Ramesh Chandra Mishra
      Subscriber

      Rob

      I really need help on this because I am stuck here since 2 days.

      I am writing all the steps I am following just to give you clarity so that you can point out if I am doing something wrong.

      a) I prepare my case file and do not touch anything regarding execute on demand in my case file.

      b) I prepare journal file, script file and libudf folder for compilation on HPC. In journal file I add /define/user-defined/execute-on-demand "ach_udf::libudf" for hooking this part of udf apart from other commands.

      c) I compile UDF on HPC which is done successfully.

      d) I submit the job and when it runs it stops at the execute-on-command and gives error: 

       /define/user-defined/execute-on-demand "ach_udf::libudf"
      ===============Message from the Cortex Process================================

      Fatal error in one of the compute processes.

      ==============================================================================

    • Rob
      Forum Moderator

      If you unhook the UDF and then use the /define... command locally what happens? You can test this on a dummy case, it just need enough mesh to load. 

    • Ramesh Chandra Mishra
      Subscriber

      I am not sure I follow.

      Are you saying that after running the simulations, I should use this command and see what happens?

    • Rob
      Forum Moderator

      No, you have the UDF, and can load it into any Fluent model. Do this on your local machine - does the command work? 

    • Ramesh Chandra Mishra
      Subscriber

      yes, I have tried that .

      As soon as I execute the execute on demand after compiling udf on my local machine, it gives error:

      BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES.

      I have tried this with other udf too. The issue remains the same.

      I don't know if I am missing out on something.

       

    • Ramesh Chandra Mishra
      Subscriber

      I came to know that F_UDMI works only for boundary faces but I am using it for surfaces which I created using isoclip which are a part of the domain or you can say interior. can that be a reason? Because I am printing the value of F_UDMI for different locations under DEFINE_ON_DEMAND macro.

       

       

    • Rob
      Forum Moderator

      That would cause a failure after compilation, when you attach the UDF or trigger the Face loop. Isosurfaces aren't technically faces (facets) in the mesh sense. 

      Have a look at Expressions; depending on version and who told you to do what at Uni you may find the UDF is not needed. 

    • Ramesh Chandra Mishra
      Subscriber

      I have tried the expressions and custom field functions but concentration gradient is not available in the fluent GUI and it is one of the terms in my equation which I am trying to solve through UDF. So basically it is not possible without a UDF.

    • Rob
      Forum Moderator

      So you'll need to get the UDF and command working. 

    • Ramesh Chandra Mishra
      Subscriber

      So we are back to square one. I am unable to execute the define_on_demand macro. can you suggest me any alternative macro for that. I will give it a shot.

       

    • Rob
      Forum Moderator

      Have you got the UDF working manually, you mention an error when running so that needs fixing first. The concentration gradient is available in the cells, what do you need the surface for?

    • Ramesh Chandra Mishra
      Subscriber

      UDF is getting compiled without error. But as soon as my job starts running, it stops at the command  

      /define/user-defined/execute-on-demand "ach_udf::libudf" giving me the error:
      ===============Message from the Cortex Process================================

      Fatal error in one of the compute processes.

      ==============================================================================

      I need value of an expression on a surface and that equation includes concentration gradient: 

    • Rob
      Forum Moderator

      Which means the C coding grammar is good, but that the macro/data use from Fluent needs work. 

      So, you need concentration gradient, that's available in all cells via the macros. You want to use that value on a surface? What's wrong with calculating the value everywhere, storing the value in a UDM and then displaying that value on a surface? 

    • mishranamrata1196
      Bbp_participant

      That is exactly what I am doing using DEFINE_ON_DEMAND macro. Don't know where is it going wrong.

    • Rob
      Forum Moderator

      Take out some/all of the equations, ie simply the code. If that works slowly add macros/equations back in until it fails. That'll identify the cause. 

    • mishranamrata1196
      Bbp_participant

      Hi Rob

      I tried what you said and also identified the cause but don't know how to fix it.

      Following is my piece of code:

      DEFINE_ON_DEMAND(ach_udf)
      {
      FILE* fp;
      fp = fopen("INDICE.txt", "a");
      Thread *t,*to;
      face_t f;
      cell_t co;
      Domain *d;

      d = Get_Domain(1);                                           
      real A[ND_ND]; 

       

      t = Lookup_Thread(d,2); 

      real ACHt_mean_out=0;
      real ACHt_mean_in=0;


      begin_f_loop(f,t)
      {
      F_AREA(A,f,t);

      co = F_C0(f, t);
      to = THREAD_T0(t);

       

      real vel_roof= C_V(co,to);
      if (vel_roof>0)
      {
      ACHt_mean_out += vel_roof*NV_MAG(A);
      }
      else
      {
      ACHt_mean_in +=vel_roof*NV_MAG(A);
      }
      }
      end_f_loop(f,t)

      }

      This is getting compiled and solved properly. But as soon as I use C_UDMI for storage, it gives error. Following is the code which gives error:

      DEFINE_ON_DEMAND(ach_udf)
      {
      FILE* fp;
      fp = fopen("INDICE.txt", "a");
      Thread *t,*to;
      face_t f;
      cell_t co;
      Domain *d;

      d = Get_Domain(1);                                           
      real A[ND_ND]; 

       

      t = Lookup_Thread(d,2); 

      real ACHt_mean_out=0;
      real ACHt_mean_in=0;


      begin_f_loop(f,t)
      {
      F_AREA(A,f,t);

      co = F_C0(f, t);
      to = THREAD_T0(t);

       

      real vel_roof= C_V(co,to);
      if (vel_roof>0)
      {
      ACHt_mean_out += vel_roof*NV_MAG(A);
      }
      else
      {
      ACHt_mean_in +=vel_roof*NV_MAG(A);
      }
      }
      end_f_loop(f,t)

      C_UDMI (co,to,0)=ACHt_mean_out ;

      }

      Can you please tell me what is wrong here.

       

    • Rob
      Forum Moderator

      Try putting the C_UDMI call into the loop, but as it's a face loop check up on F_UDMI. The UDMs are cell/facet based, they're not a single domain level value. 

    • mishranamrata1196
      Bbp_participant

      Yes, that's why I didn't put it into loop. 

    • Rob
      Forum Moderator

      You just want a single value? 

    • mishranamrata1196
      Bbp_participant

      Hi Rob

      I want two things:

      a) A single value for ACHt_mean_out after all the summation.

      b) The value of  vel_roof*NV_MAG(A) on each face of the surface defined with zone id 2.

    • Rob
      Forum Moderator

      UDFs tend to do "stuff" in the code. In your case can you simply report (surface sum/integral/etc) the values of the UDMs, ie the F_UDM is the result of vel_roof*NV_MAG(A) for each facet? Or fprint (or whatever the correct command is now) the single value. 

    • mishranamrata1196
      Bbp_participant

      I can't use F_UDMI because the surface is an interior surface not a boundary face.

    • Rob
      Forum Moderator

      An interior surface is a boundary face as it exists as a mesh surface and so has an idenity. If you mean an iso-surface then you'll also be lacking NV_MAG(A). 

Viewing 26 reply threads
  • The topic ‘Hooking DEFINE_ON_DEMAND for HPC simulations’ is closed to new replies.