Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Fluent / Re: Can I get the number of faces in a boundary zone to use it in a variable?
« Last post by william on December 27, 2020, 04:44:08 PM »
Hi,

How can I get the number of faces in a boundary zone to use it in a variable in Fluent?

Thanks.

Create a variable, then use the following Scheme code snippet

(define (ncf ct_id) (car (%inquire-faces-and-nodes-on-thread ct_id)))

Then just use

(ncf 4)

to get the number of faces in thread with ID 4.
12
Fluent / Can I get the number of faces in a boundary zone to use it in a variable?
« Last post by pico on December 27, 2020, 04:41:45 PM »
Hi,

How can I get the number of faces in a boundary zone to use it in a variable in Fluent?

Thanks.
13
You can use a UDF for this purpose, here is a sample code. You can modify it to suite your requirements for any variable you like to monitor:

Code: [Select]
#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
}

14
Fluent / Can I monitor the location of min/max values during the simulation in Fluent
« Last post by pico on December 27, 2020, 04:35:16 PM »
I want to monitor the location of min/max values, lets say pressure over the duration of a simulation with Ansys Fluent. Can anyone please help?

Thank you.
15
Fluent / Re: Global maximum value of a variable in Fluent using UDF
« Last post by infocfd on September 24, 2020, 05:24:53 PM »
Thanks!
16
Fluent / Re: Is there any UDF to access inter-phase mass transfer rate
« Last post by infocfd on September 24, 2020, 05:16:28 PM »
Thank you!
17
Fluent / Re: Global maximum value of a variable in Fluent using UDF
« Last 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);
}
18
Fluent / Global maximum value of a variable in Fluent using UDF
« Last 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.
19
Fluent / Re: Is there any UDF to access inter-phase mass transfer rate
« Last post by william on September 24, 2020, 04:50:32 PM »
Hi,
You can access the interphase mass transfer rate using the following macro:

C_STORAGE_R_XV(cell,mixture_thread,SV_MASS_TRANSFER,k-1)

k in the above macro is the mass transfer mechanism number, which can be found from phase interaction panel in fluent. The number in the mass transfer mechanism before the 'From Phase', 'To Phase' option is the mass transfer mechanism number.

And if you are looking for a UDF, the following code illustrates the example:

The UDF is used to store the cavitation mass transfer rates in a UDM location.

#include "udf.h"
#define k 1
DEFINE_ADJUST(mass_transfer_access,d)
{
cell_t c;
Thread *t;
thread_loop_c(t,d)
begin_c_loop(c,t)
C_UDMI(c,t,0) = C_STORAGE_R_XV(c,t,SV_MASS_TRANSFER,k-1);
end_c_loop(c,t)
}

20
Fluent / Is there any UDF to access inter-phase mass transfer rate
« Last post by infocfd on September 24, 2020, 04:46:00 PM »
I need to access the inter-phase mass transfer rate using a UDF in Fluent for further processing. Is there any macro or other method in fluent to access that?

Thank you in advance.
Pages: 1 [2] 3 4 ... 10