[ANSYS, Inc. Logo] return to home search
next up previous contents index

2.2.1 DEFINE_ADJUST



Description


DEFINE_ADJUST is a general-purpose macro that can be used to adjust or modify ANSYS FLUENT variables that are not passed as arguments. For example, you can use DEFINE_ADJUST to modify flow variables (e.g., velocities, pressure) and compute integrals. You can also use it to integrate a scalar quantity over a domain and adjust a boundary condition based on the result. A function that is defined using DEFINE_ADJUST executes at every iteration and is called at the beginning of every iteration before transport equations are solved. For an overview of the ANSYS FLUENT solution process which shows when a DEFINE_ADJUST UDF is called, refer to Figures  1.9.1, 1.9.2, and 1.9.3.



Usage



DEFINE_ADJUST( name, d)


Argument Type Description
symbol name UDF name.
Domain *d Pointer to the domain over which the adjust function is
  to be applied. The domain argument provides access to all
  cell and face threads in the mesh. For multiphase flows, the
  pointer that is passed to the function by the solver is the
  mixture-level domain.
Function returns  
void  
   

There are two arguments to DEFINE_ADJUST: name and d. You supply name, the name of the UDF. d is passed by the ANSYS FLUENT solver to your UDF.



Example 1


The following UDF, named my_adjust, integrates the turbulent dissipation over the entire domain using DEFINE_ADJUST. This value is then displayed in the console. The UDF is called once every iteration. It can be executed as an interpreted or compiled UDF in ANSYS FLUENT.

/********************************************************************
   UDF for integrating turbulent dissipation and displaying it in the
   console                                                   
*********************************************************************/

#include "udf.h"

DEFINE_ADJUST(my_adjust,d)
{
  Thread *t;
  /* Integrate dissipation. */
  real sum_diss=0.;
  cell_t c;
  
  thread_loop_c(t,d)
  {
   begin_c_loop(c,t)
       sum_diss += C_D(c,t)*
       C_VOLUME(c,t);
   end_c_loop(c,t)
  }
 
  printf("Volume integral of turbulent dissipation: %g\n", sum_diss);
}



Example 2


The following UDF, named adjust_fcn, specifies a user-defined scalar as a function of the gradient of another user-defined scalar, using DEFINE_ADJUST. The function is called once every iteration. It is executed as a compiled UDF in ANSYS FLUENT.

/********************************************************************
   UDF for defining user-defined scalars and their gradients        
*********************************************************************/

#include "udf.h"

DEFINE_ADJUST(adjust_fcn,d)
{
  Thread *t;
  cell_t c;
  real K_EL = 1.0;
 
  /* Do nothing if gradient isn't allocated yet. */
  if (! Data_Valid_P())
    return;

  thread_loop_c(t,d)
    {
    if (FLUID_THREAD_P(t))
       {
        begin_c_loop_all(c,t)
            {
             C_UDSI(c,t,1) += 
                          K_EL*NV_MAG2(C_UDSI_G(c,t,0))*C_VOLUME(c,t);
            }
        end_c_loop_all(c,t)
       }
    }
}



Hooking an Adjust UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_ADJUST is interpreted (Chapter  4) or compiled (Chapter  5), the name of the argument that you supplied as the first DEFINE macro argument (e.g., adjust_fcn) will become visible and selectable via the User-Defined Function Hooks dialog box in ANSYS FLUENT. Note that you can hook multiple adjust functions to your model. See Section  6.1.1 for details.


next up previous contents index Previous: 2.2 General Purpose DEFINE
Up: 2.2 General Purpose DEFINE
Next: 2.2.2 DEFINE_DELTAT
Release 12.0 © ANSYS, Inc. 2009-01-14