Simulating wave propagation in a controlled environment is a fundamental challenge in offshore and marine engineering. A Numerical Wave Tank (NWT) allows us to study how waves interact with structures without the cost of physical testing. However, generating stable, physical waves requires precise boundary conditions often handled through custom scripts.
In this tutorial, we walk through the complete setup of a Numerical Wave Tank in ANSYS Fluent, utilizing a User Defined Function (UDF) to generate gravity waves via the Volume of Fluid (VOF) model and Open Channel Flow settings.
Project Workflow
1. Geometry & Domain Design
The tank is modeled as a 3D rectangular domain to capture the longitudinal propagation of waves.
- Length: 25 meters (to allow space for wave development).
- Cross-Section: 3m x 1.5m.
- Method: Created as a 2D sketch in the XY plane and extruded in the Z-direction.
2. Meshing Strategy
To capture the free-surface interface accurately, a structured or high-quality semi-structured mesh is required.
- Method: Multi-zone meshing with adaptive sizing.
- Resolution: Seven-level resolution to ensure the interface between air and water remains sharp during propagation.
- Cell Count: Approximately 124,000 cells for this specific 3D domain.
3. Solver Setup & VOF Model
The simulation relies on the Volume of Fluid (VOF) multiphase model.
- Physics: Gravity enabled in the Y-direction (-9.81 m/s²).
- Phases: Air (Primary) and Water (Secondary) with a surface tension coefficient of 75.
- Options: Open Channel Flow enabled to provide the necessary framework for surface gravity waves.
- Turbulence: K-Epsilon RNG with standard wall functions.
Wave Generation via UDF
The core of the wave generation is the User Defined Function (UDF). It defines the velocity components at the inlet boundary as a function of time and position to mimic the kinematics of a physical wave maker.
Note: Ensure you compile and build the UDF within the Fluent environment before assigning it to the Velocity Inlet.
4. Initialization & Patching
Before starting the transient run, we must define the initial water level in the tank:
- Step 1: Standard initialization.
- Step 2: Create a "Marked Region" up to the desired initial water height.
- Step 3: Patch the Phase 2 (Water) volume fraction as 1 in that region.
Results & Visualization
To visualize the waves, we use ISO-Surfaces in CFD-Post. By selecting the Volume Fraction of water at a value of 0.99, we can clearly see the wave profile as it moves from the inlet to the outlet.
Transient animations help verify the wave height, wavelength, and phase velocity against theoretical values, ensuring the UDF is correctly modeling the target sea state.
Download the UDF & Project Files
The source code for the wave generation UDF and the full simulation walkthrough are available on the YouTube channel.
▶ Subscribe to ANSYS Tutor