TAGGED: #fluent-#cfd-#ansys, udf
-
-
September 7, 2024 at 1:36 amcsolanovSubscriber
this code prints me the temperature values on the face boundary of my 2d geometry. I have 17 face id but when it prints it only gives me 8 face id values.
What can I do to make the code print all the faces temperature values? I'm running fluent in parallel.Â
#include "udf.h"ÂDEFINE_EXECUTE_AT_END(get_left_boundary_temperatures){  Domain* d = Get_Domain(1); // Get the domain  Thread* t;  face_t f;  FILE* fp;  int i, ID;  int zone[3] = { 5, 6,7 };  // Open file to write temperatures  fp = fopen("left_boundary_temperatures2.txt", "w");  if (fp == NULL)  {    Message("Error opening file for writing temperatures.\n");    return;  }  for (i = 0; i < 3; i++) { // Loop over relevant zones (left side)    ID = zone[i];    t = Lookup_Thread(d, ID);    // Loop through all threads    thread_loop_f(t, d)    {      // Check if the thread is a boundary thread      if (BOUNDARY_FACE_THREAD_P(t))      {        // Check if this is the left boundary thread        if (THREAD_ID(t) == zone[i]) // Use actual ID of left boundary        {          // Loop through faces in the thread          begin_f_loop(f, t)          {            // Get the temperature at the face            real temperature = F_T(f, t);            // Write the temperature to the file            fprintf(fp, "Face ID: %d, Temperature: %f\n", f, temperature);          }          end_f_loop(f, t);        Â        }      }    }    Â    // Close the file    fclose(fp);  }} -
September 9, 2024 at 12:37 pmFedericoAnsys Employee
Hello,Â
 When running Fluent in parallel, each compute node will handle a subset of the domain's mesh. Hence, try your UDF on a single CPU (serial) and see if it works. If it does, you will need to parallelize your UDFs. 7.3. Parallelizing Your Serial UDF (ansys.com)
-
September 9, 2024 at 1:42 pmcsolanovSubscriber
Hi,
Â
Thank you for your reply. Yes I have this code and it runs well in serial. I've tried to paralellize the code and it prints me only values for two boundary faces ID's. This is the code using macros for parallel and debug messages.
#include "udf.h"ÂDEFINE_EXECUTE_AT_END(get_left_boundary_temperatures){#if !RP_HOST  Domain* d = Get_Domain(1); // Get the domain  Thread* t;  face_t f;#endif  FILE* fp;  int i, ID;  int zone[3] = { 5, 6, 7 };  // Open file to write temperatures  fp = fopen("left_boundary_temperatures2.txt", "w");  if (fp == NULL)  {    Message("Error opening file for writing temperatures.\n");    return;  }  Message("File opened successfully.\n");  for (i = 0; i < 3; i++)  { // Loop over relevant zones (left side)    ID = zone[i];#if !RP_HOST    t = Lookup_Thread(d, ID);    // Debug message for thread ID    Message("Processing Thread ID: %d\n", ID);    // Check if the thread is a boundary thread    if (BOUNDARY_FACE_THREAD_P(t))    {      Message("Thread ID %d is a boundary thread.\n", ID); // Debug message      // Loop through faces in the thread      begin_f_loop(f, t)      {        // Get the temperature at the face        real temperature = F_T(f, t);        // Write the temperature to the file        fprintf(fp, "Thread ID: %d, Face ID: %d, Temperature: %f\n", ID, f, temperature);        // Debug message for face ID and temperature        Message("Thread ID: %d, Face ID: %d, Temperature: %f\n", ID, f, temperature);      }      end_f_loop(f, t);    }    else    {      Message("Thread ID %d is NOT a boundary thread.\n", ID); // Debug message    }#endif Â    PRF_GSYNC();  }   // Close the file  fclose(fp);  Message("File closed successfully.\n");}
-
- You must be logged in to reply to this topic.
- Non-Intersected faces found for matching interface periodic-walls
- Script error Code: 800a000d
- Unburnt Hydrocarbons contour in ANSYS FORTE for sector mesh
- Help: About the expression of turbulent viscosity in Realizable k-e model
- Fluent fails with Intel MPI protocol on 2 nodes
- Cyclone (Stairmand) simulation using RSM
- error udf
- Diesel with Ammonia/Hydrogen blend combustion
- Mass Conservation Issue in Methane Pyrolysis Shock Tube Simulation
- Script Error
-
1281
-
591
-
544
-
524
-
366
© 2024 Copyright ANSYS, Inc. All rights reserved.