1
Fluent / Re: What is the macro to access the level-set function in a UDF?
« on: December 27, 2020, 05:23:29 PM »
The Level-set function can be accessed using the C_LSF(c,t) macro, where 't' is the phase thread pointer in Fluent.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
I am getting the following Error: "ST_Create_Store: out of memory" in out file.
Please tell me how to fix this error.
Thank you.
Hi,
How can I get the number of faces in a boundary zone to use it in a variable in Fluent?
Thanks.
#include "udf.h"
static real global_max_pressure;
static real global_coordinates_max_pressure[ND_ND];
static int global_print_output = 1;
DEFINE_ON_DEMAND(get_max_pressure)
{
Domain *d = Get_Domain(1);
Thread *t;
cell_t c;
real max_pressure = -REAL_MAX;
real max_pressure_node;
real iwork[ND_ND], coordinates_max_pressure[ND_ND];
#if !RP_HOST
/* Calculate the maximum pressure */
thread_loop_c(t, d)
{
if (FLUID_THREAD_P(t)) {
begin_c_loop_int(c, t)
{
if (C_P(c,t) > max_pressure) {
max_pressure = C_P(c,t);
C_CENTROID(coordinates_max_pressure, c, t);
}
}
end_c_loop_int(c, t)
}
}
max_pressure_node = max_pressure;
/* Global reduction */
max_pressure = PRF_GRHIGH1(max_pressure);
/* Verify on each compute node, consider numerical round-off errors */
if (max_pressure_node < max_pressure-max_pressure*1e-16) {
NV_S(coordinates_max_pressure,=,-REAL_MAX);
}
PRF_GRHIGH(coordinates_max_pressure,ND_ND,iwork);
/* Output */
global_max_pressure = max_pressure;
NV_V(global_coordinates_max_pressure,=,coordinates_max_pressure);
if (global_print_output) {
#if RP_2D
Message0("Max pressure %e at %e | %e\n", max_pressure,
coordinates_max_pressure[0], coordinates_max_pressure[1]);
#else
Message0("Max pressure %e at %e | %e | %e\n", max_pressure,
coordinates_max_pressure[0], coordinates_max_pressure[1],
coordinates_max_pressure[2]);
#endif
}
#endif
}
DEFINE_ON_DEMAND(activate_console_output)
{
global_print_output = 1;
}
DEFINE_ON_DEMAND(deactivate_console_output)
{
global_print_output = 0;
}
DEFINE_EXECUTE_AT_END(run_max_pressure)
{
get_max_pressure();
node_to_host_real_1(global_max_pressure);
node_to_host_real(global_coordinates_max_pressure, ND_ND);
}
DEFINE_REPORT_DEFINITION_FN(max_pressure_location_x)
{
return global_coordinates_max_pressure[0];
}
DEFINE_REPORT_DEFINITION_FN(max_pressure_location_y)
{
return global_coordinates_max_pressure[1];
}
DEFINE_REPORT_DEFINITION_FN(max_pressure_location_z)
{
#if RP_2D
return 0.0;
#else
return global_coordinates_max_pressure[2];
#endif
}
#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);
}