TAGGED: fluent, udf, user-defined-function
-
-
March 28, 2024 at 3:14 pm
Mehdi Famouri
SubscriberHello fellow UDF writers! Does anyone have an example using PRF_GRSUM macro? Please note, I'm not asking about PRF_GRSUM1 macro.Â
Best,
Mehdi -
April 9, 2024 at 1:40 pm
Luca B.
Forum ModeratorHi,
The PRF_GRSUM macro in Fluent's User Defined Functions (UDF) is used to compute the global sum of a float or double array across all compute nodes in a parallel computation. Here's an example of how you might use the PRF_GRSUM macro in a UDF:
DEFINE_ON_DEMAND(test)
{
real x[1]; /* Array of size 1 to hold the sum */
real sum;
int iwork[1]; /* Work array for parallel operation */
/* Initialize the array with the value to sum */
x[0] = 5; /* Your code to set the initial value */
/* Compute the global sum */
PRF_GRSUM(x, 1, iwork);
/* x[0] now contains the sum of the values across all compute nodes */
sum = x[0];
Message0("Total = %f\n",sum);
/* You can now use 'sum' for further calculations or monitoring */
}
In this example,
x
is an array that you want to sum across all compute nodes. ThePRF_GRSUM
macro takes the arrayx
, the number of elements in the array (which is 1 in this case), and a work arrayiwork
as arguments. After the macro is called,x[0]
will contain the global sum of the values that were inx
on each compute node.Please note that the PRF_GRSUM macro should be used in a context where it is called only once per compute node, such as within the
DEFINE_ADJUST
macro, to avoid issues with parallel execution as mentioned in the documentation. -
April 20, 2024 at 1:04 pm
Mehdi Famouri
SubscriberThank you Luca for your attention and reply, shouldn't "x" and "iwork" have the same declaration? One is integer and the other is real.Â
-
April 20, 2024 at 1:09 pm
Mehdi Famouri
Subscriber
-
- The topic ‘Fluent UDF: An example using PRF_GRSUM macro?’ is closed to new replies.
- How do I get my hands on Ansys Rocky DEM
- Unburnt Hydrocarbons contour in ANSYS FORTE for sector mesh
- convergence issue for transonic flow
- Facing trouble regarding setting up boundary conditions for SOEC Modeling
- Point exception in erosion calculation
- Errors with multi-connected bodies using AQWA
- Script Error Ansys
-
2502
-
931
-
761
-
599
-
591
© 2025 Copyright ANSYS, Inc. All rights reserved.