-
-
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
Konstantine Kourbatski
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
Konstantine Kourbatski
Ansys Employeeis it properly hooked: User-Defined - Functions - Hooks
-
August 4, 2019 at 3:04 pm
Konstantine Kourbatski
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
-
- You must be logged in to reply to this topic.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Suppress Fluent to open with GUI while performing in journal file
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Difference between K-epsilon and K-omega Turbulence Model
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- error in cfd post
-
2688
-
2138
-
1355
-
1136
-
462
© 2023 Copyright ANSYS, Inc. All rights reserved.