-
-
August 1, 2019 at 3:45 pm
kfouladi
SubscriberHello All,
I have problem using a DEFINE_EXECUTE_AT_END UDF. It seems not to do anything or at least it does not create the output file (edata.txt). I originally had this UDF as a DEFINE_ON_DEMAND, which worked fine. Any help would be appreciated.Â
This is what fluent writes at the end:
Registering UdfSource, ("Users/kfoul_000/Documents/…../gen.c")
Registering Udflib, ("Users/kfoul_000/Documents/…./dp0/FFF-1/Fluent/libudfxaa1")
 Writing data to C:Userskfoul_000Documents....dp0FFF-1FluentFFF-1.1.ip ...
(1) IÂ have defined 3 User-Defined Memory. (2) Please disregard the accuracy of the equation.
My UDF file is attached to the next post.
Â
Kamran
-
August 1, 2019 at 3:45 pm
kfouladi
Subscriber#include "udf.h"
DEFINE_EXECUTE_AT_END(gen)
{
 Domain *d; /* declare domain pointer since it is not passed as an Â
         argument to the DEFINE macro */
  real temp = 293.15;
  real dudx, dudy;
  real rho = 1000.0;
  real sum_e;
  sum_e=0.;
  Thread *t;
  cell_t c;
  d = Get_Domain(1);   /* Get the domain using Fluent utility */
   /*(location index 0)                      */
  /* Loop over all cell threads in the domain */
  thread_loop_c(t,d)
   {
   begin_c_loop(c,t)
    {
dudx = C_U_G(c,t)[0];
dudy = C_U_G(c,t)[1];
     C_UDMI(c,t,0) = 1.0/temp*(2*(pow(dudx,2) + pow(dvdy,2) ));
C_UDMI(c,t,1) = rho;
C_UDMI(c,t,2) = C_UDMI(c,t,0) + C_UDMI(c,t,1);
    sum_e += C_UDMI(c,t,2) * C_VOLUME(c,t);
    }
   end_c_loop(c,t)
    }
printf("Volume integral e: %gn", sum_e);
FILE *fp;Â Â Â
 fp = fopen("edata.txt","w+");Â
 fprintf(fp, "Volume integral e: %gn", sum_e);
fclose(fp);Â
fflush(stdout);
}
-
August 2, 2019 at 6:50 pm
Konstantin
Ansys Employee1) is the DEFINE_EXECUTE_AT_END executed? You have printf, is this message been printed?
2) since you are not specifying explicit path to the file, fluent is expected to open file in project_filesdp0FLUFluent, but if it's not there, do a quick search of your folders to check if it's been written in a different place
-
August 2, 2019 at 8:18 pm
kfouladi
SubscriberI am not sure DEFINE_EXECUTE_AT_END is executed. printf is not printed and I checked my computer and there is no "edata.txt" in any directory.
-
August 2, 2019 at 8:20 pm
Konstantin
Ansys Employeeis it properly hooked: User-Defined - Functions - Hooks
-
August 4, 2019 at 3:04 pm
Konstantin
Ansys EmployeeIs DEFINE_EXECUTE_AT_END executed at every iteration? Do you see printf outputs after each iteration? What may happen is the file is not overwritten at a subsequent execution, but this is a basic C programming question not related to ANSYS products
-
- The topic ‘EXECUTE_AT_END UDF’ is closed to new replies.
-
6570
-
1906
-
1463
-
1311
-
1022
© 2026 Copyright ANSYS, Inc. All rights reserved.