[ANSYS, 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 an Elbow Duct

Consider the elbow duct illustrated in Figure  8.2.1. The domain has a velocity inlet on the left side, and a pressure outlet at the top of the right side.

Figure 8.2.1: The Mesh 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 (of .01 m/sec) at the inlet are shown in Figures  8.2.2 and 8.2.3. The consistent profile is seen to develop as the flow passes through the duct.

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

Now suppose that you want to impose a non-uniform $x$ velocity to the duct inlet, which has a parabolic shape. The velocity is 0 m/s at the walls of the inlet and 0.1 m/s at the center.

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 ANSYS 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 dialog box) 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, h;
  face_t f;

  h = 0.016; /* inlet height in m */

    F_CENTROID(x, f, thread);
    y = 2.*(x[1]-0.5*h)/h; /* non-dimensional y coordinate */
    F_PROFILE(f, thread, position) = 0.1*(1.0-y*y);
  end_f_loop(f, thread)

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

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

figure Boundary Conditions figure figure velocity-inlet figure Edit...

Figure 8.2.4: The Velocity Inlet Dialog Box

In the X-Velocity drop-down list, select udf inlet_x_velocity, the name that was given to the function above (with udf preceding it). Click OK to accept the new boundary condition and close the dialog box. The user profile will be used in the subsequent solution calculation.

After the solution is initialized and 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 walls.

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 Pressure Outlet Profile for Flow in a Tube

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

p_x = p_0 + A \sin(\omega t)

The tube is assumed to be filled with air, with a fixed total pressure at the inlet. The pressure of the air fluctuates at the outlet about an equilibrium value ( $p_0$) of 101325 Pa, with an amplitude of 5 Pa and a frequency of 10 rad/s.

The source file listing for the UDF that describes the transient outlet profile is shown below. The function, named unsteady_pressure, 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 pressure profile boundary condition

#include "udf.h"

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

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


Before you can interpret or compile the UDF, you must specify a transient flow calculation in the General task page. Then, follow the procedure for interpreting source files using the Interpreted UDFs dialog box (Section  4.2), or compiling source files using the Compiled UDFs dialog box (Section  5.2).

The sinusoidal pressure boundary condition defined by the UDF can now be hooked to the outlet zone. In the Pressure Outlet dialog box (Figure  8.2.7), simply select the name of the UDF given in this example with the word udf preceding it ( udf unsteady_pressure) from the Gauge Pressure drop-down list. Click OK to accept the new boundary condition and close the dialog box. The user-defined profile will be used in the subsequent solution calculation.

figure Boundary Conditions figure figure pressure-outlet-5 figure Edit...

Figure 8.2.7: The Pressure Outlet Dialog Box

The time-stepping parameters are set in the Run Calculation task page (Figure  8.2.8).

figure Run Calculation

Figure 8.2.8: The Run Calculation Task Page

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 outlet velocity. The Profile Update Interval is set to 1 so that the pressure will be updated every iteration. After 300 time steps (or 15 periods) are complete, you can examine the pressure and velocity magnitude across the pressure outlet.

To collect this information during the calculation, open the Surface Monitor dialog box (Figure  8.2.9) before beginning the calculation.

figure Monitors figure Create... (Surface Monitors)

Figure 8.2.9: The Surface Monitor Dialog Box

The Surface Monitor dialog box will display the default settings. You can rename the surface monitor by entering monitor-1 in the Name text box. Then set the parameters in the Options group box. Enable Print to Console to see the changing values of the selected quantity in the console. Enable Plot so that the selected quantity will be plotted as the calculation proceeds. Enable Write so that the information will be written to a file, which will be given the name you enter in the File Name text box ( monitor-1.out). Select Flow Time from the X Axis drop-down list, and select Time Step in the drop-down list under Get Data Every.

Next, select Area-Weighted Average from the Report Type drop-down list. In the drop-down lists under Field Variable, select Pressure... and Static Pressure. Finally, select pressure-outlet-5 in the Surfaces selection list and click OK

In a similar manner, you can set up a second monitor to capture the velocity magnitude fluctuations in the pressure outlet.

After the first time step has been completed, the monitors should appear in the chosen plot windows. Alternatively, you can read the files by opening the File XY Plot dialog box (Figure  8.2.10).

figure Plots figure figure File figure Set Up...

Figure 8.2.10: The File XY Plot Dialog Box

You can read an output file by clicking Add... and selecting it in the Select File dialog box that opens and clicking OK. Then click the Plot button in the File XY Plot dialog box to obtain plots like those shown in Figures  8.2.11 and 8.2.12.

Figure  8.2.11 nicely illustrates that the pressure oscillates around the equilibrium value, 101325 Pa, with an amplitude of 5 Pa, as expected.

Figure 8.2.11: Average Static Pressure at the Pressure Outlet

Figure 8.2.12: Average Velocity Magnitude at the Pressure Outlet

next up previous contents index Previous: 8.2 Detailed UDF Examples
Up: 8.2 Detailed UDF Examples
Next: 8.2.2 Source Terms
Release 12.0 © ANSYS, Inc. 2009-01-14