Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

help parallelizing this udf

    • csolanov
      Subscriber

      Hello, 

      I'm running a udf to calculate heat flux values along 4 boundary faces in a 2d solid domain. this is the udf

      #include "udf.h"
      #include "sg.h"
       
      DEFINE_EXECUTE_AT_END(Direct)
      {
          int i, ID, zone[4] = { 4, 5, 6, 7};
          double ds, A_by_es, flux, DTX, DTY, Area;
          double H_flux[3], A[ND_ND], es[ND_ND], dr0[ND_ND];
          face_t f;
          cell_t c0;
          Thread* t0, * t;
          Domain* d = Get_Domain(1);
          FILE* fp;
       
          fp = fopen("Data.txt", "a");  // Use append mode
          if (fp == NULL) {
              Message("Error opening file!\n");
              return;
          }
       
          for (i = 0; i < 4; i++) {  // Loop over all zones
              flux = 0.0;
              DTX = 0.0;
              DTY = 0.0;
              Area = 0.0;
              ID = zone[i];
              t = Lookup_Thread(d, ID);
       
              begin_f_loop(f, t) 
              {
                  BOUNDARY_FACE_GEOMETRY(f, t, A, ds, es, A_by_es, dr0);
                  Area += NV_MAG(A);
                  c0 = F_C0(f, t);
                  t0 = THREAD_T0(t);
       
                  DTX += C_T_RG(c0, t0)[0] * es[0] * NV_MAG(A);
                  DTY += C_T_RG(c0, t0)[1] * es[1] * NV_MAG(A);
       
                  flux += (C_T_RG(c0, t0)[0] * es[0] + C_T_RG(c0, t0)[1] * es[1]) * NV_MAG(A);
              }
              end_f_loop(f, t)
       
              DTX /= Area;
              DTY /= Area;
              flux /= Area;
       
              H_flux[i] = (32 * flux);
       
              fprintf(fp, "Wall %d:\t DTX=%f\t DTY=%f\t heat flux=%f\n", ID, DTX, DTY, H_flux[i]);
              Message("Wall %d:\t DTX=%f\t DTY=%f\t heat flux=%f\n", ID, DTX, DTY, H_flux[i]);
          }
       
          fclose(fp);
      }
       
      it builds and compiled correctly, after running the calculation I get this error
      =   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
      =   RANK 0 PID 41404 RUNNING AT "xxxx"
      =   EXIT STATUS: -1 (ffffffff)
       
      I think is because I'm running fluent in parallel and this code is not parallelized. I have read the udf manual but is not clear to me how to parallelized the code. Should I use PRINCIPAL_FACE_P macros of the condition #if RP_NODE, RP_HOST? 
       
      Any advice is welcome. Thank you.
    • Rob
      Forum Moderator

      All I can do is refer you to the UDF manual. The error isn't necessarily due to the parallel setup, as that generally just returns an incorrect value for the sums as Fluent sees the partition boundary cells two or more times. Try on one node and see what happens. 

Viewing 1 reply thread
  • You must be logged in to reply to this topic.