Author Topic: Global maximum value of a variable in Fluent using UDF  (Read 9873 times)

Offline infocfd

  • Newbie
  • *
  • Posts: 45
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Global maximum value of a variable in Fluent using UDF
« on: September 24, 2020, 05:06:04 PM »
Advertisement
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.

Offline william

  • Full Member
  • ***
  • Posts: 159
  • Reputation: +15/-0
  • Know it, share it.
    • View Profile
Re: Global maximum value of a variable in Fluent using UDF
« Reply #1 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);
}
« Last Edit: September 24, 2020, 05:21:06 PM by william »

Offline infocfd

  • Newbie
  • *
  • Posts: 45
  • Reputation: +0/-0
  • Searching for solution
    • View Profile
Re: Global maximum value of a variable in Fluent using UDF
« Reply #2 on: September 24, 2020, 05:24:53 PM »
Thanks!