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

8.2.1 Boundary Conditions

This section contains two applications of boundary condition UDFs.

Parabolic Velocity Inlet Profile in a Turbine Vane

Consider the turbine vane illustrated in Figure  8.2.1. An unstructured grid is used to model the flow field surrounding the vane. The domain extends from a periodic boundary on the bottom to an identical one on the top, a velocity inlet on the left, and a pressure outlet on the right.

Figure 8.2.1: The Grid for the Turbine Vane Example

A flow field in which a constant $x$ velocity is applied at the inlet will be compared with one where a parabolic $x$ velocity profile is applied. While the application of a profile using a piecewise-linear profile is available with the boundary profiles option , the specification of a polynomial can only be accomplished by a user-defined function.

The results of a constant-velocity applied field (of 20 m/sec) at the inlet are shown in Figures  8.2.2 and 8.2.3. The initial constant velocity field is distorted as the flow moves around the turbine vane.

Figure 8.2.2: Velocity Magnitude Contours for a Constant Inlet $x$ Velocity

Figure 8.2.3: Velocity Vectors for a Constant Inlet $x$ Velocity

The inlet $x$ velocity will now be described by the following profile:

v_x = 20 - 20 \left( \frac{y}{0.0745} \right)^2

where the variable $y$ is 0.0 at the center of the inlet, and extends to values of $\pm$ 0.0745 m at the top and bottom. Thus the $x$ velocity will be 20 m/sec at the center of the inlet, and 0 at the edges.

A UDF is used to introduce this parabolic profile at the inlet. The C source code ( vprofile.c) is shown below. The function makes use of Fluent-supplied solver functions that are described in Section  3.2.4.

The UDF, named inlet_x_velocity, is defined using DEFINE_PROFILE and has two arguments: thread and position. Thread is a pointer to the face's thread, and position is an integer that is a numerical label for the variable being set within each loop.

The function begins by declaring variable f as a face_t data type. A one-dimensional array x and variable y are declared as real data types. A looping macro is then used to loop over each face in the zone to create a profile, or an array of data. Within each loop, F_CENTROID outputs the value of the face centroid (array x) for the face with index f that is on the thread pointed to by thread. The $y$ coordinate stored in x[1] is assigned to variable y, and is then used to calculate the $x$ velocity. This value is then assigned to F_PROFILE , which uses the integer position (passed to it by the solver based on your selection of the UDF as the boundary condition for $x$ velocity in the Velocity Inlet panel) to set the $x$ velocity face value in memory.

   UDF for specifying steady-state velocity profile boundary condition 
#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position) 
  real x[ND_ND];		/* this will hold the position vector */
  real y;
  face_t f;

  begin_f_loop(f, thread)
      y = x[1];
      F_PROFILE(f, thread, position) = 20. - y*y/(.0745*.0745)*20.;
  end_f_loop(f, thread)

To make use of this UDF in FLUENT, you will first need to interpret (or compile) the function, and then hook it to FLUENT using the graphical user interface. Follow the procedure for interpreting source files using the Interpreted UDFs panel (Section  4.2), or compiling source files using the Compiled UDFs panel (Section  5.2).

To hook the UDF to FLUENT as the velocity boundary condition for the zone of choice, open the Velocity Inlet panel and click on the Momentum tab (Figure  8.2.4).

Define $\rightarrow$ Boundary Conditions...

Figure 8.2.4: The Velocity Inlet Panel

In the X-Velocity drop-down list, select udf inlet_x_velocity, the name that was given to the function above (with udf preceeding it). Once selected, the default value will become grayed-out in the X-Velocity field. Click OK to accept the new boundary condition and close the panel. The user profile will be used in the subsequent solution calculation.

After the solution is run to convergence, a revised velocity field is obtained as shown in Figures  8.2.5 and 8.2.6. The velocity field shows a maximum at the center of the inlet, which drops to zero at the edges.

Figure 8.2.5: Velocity Magnitude Contours for a Parabolic Inlet $x$ Velocity

Figure 8.2.6: Velocity Vectors for a Parabolic Inlet $x$ Velocity

Transient Velocity Inlet Profile for Flow in a Tube

In this example, a temporally periodic velocity boundary condition will be applied to the inlet of a tube using a UDF. The velocity has the form

v_x = v_0 + A \sin(\omega t)

The tube is 1 m long with a radius of 0.2 m. It is assumed to be filled with air with a density of 1 kg/m $^3$ and a viscosity of 2 $\times 10^{-5}$ kg/m-s. The velocity of the air fluctuates about an equilibrium value, $v_0$, of 20 m/s, with an amplitude of 5 m/s and at a frequency of 10 rad/s.

The source file listing for the UDF that describes the transient inlet profile is shown below. The function, named unsteady_velocity, is defined using the DEFINE_PROFILE macro. The utility CURRENT_TIME is used to look up the real flow time, which is assigned to the variable t. (See Section  3.5 for details on CURRENT_TIME).

   UDF for specifying a transient velocity profile boundary condition 

#include "udf.h"

DEFINE_PROFILE(unsteady_velocity, thread, position) 
  face_t f;
  real t = CURRENT_TIME;

  begin_f_loop(f, thread)
      F_PROFILE(f, thread, position) = 20. + 5.0*sin(10.*t);
  end_f_loop(f, thread)

Before you can interpret or compile the UDF, you must specify an unsteady flow calculation in the Solver panel. Then, follow the procedure for interpreting source files using the Interpreted UDFs panel (Section  4.2), or compiling source files using the Compiled UDFs panel (Section  5.2).

The sinusoidal velocity boundary condition defined by the UDF can now be hooked to the inlet zone for the X-Velocity. In the Velocity Inlet panel , simply select the name of the UDF given in this example with the word udf preceeding it ( udf unsteady_velocity) from the drop-down list to the right of the X-Velocity field. Once selected, the default value will become grayed-out in the X-Velocity field. Click OK to accept the new boundary condition and close the panel. The user profile will be used in the subsequent solution calculation.


The time-stepping parameters are set in the Iterate panel .

Solve $\rightarrow$ Iterate...


In this example, a Time Step Size of 0.0314 s is used so that 20 time steps will complete a full period of oscillation in the inlet velocity. The UDF Profile Update Interval is set to 1 so that the velocity will be updated every iteration. After 60 time steps (or 3 periods) are complete, you can examine the velocity magnitude across the pressure outlet for its response to the oscillating inlet condition.

To collect this information during the calculation, open the Surface Monitors panel before beginning to iterate.

Solve $\rightarrow$ Monitors $\rightarrow$ Surface...


Increase the Surface Monitors index to 1. This will enable you to define the parameters of monitor-1 (which you could rename, if desired, in the text entry box under Name). Select Plot so that the selected quantity will be plotted as the calculation proceeds. Select Print to see the changing values of the selected quantity in the console window. Select Write so that the information will be written to a file, which will be given the name monitor-1.out. (If you change the name of the monitor, that name will be used as the prefix for the output file.)

Under Every, you can choose Iteration, Time Step, or Flow Time. To monitor the result of each time step, you should choose the Time Step option. By clicking on Define... you can specify the quantity to be monitored in the Define Surface Monitor panel.


In this example, Velocity... and Velocity Magnitude are chosen in the drop-down lists under Report of. The location of the report is pressure-outlet-5, which is selected in the Surfaces list. A simple Area-Weighted Average is chosen in the Report Type drop-down list, with the Flow Time chosen in the X Axis drop-down list.

Once the first time step has been completed, the monitor should appear in the chosen plot window. Alternatively, you can read the file by opening the File XY Plot panel .

Plot $\rightarrow$ File...


You can read the output file by typing its name in the text entry box under Files and clicking on Add.... By selecting this file and clicking on Plot, you can obtain the plot shown in Figure  8.2.7.

Figure 8.2.7: Average Velocity Magnitude at the Pressure Outlet

The figure nicely illustrates that the velocity oscillates around the equilibrium value, 20 m/s, with an amplitude of 5 m/s, as expected.

next up previous contents index Previous: 8.2 Detailed UDF Examples
Up: 8.2 Detailed UDF Examples
Next: 8.2.2 Source Terms
© Fluent Inc. 2006-09-13