You are on page 1of 2

____________________________________________________________________________________

DEFINE_PROFILE execution and UDF Profile


Update Interval for Unsteady Simulations
Problem/Description:
DEFINE_PROFILE execution and UDF Profile Update Interval for Unsteady Simulations

Solution:
In order to increase computational efficiency, it may be desirable to update boundary profiles that are
assigned via UDFs only at the first iteration of each time step. In Fluent, the DEFINE_PROFILE macros
are executed at every iteration within every time step. The UDF Profile Update Interval in the Iterate
panel can be used to restrict the execution of the DEFINE_PROFILE macros to every N iterations during
an unsteady calculation. In an unsteady calculation, regardless of the value entered for UDF Profile
Update Interval, all DEFINE_PROFILE macros are also executed a single time prior to the execution of
the DEFINE_ADJUST function for the first iteration of the time step.

This means that if the values to be assigned in the DEFINE_PROFILE function are functions of time
ONLY, a very large value can be entered for the UDF Profile Update Interval in the Iterate panel, and the
DEFINE_PROFILE function will be executed once, and only once per time step.

This trick will not work if the values to be assigned in the DEFINE_PROFILE function happen to depend
on various quantities that are calculated in the DEFINE_ADJUST macro. This is because the once-per-
time-step execution of all DEFINE_PROFILE functions occurs before the execution of the
DEFINE_ADJUST function for the first iteration in the time step. There is no elegant way to suppress the
execution of the DEFINE_PROFILE functions at the beginning of each time step and it is not possible to
force the DEFINE_ADJUST function to execute first. Therefore, when the DEFINE_PROFILE functions
depend on values calculated in the DEFINE_ADJUST function, one possible workaround that will
approximate executing the DEFINE_PROFILE macros only during the first iteration of each time step is to
add some code to the UDF so that the looping macros within the DEFINE_PROFILE blocks are executed
only at the first iteration of every time step. Users can consider many ways to do this. One possibility is
detailed below.

---------------------------------------------------------------------------------------------------

#include "udf.h"

real current = 0.0;


real profile1 = -0.01;
real profile2 = -0.01
/* etc, one value for each profile macro */

DEFINE_ADJUST(name,domain)
{
current = RP_Get_Real("flow-time");
.
.
other commands
.
.
}
DEFINE_PROFILE(name,t,nv)
{
if(profile1 != current)
{
begin_f_loop(f,thread)
{}
end_f_loop(f,thread)
}
profile1 = current;
}

This will work because the value of current can only be updated in the adjust function. Therefore, the
loop in the DEFINE_PROFILE macro will not be executed until after the DEFINE_ADJUST function has
been executed for the first iteration of the new time step.

You might also like