CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   DEFINE_PROFILE: flow time does not increase within UDF (https://www.cfd-online.com/Forums/fluent-udf/216214-define_profile-flow-time-does-not-increase-within-udf.html)

FrankR April 1, 2019 08:37

DEFINE_PROFILE: flow time does not increase within UDF
 
Dear Community,

I want to modify a boundary condition. Luckily, the example "2.3.24.11. Example 9 - Mass Flow Rate UDF for a Mass-Flow Inlet or Mass-Flow Outlet" from the "ANSYS Fluent Customization Manual" is almost want I need.

With minor variations I defined as an interpreted UDF:
---------------------------------------------

#include "udf.h"
DEFINE_PROFILE(Test_07_mass_flow,th,i)
{
face_t f;
real flow_time = CURRENT_TIME;
begin_f_loop(f,th)
{
if(flow_time <= 906.0)
F_PROFILE(f,th,i) = -(0.00006*flow_time-0.0779);
else
F_PROFILE(f,th,i) = 0.0;
}
end_f_loop(f,th);
printf("\n flow_time = %f F_PROFILE(f,th,i) = %f\n", flow_time, F_PROFILE(f,th,i) );
}
----------------------------------------------

Mass flow is an output parameter, and I get a value of 0.0779. The term in parentheses is evaluated at every instant, but only with flow_time=0, even though flow_time augments in the course of the simulation.

Why is what ? Evidently, FLUENT does find the UDF as the initial value is correct.

And why is printf to the console not executed ?

Fringe question: how can I have the data written to an additional file ? I tried
FILE *fp;
fp = fopen("data.txt","w");
fprintf(fp, "%4.2f %4.2f\n", flow_time, F_PROFILE(f,th,i) );
fclose(fp); /* close the file pointed to by fp */
but FLUENT does not like "FILE *fp".

I use the FLUENT "Academic Student Release" 19.2 on a Windows-PC in stand-alone mode (not using Workbench).

Thank you dearly for sharing your expertise and your kind advice,

FrankR

pakk April 1, 2019 10:43

I have to ask, because you did not mention it: are you sure that you are running a transient simulation, and not steady-state?


And printf is executed, but it does not print to the console. To print to the console, you should use the Message() command.

FrankR April 1, 2019 10:51

It is transient.

Message works only for compiled UDF. Our System Administrator will not have time to install anything for me.

Thanks,
FrankR

AlexanderZ April 2, 2019 00:45

use
Code:

real flow_time;
 flow_time = RP_Get_Real("flow-time");

best regards

FrankR April 2, 2019 07:55

Dear AlexanderZ

thank you so much, this did the trick.

I found your advice in the same manual, chapter "3.5. Time-Dependent Macros". The difference between these two definitions is not elaborated.

Printing to screen is possible. The printf-command must be placed inside the loop. Outside the loop F_PROFILE(f,th,i) is zero.

The chapter "8.2.1.2. Transient Pressure Outlet Profile for Flow in a Tube" reveals that the "Profile Update Interval" must be set to 1 so that the UDF is evaluated in every iteration.

There is just one aspect that is irritating me: that same chapter speaks of a "Surface Monitor dialog box" in the context of the example given. This dialog box can ostensibly be accessed via Solution → Monitors → Surface New...

This option does not exist, this dialog box does not pop up anywhere. Under Tree, Solution, Monitors I find only Residual, Report Files, Report Plots, Convergence Conditions.

Any idea ? Is there a way to extend this menu ?

Thank you again,

FrankR

pakk April 2, 2019 08:09

1 Attachment(s)
Ah, that is something from the past...
It existed in Fluent 16.2, and it was gone by Fluent 18.0. (I don't have Fluent 17.X available now.)


Apparently, when the monitor system was updated in Fluent, they forgot to update this part of the manual.

FrankR April 2, 2019 08:46

If that is true, then it means that Ansys provides a very miserable documentation. Because I use release 19.2.
Maybe they forget to browse their old Manuals.


All times are GMT -4. The time now is 18:27.