Udf Porus
Udf Porus
Purpose
The purpose of this tutorial is to illustrate the modelling of a position dependent porous
plug in a two dimensional channel flow with the help of a User Defined Function (UDF).
Prerequisites
This tutorial assumes that you are familiar with FLUENT interface and that you have
a good understanding of the basic setup and solution procedures. If not, the FLUENT
Tutorial Guide will provide you with the necessary experience. If you have not used UDF’s,
it would be helpful to review the FLUENT UDF Manual.
Problem Description
The problem to be considered is shown schematically in Figure 1.1. The domain is divided
into two fluid zones. In zone fluid-2 a x-momentum source is patched with the help of a
user defined function (UDF) which effectively behaves like a porous plug.
porous plug
inlet outlet
/*******************************************************************/
/* */
/* Position-Dependent Porous Media */
/* */
/*******************************************************************/
#include "udf.h"
#define c2 100.0
real x[ND_ND];
float con, source;
return source;
3. Under lib porous directory, create two subdirectories named src and ntx86.
4. Copy the source file (porous plug.c) to the src directory.
5. Under ntx86 directory, create a subdirectory called 2d and copy the files makefile nt.udf
and user nt.udf to it. Use the following path to obtain both the files:
\Fluent.inc\fluent6.0\src
8. Finally, in the command prompt, go to the working directory (2d) and type the
command nmake to compile the udf.
Note: If there is some problem, type nmake clean and then again type nmake. You
will see the appropriate message in the console.
Step 2: Grid
Step 3: Models
2. Turn on the standard k-epsilon (2 eqn) turbulence model with standard wall functions.
Step 4: Materials
We will use the default fluid properties of air for this problem. Therefore, we need not make
any changes to the material properties.
Step 5: Link the UDF’s
For more information on linking the compiled UDF’s, refer to Section 7.3.4 Linking Your
Shared Library to the FLUENT Executable, in the UDF Manual.
Step 6: Boundary Conditions
Step 7: Solution
1. Initialize the flow field using the boundary conditions set at velocity-inlet-1.
2. Enable the plotting of residuals during calculation.
1e-01
1e-02
1e-03
1e-04
1e-05
1e-06
0 5 10 15 20 25 30 35 40 45
Iterations
Step 8: Postprocessing
2.09e+00
1.92e+00
1.75e+00
1.58e+00
1.41e+00
1.24e+00
1.07e+00
8.96e-01
7.25e-01
5.54e-01
3.83e-01
Results
The above vector plot shows that the fluid flows preferentially near the bottom of the
channel due to the effect of the source term on the axial momentum of the fluid.
Summary
This tutorial has demonstrated the use of UDFs for specifying source terms. User-defined
source terms can be a useful way of introducing additional physics into the simulation, and
can usually be modeled as sources or sinks of mass, momentum, energy, species, etc.
Once you are comfortable with the present exercise, try modifying the UDF to specify
momentum sources for both the x and y momentum equations. The present UDF could
be copied and suitably modified for the y momentum equation. Both functions would then
reside in the UDF file, and be accessible to the solver upon compilation.
Appendix
If you prefer to compile the UDFs on a UNIX machine, follow the procedure below:
4. Make a source directory (mkdir src) and put your source code (porous plug.c) in the
src directory.
6. Edit the SOURCES and FLUENT INC macros in makefile for your own use.
8. Build the shared libraries by typing make in your lib porous directory (the one with
Makefile in it):
For compiling UDF’s on any other platform, refer to Section 7.3, Compiled UDFs,
in the UDF Manual.