Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

ERRO WHEN TRYING TO WRITE A .TXT FILE USING UDF

    • csolanov
      Bbp_participant

      I want to get the heat flux values for a p20 steel solid 2d rectangular shape. I want the values for each node in the y-axis written in a .txt file. Whenever I compiled my udf it builds but when loading I get this error.

      ERROR: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).

      The system cannot find the file specified.

      this is the code:

      ----------------------------------------------------------------------------------------------------------------------------------------------

      #include "udf.h"
      #include "stdio.h"  

      DEFINE_EXECUTE_AT_END(write_heat_transfer_to_file)
      {
          Domain *domain;
          Thread *t;
          cell_t c;
          real thermal_conductivity;
          real temperature;
          real heat_flux;

          FILE *file;  
          char filename[] = "written_heat_transfer_values.txt"; 

          domain = Get_Domain(1); 

          
          file = fopen(filename, "w");
          if (file == NULL)
          {
              Message("Error opening file %s\n", filename);
              return;
          }

          
          thread_loop_c(t, domain)
          {
             
              begin_c_loop(c, t)
              {
                 
                  thermal_conductivity = C_K_L(c, t);  
                  temperature = C_T(c, t);  

                  
                
                  heat_flux = thermal_conductivity * temperature;  

                 
                  fprintf(file, "Cell ID: %d, Thermal Conductivity: %g W/m*K, Heat Flux: %g W/m^2\n", c, thermal_conductivity, heat_flux);
              }
              end_c_loop(c, t)
          }

          
          fclose(file);

         
          Message("Heat fluxvalues written to %s\n", filename);
      }
      }

      ----------------------------------------------------------------------------------------------------------------------------------------------

    • Rob
      Forum Moderator

      The error means it's not compiled, so you need to resolve that before loading the library. What error are you seeing when compiling? 

      Are you wanting the data at a single instance, ie the end of a solution or during? I ask as surface reports may be an easier approach. 

    • csolanov
      Bbp_participant

      the code run now. There were errors inside the code that's why it was giving me error. 

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