CAPE Forum

Ansys => Fluent => Topic started by: infocfd on September 24, 2020, 05:06:04 PM

Title: Global maximum value of a variable in Fluent using UDF
Post by: infocfd on September 24, 2020, 05:06:04 PM
Is there any way of accessing the value of a global maximum value in the domain using a UDF in fluent?

Thank you in advance.
Title: Re: Global maximum value of a variable in Fluent using UDF
Post by: william on September 24, 2020, 05:14:20 PM
Hi,

The Global Maximum Value of a certain variable can be obtained through the User Defined Functions in Fluent using Global Maximum Macro PRF_GRHIGH1(x). This can be used to obtain the Global Minimum as well.

Here is the implementation that outputs the global maximum temperature in the domain:

Code: [Select]
#include "udf.h"
DEFINE_ON_DEMAND(MaxTemp)
{
Domain *d;
d = Get_Domain(1); /* Get the domain using Fluent utility */
Thread *t;
cell_t c;
real T_maxx = 0;
real T_max = 0;
#if RP_NODE
{
thread_loop_c(t,d)
{
if (FLUID_THREAD_P(t))
{
begin_c_loop(c,t)
{
T_maxx = MAX(C_T(c,t), T_maxx);
}
end_c_loop(c,t)
}
}
}
#endif
 T_max = PRF_GRHIGH1(T_maxx);
Message("\n T_maxx %0.14f", T_maxx);
Message("\n T_max %0.14f", T_max);
}
Title: Re: Global maximum value of a variable in Fluent using UDF
Post by: infocfd on September 24, 2020, 05:24:53 PM
Thanks!