Tutorial Module01

Revision as of 13:51, 7 December 2017 by Chris.Huxley (Talk | contribs) (Create Scatter Points)

Jump to: navigation, search
LINKS: Main page
Modelling Advice Tutorial Models Tips and Tricks
Mesh Generation Tips Tutorial Module 1 SMS
A Model Won't Start Tutorial Module 2 UltraEdit
A Model Crashes Tutorial Module 3 Notepad++
A Model Runs Slow Tutorial Module 4 Excel
TUFLOW Products Support / Contact TUFLOW FV Utilities
Requesting a Licence Running TUFLOW FV
Mesh Generation Tips

Tutorial Description

The following example demonstrates the development of a very simple model mesh. Follow the steps performed here and expand upon them to develop more complex, real-world models.

The example is a trapezoidal channel, dimensions as shown:

  • Top width = 100 m
  • Bottom width = 50 m
  • Depth = 5 m
  • Length of channel = 1,000 m
  • Grade of channel = 1 in 1,000
  • The model domain should have a resolution of 12.5 m across the channel and 25 m along the channel.

Note: Try completing the following steps to create the TUFLOW FV models in this tutorial module. For reference, complete versions of the models can be downloaded from the TUFLOW website: http://www.tuflow.com/FV%20TutorialModel.aspx

Modelling Folder Structure

The first step is to establish a folder structure. For a TUFLOW FV model project called “Trapezoidal_Steady_State_Example”, the folder structure will be:

Module1 Folder Structure.jpg

TUFLOW FV Model Geometry

Map Coverage

  • Data contained within the SMS Map Coverage is used to define the model mesh layout.
  • The first step is to setup the SMS Map coverage. In this coverage the “outline”, or specific points and curves that describe the geometry to be meshed, is defined by the following symbol (located on the bottom left of the SMS Window).1.1.1A.png
  • Before entering data into the Map coverage, the coverage type should be assigned. The coverage type must be “Generic 2D Mesh”. Right click on the coverage label in the explorer bar as shown:


  • The map coverage works in a plan view. Using the “create feature point” button, create the 8 points that define the channel.1.1.1B.png
  • As each feature point is created, use the coordinate boxes in the toolbar above the main display window to specify the precise coordinates (x and y), and elevation value (z). .Module2 Coordinate Boxes.jpg
1 0.0 0.0 0.0
2 0.0 25 -5
3 0.0 75 -5
4 0.0 100 0.0
5 1000 0.0 0.0
6 1000 25 -6
7 1000 75 -6
8 1000 100 0.0

The feature points should then look like:


  • Now use the “Create feature arc” button to join the dots together.


  • Save the SMS Project into the 'Geo' folder. The project should be called 'trap_steady_01.sms'

You have now created the basic map layout that will define the model geometry.

Create Scatter Points

  • Scatter points contain elevation information which will at a later stage be interpolated onto the model mesh.
  • In this example the scatter dataset will be created from the previously created Map Coverage. Do this by selecting “Feature objects” – “Map -> Scatter” from the menu.


  • Make sure you specify the z value source from the “Arc node and vertex elevations” in the dialog box:

TUFLOW FV Module 1 Edit1.jpeg

  • Use the display button to turn on contours in the scatter data module and view the newly created dataset:1.1.2C1.png
  • Select contours, countours method and select colourfill to visualize the z values.

TUFLOW FV Module 1 Edit2.jpeg

Then the shaded z values are then visible:


Note: These steps relating to the scatter point dataset have replaced the often complex steps associated with inputting GIS layers, scatter datasets, etc to create the base topography/bathymetry for the model. The approach demonstrated is fine for a simple test case, but real world applications are often more complex and contain a variety of data sources. This can be done in SMS in a more rigorous manner (discussed in the SMS manuals) but is also done using other software such as GIS and CAD.

Build Polygons

  • Click on the “Map Data” entry in the explorer window to do this.


  • The next step is to build polygons, which is done from the menu “Feature Objects” – “Build Polygons”.


This takes the feature arcs and creates a series of polygons. It is these polygons that we can now individually investigate and specify mesh properties for.

Build The Mesh

  • Now we can build a mesh. To build the mesh, use the menu commands “Feature Objects” – “Map -> 2D Mesh”.


The resulting mesh, as shown. It doesn’t look very good. But it is a mesh! A mesh has been created using 6 triangular elements (pave), connected by the nodes which, in this case, are the 8 points used to define the extents of the trapezoidal channel.


Note in the image that the scatter data set has been “unticked” in the explorer window – this hides the scatter data in the display, which makes the other information easier to see. Also unclick the map data set to better inspect the mesh data information. This model geometry is not good enough. We require a much higher resolution than this. A higher resolution is achieve by updating the information within the map data coverage, creating more vertices and hence more elements.

Note: more vertices along the polygon arcs = higher mesh resolution.

Modify Polygons

  • Click on the “Map Data” entry in the explorer window to make the coverage editable.


  • Using the “select feature polygon” button, double click on each of the polygons.1.1.5A.png

A dialog box will appear with many options. Check out the SMS manual for a better description, or try a few different options and see what happens.


Some of the key options worth noting are:

  • Mesh type:
    • Paving is the classic triangular mesh, where triangles are used to fill the polygon area.
    • Patch fills the polygon area with a patch of quadrilateral (rectangular) elements. There are some limitations to using this mesh type (like having 4 arcs defining the polygon).
  • Bathymetry Type:
    • Scatter Set will use the scatter data we have created in the 'Create Scatter Points' step to set the z values in the mesh
  • Preview Mesh:
    • Use this to see how your mesh design looks for this polygon area.

Along the bottom of the display image is a series of buttons which let you adjust arc lines and the vertices that define them.

  • For this model example we should adopt a resolution of 12.5 m across the channel and 25 m along the channel. Using the “Select Feature Arc” button, select the top arc.1.1.5B.png

Then, adjust the number of vertices (the “Arc options” buttons) to suit the desired mesh resolution. In this instance, there should be 1,000 / 25 - 1 = 39 vertices. Repeat this for the bottom arc.


  • Repeat for the left and right arcs, which will have 25 / 12.5 - 1 = 1 vertices. You may need to use the “zoom” button to assist with arc selection.1.1.5C.png
  • Once this is done, check the “Bathymetry type” to be “scatter set”. This will ensure that the z values previously entered into the scatter data will be interpolated onto the final mesh. For a straight trapezoidal channel such as this, a patch mesh type is the most efficient.


  • Use the “Preview Mesh” to see what the mesh looks like. Use the zoom function to see the finer details.


  • Once happy with the layout the mesh within this specific polygon, repeat with the remaining polygons. The middle polygon has 50 / 12.5 - 1 = 3 vertices across the channel and 1,000 / 25 -1 = 39 vertices along the channel. The lower polygon has the same vertex count as the top polygon. Note that as each polygon is edited, the arc vertices are updated – this highlights how the mesh generator tracks each polygon to ensure that the overall mesh is consistent.
  • Now repeat the steps listed for "Build Polygons" and "Build the Mesh", using the menu commands “Feature Objects” – “Build Polygons” and “Feature Objects” – “Map -> 2D Mesh”, to create the mesh. This time, a reasonable looking mesh should appear.


Linear Elements

There are some final adjustments to be made prior to finishing the mesh creation.

  • The first is to switch the elements to be linear, rather than quadratic. Quadratic elements (that include mid-side nodes) are not used by TUFLOW FV. Click on the "Mesh Data" entry in the explorer window. Press the menu command “Elements” – “Linear <-> Quadratic” to remove the mid-side nodes.


The difference between linear and quadratic can be seen in the mesh display. The quadratic form is the first display below followed by the linear mesh display.

1.1.6B.png 1.1.6C.png

Nodestrings (Boundary Conditions)

The last step is to insert nodestrings. Nodestrings are a string of nodes that can be used to define the location of boundary condition inflows/outflows. For this example, there will be an upstream and a downstream boundary condition applied (ie along the left and right edges of the model domain).

  • Press the “Create nodestring” button 1.1.7.png, then click along the nodes that make up the left edge of the mesh. Nodestrings should all be created from right to left while looking downstream.
  • Repeat this procedure along the right edge of the mesh.

Hint – hold the “shift” button down to select all nodes between first clicked and second clicked nodes.


You have completed the construction of a mesh, congratulations. Resave your SMS project


  • A useful way to review the created mesh is to use the “Rotate” button. This allows you to visualise the mesh in perspective view.1.1.8.png


  • Click File >> Save to save the SMS project 'trap_steady_01.sms'. This will preserve all of the input data used to develop our mesh (in case we wish to make updates in the future).
  • Click File >> Save As. Select the type " 2D Mesh files (*.2dm). Save the file using the name 'trap_steady_01.2dm'. This will become the geometry input file for the TUFLOW FV model.

TUFLOW FV Model Setup

The following example takes the trapezoidal channel created above and sets up, runs and visualises a hydrodynamic simulation. Specifications for the model setup of the trapezoidal channel are as follows:

  • The bed is lined with a coarse concrete; a Manning friction of 0.018
  • There is a constant upstream inflow of 450 m3/s
  • The downstream water level is 2.5 m above the bed

Nodestring Order

Open the 2dm file in a text editor and look for the nodestrings. Do this by searching for “NS” at the start of the line. For the 2dm file which has been crated, the NS lines are as follows:

NS 368 369 287 246 205 164 121 122 -123 1 NS 366 367 247 206 165 124 118 119 -120 2

TUFLOW FV uses the nodestrings as boundaries, with the first nodestring listed being boundary 1, the second nodestring as boundary 2, etc. In this case (by looking at the node list in the 2dm file and comparing to the nodes in SMS), the first nodestring is the upstream boundary (ie – a flow boundary) and the second nodestring is the downstream boundary (ie – a water level boundary).

Don’t panic if the nodes listed in the nodestring are in either have different numbers or are in reverse order to that shown; this doesn’t influence their behaviour. It is however important that each nodestring lists 9 numbers. This is the number of nodes that the nodestring intercepts

Boundary Condition Files

For TUFLOW FV, csv (comma delimited) format files contain boundary condition inputs. In this case, the boundary conditions are very simple because the run is steady state.

The flow boundary (called “steadyQ_01.csv”) should contain the following:

Time Flow
0.0 0.0
1.0 100
2.0 450
6.0 450

Note that the first column (time) is in hours. Note also that there is a warm-up period of 2 hours.

The water level boundary (called “steadyWL_01.csv”) should contain the following:

Time WL
0.0 -3.5
48.0 -3.5

Both files should be placed in the folder “bc”.

Create the TUFLOW FV Control File (FVC)

The TUFLOW FV control file is created via a text editor. Notepad++ or UltraEdit is recommended for this purpose. These software include configuration features which allow for syntax highlighting of TUFLOW FV specific commands. TUFLOW FV models can also be executed directly from the text editors. This configuration information is provided in the following pages:

Often, an fvc file is created from an earlier model or from a template. If using a template then it’s good practice to comment out the irrelevant commands. A “!” at the start of the line means that the line is not read by TUFLOW FV. This allows you to insert comments into your fvc file (this is recommended). To simplify this example only those lines that are relevant to this simulation are shown in the fvc file. For this tutorial example, the file is called “trap_steady_01.fvc”. The fvc file is shown below. A description of each entry is provided.

FVC File Contents

! TUFLOW FV TUTORIAL The first 2 lines are a description of the model simulation. You may also wish to include the initials of the modeller, etc.

 ! Flow along a trapezoidal channel
 ! TIME COMMANDS The time commands include the start and end times (the default time format is Hours). The CFL limit is 1 by default – TUFLOW FV then assigns a timestep at each computational step according to the CFL limit and between the ranges specified in the timestep limits.
start time == 0.0
end time == 6.0
cfl == 1.0
timestep limits == 0.0001, 10.

! MODEL PARAMETERS The model parameters are those that control various physical and numerical processes.

When the stability limits are exceeded (water level first, then velocity), the model is considered to have crashed. Note that the velocity limit here is high – that’s because the velocities along the wetting and drying boundary edges are high.

A Smagorinsky eddy viscosity approach has been specified, with a Smagorinsky factor of 0.2.

stability limits == 10. ,100.
momentum mixing model == Smagorinsky
global horizontal eddy viscosity == 0.2

! GEOMETRY The model geometry is the 2dm created above in this tutorial module.
geometry 2d == ..\geo\trap_steady_01.2dm

 ! MATERIAL PROPERTIES So far, material types haven’t been highlighted. By default, SMS will create elements using a single material type (1). It is this material type that is assigned a bottom roughness of 0.018 (the default friction approach is a Manning’s number).
material == 1
bottom roughness == 0.018
end material

 ! INITIAL CONDITIONS The initial condition is 2.5 m above the bed at the downstream end (ie -3.5 m).
initial water level == -3.5

 ! BOUNDARY CONDITIONS The boundary conditions link the csv files containing the actual flows and water levels to the nodestrings. Nodestring 1 is assigned a flow boundary and nodestring 2 is assigned a water level boundary.
bc == Q, 1, ..\bc\steadyQ_01.csv
bc header == time,flow
Sub-type == 4
end bc

bc == WL, 2, ..\bc\steadyWL_01.csv
bc header == time,WL
end bc

 ! OUTPUT COMMANDS In this instance, a datv format file is specified. This format is easily read into SMS for viewing. The h, v and d mean that outputs files containing water level, velocity and water depth will be created.
output dir == ..\Output\
output == datv
Output Parameters == h,v,d
Output Interval == 600
end output

The TUFLOW FV control file should look similar to the figure below.

TUFLOW FV Simulation File.png


Once you’re happy with the fvc file contents, run TUFLOW FV. Refer to the following link for simulation run options: Running TUFLOW FV
An example batch file (run.bat) has been included in the 'input' folder within the tutorial dataset download. You can run the batch file by double clicking it from Windows Explorer. It will sequentially execute the three models that are included in this tutorial module.

You may find that your simulation has crashed. This has likely occured due to some syntax error in the inputs . See the following link for advice: Common reasons why a model won’t start

Check Results

During the model simulation the result files will be written; one for the water levels (“_H”.dat), one for velocities (“_V.dat”) and another for water depths (“_D.dat”). They will have the same prefix as the fvc file; in this example they will be called:




To view them, start SMS and open the 2dm file. Then, from either the SMS menu or by dragging into the SMS window, open the dat files. There are a range of display options in SMS; the following display shows a longitudinal profile of water depths throughout the simulation. To do this, a feature arc needs to be created in the Map module (the type of this coverage needs to be “Observation”). Then, the “Display” – “Plot wizard” menu is used. See the SMS manual for advice on viewing results files.


Inclusion of Salinity

It is relatively straightforward to include a conservative tracer into the model simulation.

Note: Licensing enabling the TUFLOW FV AD Module is required to model salinity.

The following additional components are required:

FVC File Updates

! TUFLOW FV TUTORIAL Include salinity as a model parameter (the first number = 1), but decoupled from the density simulations (the second number = 0).

! Flow along a trapezoidal channel + AD


include salinity == 1,0

start time == 0.0
end time == 6.0
cfl == 1.0
timestep limits == 0.0001, 10.

! MODEL PARAMETERS The scalar mixing model and diffusivity are specified as model parameters.

stability limits == 10. ,100.
momentum mixing model == Smagorinsky
global horizontal eddy viscosity == 0.2

Scalar mixing model == constant
Global horizontal scalar diffusivity == 1

geometry 2d == ..\geo\quick tutorial.2dm

material == 1
bottom roughness == 0.018
end material

initial water level == -3.5

Initial Salinity == 0 The initial concentration is 0.

! BOUNDARY CONDITIONS An additional column in the boundary condition files is required, specifying the concentration at the boundary. the new boundary condition has been renamed as version 02.

bc == Q, 1, ..\bc\steadyQ_002.csv
bc header == time,flow,Sal
Sub-type == 4
end bc
bc == WL, 2, ..\bc\steadyWL_02.csv
bc header == time,WL,Sal
end bc

bc == QC, 240,55, ..\bc\cellQ_02.csv A new boundary condition (QC) defines a constant inflow into an element (or cell). The numbers 240,55 are the x,y coordinates where the inflow will occur.
bc header == Time,flow,Sal
end bc

! OUTPUT COMMANDS An additional output parameter is specified (Sal).
output dir == ..\Output\
output == datv
Output Parameters == h,v,d,Sal
Output Interval == 600
end output

Update Boundary Condition Files

The updated flow boundary (called “steadyQ_02.csv”) should contain the following:

Time Flow Sal
0.0 0.0 0.0
1.0 100 0.0
2.0 450 0.0
6.0 450 0.0

The water level boundary (called “steadyWL_02.csv”) should contain the following:

Time WL Sal
0.0 0.0 0.0
48.0 -3.5 0.0

The cell inflow boundary (called “cellQ_02.csv”) should contain the following:

Time Flow Sal
0.0 0.0 30.0
1.0 10.0 30.0
2.0 10.0 30.0
6.0 10.0 30.0

View Results

The output file with concentrations will have the extension “_SAL.dat”:


The results view in SMS should look something similar to the following:


Going Further

Model Topography Modification

For modellers with a firm grasp of the basics of modelling, the best way to learn how to setup and run TUFLOW FV is to experiment. In the following example, the mesh has been adjusted to include a “bump” in the centre and a constriction further downstream, which will induce transitions to supercritical flow. Mesh resolution has been increased around these features.

The results are far more interesting using this mesh design. The SMS Map, Scatter and Mesh data associated with this model can be downloaded from the TUFLOW website: http://www.tuflow.com/FV%20TutorialModel.aspx

The model inputs and results have the suffix '03' in their file name.




Note: When viewing model results in SMS it is required that the associated '2dm' file be opened first. Using SMS, skipping this step with either result in:

  • a data load error (if the number of vertices/points/elements in the result file do not match that in the 2dm file); or alternatively
  • the results dataset will load though not be displayed correctly. This display error occurs due to the number of vertices/points/elements in the result file matching the 2dm file, though the spatial location of the vertices/points/elements not matching.

Model Resolution Update

Try doubling the resolution of the model. What happens to the model simulation time when the model resolution is increased to cells with the following dimensions: 6.25 m across the channel and 12.5 m along the channel?

Halving the cell size results in 4 times the number of cells and a halving of the model timestep (required to meet the Courant criteria limits which calculate the model timestep). As such, halving the full model domain resolution results in an 8 fold increase in simulation time. This result highlights one of the benefits in using the TUFLOW FV flexible mesh model structure, where model resolution refinements can be varied spatially (ie. not applied globally over the entire model). This model structure reduces the overall number of computation cells within a model and increases the simulation runtime efficiency.


This section contains a link to some common issues that may occur when progressing through the first module of the TUFLOW FV tutorial model: Common reasons why a model won’t start

For further support please email support@tuflow.com