Visualisation of Tsunami Simulations Adam Wilde BSc (Hons) Computing (Ind) (2005/2006) The candidate confirms that the work submitted is their own and the appropriate credit has been given where reference has been made to the work of others. I understand that failure to attribute material which is obtained from another source may be considered as plagiarism. (Signature of student) _______________________________
66
Embed
Visualisation of Tsunami Simulations Adam Wilde BSc · PDF fileVisualisation of Tsunami ... and producing animations of the wave run-up. i . ... from an existing numerical water wave
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Visualisation of Tsunami Simulations Adam Wilde
BSc (Hons) Computing (Ind) (2005/2006)
The candidate confirms that the work submitted is their own and the appropriate credit has been given where reference has been made to the work of others. I understand that failure to attribute material which is obtained from another source may be considered as plagiarism. (Signature of student) _______________________________
Summary
This project focuses on the use of 3D visualisation and interaction techniques with the aim of
developing informative, flexible, efficient and attractive approaches to displaying water wave
simulations. The water wave simulations will be generated in binary data form, using the existing 2D
numerical wave model OTT-2D but will be transformed into a full screen 3D visualisation that can be
used to explore areas of interest on the water surface and bed topography, whilst simultaneously
displaying water velocity and producing animations of the wave run-up.
i
Acknowledgements To my supervisor, Matthew Hubbard, for explaining the structure of the OTT-2D data files (on more
than one occasion) and also for offering alternative approaches when I felt out of my ‘depth’. To
Leroy, for his time and C++ expertise. My parents, for desperately trying to understand the technical
aspects of the project and to my girlfriend, for keeping me alive when I didn’t have time to cook for
myself.
ii
Table of Contents
Chapter 1 Project Introduction 1.1 Problem Statement …………………………………………………………..… 1 1.2 Objectives ………………………………………………………….………….. 1 1.3 Minimum Requirements……………………………………………………….. 2 1.4 Other Areas to Consider ………………………………………………………. 2 1.5 Deliverables ……………………………………………………………..…….. 3 1.6 Relevance to Degree Programme ……………………………………….…….. 3 1.7 Background Reading ………………………………………………..……….... 4 1.7.1 Existing 3D Graphic Languages and Visualisation Environments … 4 1.7.2 Spatial Data Structures ……………………………………………... 7 1.7.3 Adaptive Mesh Refinement ………………………………………… 10 1.7.4 Existing AMR Visualisation Techniques …………………………... 12 1.7.5 Human-Computer Interactions within 2D/3D Environments ……… 15 1.8 OTT-2D Overview ……………………………………………………………. 16 Chapter 2 Design ………………………………………………………………………… 18 2.1 Requirements . ………………………………………………………………… 18 2.1.1 Ability to Recognise and Handle OTT-2D Output Files …………… 18
2.1.2 Facilitate Internal Storage of Simulation Data Values ……………… 19 2.1.3 Generate Accurate Representations of Wave Data in Mesh Form….. 20 2.1.4 Control Simulation Timing …………………………………………. 21 2.1.5 Allow Simulation Manipulation ………………………………….… 21 2.1.6 Support Cross Platform Operation…………………………………... 22 2.2 Preliminary Design…………………………………………………….……….. 22 2.2.1 Vectors as Dynamic Storage Elements……………………………… 22 2.2.2 Using a Quadtree for Mesh Joining at Different Levels…………….. 23 2.2.3 Lighting and Normals………………………………………………... 24 2.2.4 Creating Timeframes………………………………………………… 25 2.2.5 Using the GLUI Toolkit for Creating Interactive Controls………….. 26 2.3 Hardware Requirements………………………………………………………… 26 2.4 Software Requirements…………………………………………………………. 27
iii
Chapter 3 Implementation…………………………………………………………….… 28 3.1 Methodology………………………………………………………………..…. 28 3.2 Development Plan……………………………………….…………………….. 28 3.3 Development Phases…………………………………………………………… 29 3.4 Description of Methods………………………………………………………... 33 3.5 Solutions to Problems Encountered……………………………………………. 36 3.5.1 Vertex Arrays………………………………………………..………. 36 3.5.2 Vertex Buffer Objects………………………………………….……. 37 3.5.3 Unstructured vs. Structured Output Files………………….…….…… 38 3.5.4 Handling the Unstructured Data Format. …………………………… 38 3.5.5 Using GLUT for Timing. ……………………………..………….…. 39 Chapter 4 Evaluation……………………………………………………………………... 40 4.1 Introduction…………………………………………………………….………. 40
4.2 Evaluation Against Minimum Requirements…………….……….……………. 40 4.3 Heuristic Evaluation……………………………………………………………. 42 4.4 Formative Evaluation. …………………………………………………………. 45 4.5 End User Evaluation……………………………………………………………. 45 4.6 Functionality versus Efficiency. ……………………………….………………. 47 Chapter 5 Conclusion…………………………………………………………..…………. 49 5.1 Successes…………………………………………………………………….…. 49 5.2 Failures…………………………………………………………………….……. 49 5.3 Future Enhancement Possibilities………………………………………………. 49 5.4 Evaluation of Decisions Made……………………………………………….…. 50 5.5 Overall Methodology Evaluation………………………………………………. 50 References………………………………………………………………………………….……. 51 Accompanying Material……………………………………………………..…………………. 54 Appendices………………………………………………………………………………………. 55 Appendix A Personal Reflection…………………………………………..………. 55 Appendix B Initial and Final Project Plan…………………………………………. 57 Appendix C Test Plan…………………………………………………………..…. 59 Appendix D Visualisation User Manual…………………………..………………. 60 Appendix E GLUI Feature List……………………………………………………. 61
iv
1 Project Introduction
1.1 Problem Statement
The aim of the project is to construct and use suitable data structures and algorithms to generate 3D
visualisations of the output from an existing numerical water wave model OTT-2D written in Fortran
90 Code. The existing code generates simple but adaptive simulations of water waves in the form of
numeric data output files; however the aim of the project is to produce an efficient and clear 3D
representation of the flow of water alongside the corresponding bed topography. The visualisations
should be informative, flexible, efficient and attractive and have the ability to run on various
platforms. It should make good use of HCI techniques to provide the user with simple, straight-
forward, yet powerful methods of manipulating the viewpoint and progress of the simulation.
1.2 Objectives
The current 2D numerical model provides accurate simulations of wave transformation, run-up,
overtopping and regeneration. The result of the simulation is a series of data files, containing arrays of
water depth, height of sea bed and flow velocity at each grid point throughout the period of the
simulation. The simulation can run across grids of various sizes and generate several finer scale grids
of varying range using an adaptive mesh refinement technique (AMR). The AMR allows for a high
level of efficiency, while providing greater detail (more points of recordable data) and increased
model adaptability, as the overlaid finer meshes are only applied to parts of the simulation that require
higher levels of resolution (such as a region of moving shoreline). While the numerical wave model
provides very accurate output data it requires a suitable form of visualisation for the end user. The
objectives of the project are therefore, to investigate appropriate techniques for visualising the
numerical wave model data in a 3D environment and allow several methods for manipulating and
controlling the 3D representation. The objectives of this project are not to explore the means by which
AMR techniques should be developed, but rather how AMR data scenarios can and should be
effectively visualised.
1
1.3 Minimum Requirements
The requirements below define the minimum that must be produced in order to deliver a solution to
the problem:
Produce a method of processing and storing wave run-up data from external data files
Produce an algorithm to generate efficient and clear step by step animations of the wave
run up
Employ AMR within the 3D visualisation of the wave and bed topography
Employ techniques to manipulate the 3D wave visualisation such as
zoom/pan/rotate/colouring
Regular feedback from the author of the numerical wave model will result in a 3D visualisation that is
tailored exactly to the author’s requirements and any further enhancements or modifications can be
made as are appropriate.
1.4 Other Areas to Consider
Once minimum requirements have been met, their will be further scope to add:
The ability to display flow characteristic calculations (velocity, height, etc.) at any given
point on the water surface
The functionality to load a selection of bed topography files, to change/enhance the
animation of the wave run-up
The ability to control animation speed, as well as add support for pause/fast forward and
rewind
The ability to control the appearance of the mesh, with choices of wireframe surface,
monotone or multicoloured (dependent on wave height/velocity)
Incorporate use of NVIDIA Cg rendering techniques to speed up simulation/visualisation.
(Only available for recent graphics cards; DirectX 9.0c compatible)
2
1.5 Deliverables
Final project deliverables will be:
Final solution in the form of one or more pieces of code and all necessary libraries
required to run the code and visualisation
Setup and operating instructions for the visualisation
1.6 Relevance to Degree Programme
This project will span a wide selection of topics that have been covered in university modules
including theories studied in lectures and practical skills learnt during coursework assignments. The
project will look mainly towards the computer graphics modules studied in the second and third years
but will also cover human computer interaction techniques from the GI11 and GI32 modules, software
methodology and management from the SE22 module and mathematical/programming experience
gained from the MA12, SO13 and SE21 modules.
3
4
1.7 Background Reading
1.7.1 Existing 3D Graphical Languages and Visualisation Environments
The choices of appropriate graphical languages and visualisation packages for this project are heavily
dependent on the platform and applications already available across the Leeds SoC computer network.
With this in mind, viable options are the MathWorks Inc. Matlab package, Iris Explorer and OpenGL.
Matlab is a data manipulation environment and a core programming language that includes a suite of
analytical tools and visualisation techniques, and allows for the use of existing functions and user-
defined programs. It provides an interface to allow matrix manipulation, algorithm implementation
and user interfaces as well as many other functions and can run across a wide range of operating
systems. It is a proprietary piece of software costing as much as $2000 per license for commercial use
[MathWorks, 2006].
Iris Explorer is currently developed and released through the software house Numerical Algorithms
Group (NAG). It was originally designed and developed by SGI, the people responsible for OpenGL
and runs on a collection of OpenGL, Open Inventor and ImageVision libraries as well as NAG’s own
numerical libraries. The aim of Iris Explorer is to provide a powerful visual programming
environment for 3D data visualisation, animation and manipulation. Visualisations are built up
through the selection of existing modules within the application. This removes the requirement for
any coding, although custom modules can be built in the FORTRAN or C languages. It is currently
available across a large number of platforms such as Microsoft Windows and Linux, however the cost
of purchasing the software is approximately £900 (for academic purposes) [NAG, 2006].
OpenGL is an open specification 3D graphics and modelling library that is extremely portable and
very fast to implement [Wright, 2000]. It offers an application program interface (API) for defining
2D and 3D objects rather than being an actual programming language and must therefore be used in
conjunction with a programming language such as c or C++. Initially developed by Silicon Graphics,
it allows any computer user to download the required libraries and create an application that will run
cross platform providing the user has an OpenGL specification graphics card. The majority of this off
the shelf hardware has been OpenGL compliant for a number of years, as end users have strived for
business applications and games that make use of 3D graphics [Wright, 2000]. It is widely used in
CAD, virtual reality, scientific visualisation, information visualisation and video game development
[SGI, 2006].
A comparison of the Matlab, Iris Explorer and OpenGL software follows:
Yes
OpenGL Matlab Iris Explorer
Available in SOC Yes Yes
Prior Experience No – therefore steep learning
curve
No – therefore steep learning curve, although Iris Explorer does implement OpenGL so some
features will be familiar Yes - GI21 and GI31 computing modules.
Cost to install outside of the SOC
$100 academic license, $2000 commercial use [MathWorks,
2006]. Therefore costly to install outside of SOC
Approximately £900 for academic purposes [NAG, 2006]
End users are free from licensing [SGI, 2006]. Easily available to anyone using any platform.
Cross Platform Supported on Linux, Mac OSX,
Solaris and Windows [MathWorks, 2006].
Supported on Apple Mac, UNIX, IBM RISC, Linux, Windows, Solaris and Silicon Graphics IRIX although it is only available on the SOC
Linux system [NAG, 2006].
Supported on UNIX is standard on Windows 95/98/2000/NT and MacOS PC. OpenGL runs on every major operating system including Mac OS, OS/2, UNIX, Windows 95/98,
Windows 2000, Windows NT, Linux, OPENStep, and BeOS. It is possible to implement OpenGL in Ada, C, C++, Fortran,
Python, Perl and Java [SGI, 2006].
Mouse and keyboard functionality is offered by the GLUT libraries and 3D party toolkits offer screen decoration in the
form of buttons, sliders, arcballs, checkboxes etc.
Visualisation Features
Colour control, scaling, rotation and timing
Colour control, scaling, rotation and timing
Almost endless. Colour control, transparency, texture mapping, lighting properties, material properties,
Point and click GUI interface. The work area has standard drop
down menus.
Point and click interface. The render window has a standard drop down menu to which items can be added/removed. Decoration can also be enabled to provide thumbwheels, sliders and
push buttons accessible via keyboard and mouse. Widgets provide a GUI during
development
Figure 1.7.1 Table of comparison for Matlab, Iris Explorer and OpenGL applications.
In a comparison with Iris Explorer and Matlab, OpenGL stands out as offering the most in terms of
visualisation features and the best support for cross platform operations. Compared to Matlab alone, it
offers more interactive features and is on a par with Iris Explorer with this respect. When comparing
the advantages and disadvantages of the three software alternatives, OpenGL makes the most viable
argument as the platform on which to base the visualisation project, not only in terms of
compatibility, availability and features but also in the fact that prior knowledge and experience of
using it, already exists. On a C++ foundation, the OpenGL graphical API and GLUT libraries make a
sound proposal.
GLUT and MESA
GLUT (OpenGL Utility Toolkit) is a windows system independent library of graphic functions that
implements simple window management for use with OpenGL. As the GLUT controls the window
management, menu management, call-back registration, colour variation, object drawing, and
initialisation, it makes learning OpenGL considerably easier [Skillsoft, 2000]. The latest version,
allows the user to create a single application in OpenGL that will work on Windows, Mac and Linux
machines without any need to write operating system specific code. The latest version of GLUT,
developed by Mark J. Kilgard, is not in the public domain, but is freely distributable without licensing
fees.[SGI, 2006]. However, Kilgard does state that “GLUT is not a full-featured toolkit so large
applications requiring sophisticated user interfaces are better off using native window system
toolkits.” [SGI, 2006]. This is unlikely to cause a problem as it is intended that a 3rd party interface
library will be used to create an appropriate user interface.
Mesa provides an open-source implementation of the OpenGL specification [Paul, 2006]. It is similar
to GLUT in that it provides an API, sitting directly above the OpenGL syntax and offers portability
for OpenGL applications to run on systems that have no other OpenGL solution.
On the face of it, GLUT and MESA are both well written and popular OpenGL toolkits; however the
availability of GLUT is more widespread in university and at home, therefore making it the choice for
this project.
6
1.7.2 Spatial Data Structures.
The organisation of spatial data structures, is usually hierarchical and as such is nested and recursive
in nature. The advantage of using a hierarchal structure, is that generally, queries become much faster,
with an improvement from O(n) to O(log n) [Moller, 2002].
Quadtree
The quadtree is a hierarchical data model that recursively partitions a two dimensional space into four
quadrants. The root node of the tree represents the complete domain and each node of the tree
represents a uniform subdivision of that domain. The quadtree gets it name from the fact that it always
divides a parent node into 4 smaller but equal child nodes, that each represent a quarter of the space of
their parent node [Figure 1.7.2.1]. As division is applied, child nodes become parent nodes, receiving
4 more children and they in turn become parents until the desired depth/level of partition is obtained.
There are several different forms of quadtree in use in a variety of situations. The region quadtree is
typically used to recursively subdivide a collection of objects into quadrants, until each object is
located within its own cell (tree node). With enough levels of recursion, each object will find itself
within its own cell and will therefore not be sharing a tree node.
Figure 1.7.2.1. Quadtree Example with 5 levels of refinement. (Lawlor, 2001).
Quadtrees are regular in nature, meaning that they deal with partitioning data in a uniform manner.
While this can be more restrictive it can also be far more efficient due to the predictable way in which
they handle data. The quadtree data structure was originally proposed by Raphael Finkel and J.L.
Bentley [Finkel, 1974] and has become a very popular method for image representation, spatial
indexing, efficient collision detection in two dimensions, view frustum culling of terrain data and
storage of sparse data [Tremblay, 2004].
7
Octree
An octree is fundamentally the same as a quadtree but works in a three dimensional environment.
Each parent node has eight child nodes that represent a refinement in space of the x, y and z
dimensions. Each leaf node therefore becomes an octant of its parent node and presents a cuboid
shape in physical space [Philips, 2002]. In an ideal dataset of equally distributed objects, an octree
would provide a balanced data structure. In reality, a clustering of data will produce a very un-
balanced tree, as uniform partitions would require a large recursion to divide the dataset up. A k-d tree
attempts to solve this problem by dividing space un-evenly. [Tremblay, 2004].
Figure 1.7.2.2. Octree hierarchy. Adapted from [Lachance, 2005].
BSP Tree
A Binary Space Partitioning Tree Data Structure uses arbitrary splitting planes to recursively sub
divide regions of the domain. They exist in two noticeably different forms, axis-aligned and polygon-
aligned, the difference being that the former makes use of bounding boxes within the scene, to equally
divide (or not) space depending upon the algorithms involved, and the latter, choosing to use edges
from the shapes within the scene to generate splitting planes [Haines, 2002]. Both approaches are
undertaken in a recursive manner, gradually dividing up the scene into smaller and smaller
compartments until the desired level of detail is achieved.
To store the data on each side of the binary tree, the partitioning algorithm assigns the left-hand leaf
nodes as negative and the right-hand leaf node as positive. Once an object within the scene has been
chosen as the basis of the splitting plane, all objects to the positive side of the plane are placed in the
positive side of the tree (the right-hand side).
8
Figure 1.7.2.3. BSP splitting planes and associated tree structure [Philips, 2002].
All the items appearing on the negative side of the plane are placed in the negative side of the tree (the
left-hand side). The positive and negative sides of the plane are dictated by the positioning of a
control within the domain, with the positive side being closest to the control and the negative side,
further away [Figure 1.7.2.3]. In computer games the control would be the camera (player). Where a
non-uniform item is chosen as the splitting plane, the direction and location of the plane is determined
by finding the shortest vector from plane to item boundary [Figure 1.7.2.4]. The item can then either
be split in two, with one half belonging to the positive side of the tree and the other to the negative, or
for simplicity (at the expense of performance) ,the entire item can be placed in both the positive and
negative side of the tree.
Figure 1.7.2.4. Positioning the splitting boundary [Philips, 2002].
Binary Space Partitioning Trees can be employed in more than one dimension of space if required but
usually quadtrees and octrees are preferred for two dimensional and three dimensional subdivision
due to the complexity of keeping track of splitting planes and their vectors in 3D dimensions
[Tremblay, 2004].
9
k-d tree
A k-d tree is a form of BSP tree that uses splitting planes perpendicular to the x, y or z axis. The ‘k’ in
k-d tree refers to the number of dimensions that the data structure is deployed in. A 1d-tree would deal
with splitting the area along just one axis. A k-d tree provides a balanced option to using a quadtree or
octree, as it divides space unevenly in such a way that one half of the tree holds as many objects as the
other half [Tremblay, 2004].
Conclusion
The construction of most spatial data structures is expensive, and is usually done as a pre-process
although incremental updates are possible in real time [Haines, 2002]. This is not such a disadvantage
if loading times aren’t crucial, as once the tree has been set up, the performance gains can be very
impressive. The major use of spatial data structures is in the games industry, where their use in culling
and collision detection allows for higher FPS speeds and finer detailing [Tremblay, 2004].
From the 4 data structures discussed, the quadtree displays the best attributes for use in an Adaptive
mesh refinement simulation and in storing and processing the OTT-2D data. The reason for this
choice is that the quadtree firstly matches the 2D state of the OTT-2D and secondly, is very similar to
the way in which the model stores wave data for each mesh refinement. Constructed from recursively
quartering cells into equally sized squares, it is ideally suited to the Cartesian mesh structure of the
OTT-2D model where each mesh cell is presented as a quad.
1.7.3 Adaptive Mesh Refinement
Adaptive mesh refinement (AMR) is a computational technique for improving the processing and
storage efficiency of numerical simulations. Refinements in both space and time, to selected regions
of the computational domain allow for higher detailing of important and interesting features, while
less interesting parts are left at lower resolution. This approach offers more efficiency than drawing
the entire domain at high resolution as the processor is required to do less work. So, for a small
increase in processing power over the requirements for a coarse simulation, highly refined proportions
of the domain are possible.
10
Figure 1.7.2.5 AMR with 3 levels of refinement [Quirk, 1994]
Adaptive Mesh refinement was first discussed in a series of papers [Berger, 1984. Berger, 1989] in
which, an algorithm for local adaptive mesh refinement was developed to achieve dynamic gridding.
The algorithm starts with “a coarsely resolved base-level regular Cartesian grid” and “progressively
calculates individual grid cells that require refinement” [Berger, 1984]. The criteria for choosing
higher refinement, can either be user-supplied (refine cells where value x is greater than y) or based
on a numerical analysis method such as Richardson Extrapolation [Israel, 2002], that gives acceptable
approximations as to where high detail will occur. Cells which are marked for refinement are then
processed in more detail and the resulting higher resolution mesh is overlaid onto the base grid. A
correction procedure is implemented to check that no two meshes of similar refinement level overlap
or that no two different levels of refinement share boundaries if they differ by more than 1 level of
refinement. This process is repeated, so that the finer mesh from the previous progression now
becomes the base grid on which refinement requirements are calculated. Where more detail is
required, an extra refinement will overlay the previous resolution of mesh.
The Berger Oliver Method
The Berger Oliver Method of adaptive mesh refinement differs in comparison to usual unstructured
adaptive methods in the way it picks and handles cell refinement. Instead of replacing single cells
with finer ones, the algorithm proposed by Berger and Olive, utilises a patch-wise algorithm, whereby
cells flagged for refinement are clustered into rectangular sections ready for processing. [Berger,
1984]
11
Once the finer cell values have been calculated, interpolation functions are used to transfer the values
to the coarse grid. Cell values on the coarse grid are covered by the finer mesh and overwritten with
averaged fine grid values. The resulting extra work is “usually negligible compared to the
computational costs for integrating the superimposed refinement grids” [Berger, 1984]
One of the areas in which AMR is predominately utilised, is in astrophysical simulations and image
manipulation, an example of which can be seen in the collapsing giant molecular cloud core
simulations of Klein et al. AMR techniques allowed for a reduction in resolution of 131,072 cells
compared to 1015 cells in a uniform grid [Klein, 2004].
The advantages of AMR can be summarised as the following:
• Increased computational savings compared to the majority of static grid approaches.
• Increased storage savings over a static grid approach, therefore reducing processing
requirements.
• Control of grid refinement and resolution when compared to the fixed resolution of a static
grid approach.
AMR has the disadvantage of being significantly more complicated and therefore more time
consuming to develop in applications when compared to the algorithms and data structures used to
create standard uniform meshes. Intricate and complex data structures required to fulfil AMR, such as
Quadtrees and Octrees are not available as standard classes in all object orientated languages and as
such must be coded from scratch (the Java SDK does supply classes but they are not available in
C++).
1.7.4 Existing AMR Visualisation Techniques.
The following projects are examples of existing visualisations that make use of AMR techniques
DAGH (Distributed Adaptive Grid Hierarchy)
DAGH is a data-management infrastructure that provides a framework for solving systems of partial
differential equations with adaptive methods [Browne, 2006]. Currently in use at the Universities of
Texas and Rutgers (USA), it has been used to implement reservoir simulations, numerical relativity
and geophysical modelling. It is currently possible to interact with the DAGH toolkit using the
FORTRAN 77, FORTRAN 99 and C++ languages. The DAGH tutorial [Browne, 2006] currently has
listed the following features that are provided by the software.
• Distributed dynamic data-structures for Parallel Hierarchical AMR
12
• Transparent access to scalable distributed dynamic Arrays/Grids/Grid-Hierarchies
• Multigrid/Line-Multigrid support within AMR
• Shadow grid hierarchy for on-the-fly error estimation
• Automatic dynamic partitioning and Load distribution
• Scalability, Portability, Performance
It is clear that the system incorporates AMR techniques similar to those in the OTT-2D model and
with the aim of providing high resolution modelling to problems while keeping processing power to a
minimum. It is interesting to see that the model uses parallel processing for extra performance boosts
and shares some of the requirements expected of the OTT-2D visualisation such as portability and
scalability. While a nice feature, it is considered out of scope to add parallel processing functionality
to the OTT-2D visualisation due to the complexities involved and the developer’s lack of experience
in this area.
ENZO
Enzo provides cosmological simulation code that utilises a structured Adaptive Mesh Refinement
algorithm to solve a wide range of astrophysical and cosmological problems. It is freely available to
download from the Enzo Resource webpages [Bryan, 2006] and has various achievements including,
responsibility for the world's largest simulation of the early universe [Bryan, 2006] and several front
page articles in National Geographic and Physics World magazine. While Enzo provides purely the
AMR code, there are several visualisation modules available to use. One of the most popular is
Jacques [Figure 1.7.4.1] which provides several levels of control over the simulation data.
13
Figure 1.7.4.1. Enzo simulation running on Jacques visualisation interface [Abel, 2006]
Jacques [Abel, 2006] presents a clean and uncluttered user interface that is built upon the IDL toolkit
but is very similar to some of the OpenGL interface packages available to download [Section 1.7.5].
The Jacques interface helps to demonstrate the kind of manipulation tools that users of AMR
simulations are likely to require and makes a good basis on which to design the OTT-2D visualisation.
MATLAB
The author of the OTT-2D code [Hubbard, 2002] has currently implemented a single refinement mesh
visualisation within Matlab. At present the system only utilises one of the OTT-2D output files and
must be re-loaded each time to create a step through of the simulation. The visualisation displays only
the water surface behaviour and the coarsest level of refinement but is a good starting point on which
to base the new OTT-2D simulation.
14
1.7.5 Human-Computer Interactions within 2D/3D Environments
Throughout the project, the aim will be to create and provide visualisation techniques that deliver the
most appropriate and useful solutions to the end user. Feedback from the project supervisor and
author of the numerical wave model will help to guide the direction of design and implementation, in
areas such as efficiency and display requirements.
Initial thoughts during the early design phase, include a heads up display of animation controls,
allowing the visualisation speed and time parameters to be adjusted. With the provision of
pause/resume and rewind, the user will be able to revisit key scenes in the visualisation without
having to wait for completion of the sequence and performing a restart. The user should also have the
opportunity to explore the visualisation in a truly three dimensional aspect. To provide this, the heads
up display of controls could include options for zooming in/out/panning and clockwise/anti-clockwise
rotation. Finally the visualisation should provide some means of controlling lighting and colours, as
well as surface textures for the water, land and sea bed.
All aspects of lighting can be controlled within the visualisation using various OpenGL commands.
Basic flat surface colours can be manipulated to appear three dimensional through the use of ambient,
diffuse and specular highlighting. These properties typically control how light is reflected and
refracted onto and around a scene. Material shininess can be controlled and the type and position of
lighting can be altered. Multiply light sources are possible. Bilinear/trilinear and anisotropic filtering
can be used as required to smooth and accurately shade the 3D scene. Texture mapping is also a
possibility but will probably not be used due to performance implications and the likelihood of detail
masking.
Timing controls within the visualisation will be more difficult to implement. One approach could be
to count FPS (frames per second) and implement logic into the generation algorithm to control how
many iterations of the mesh are produced each second. Raising or lowering this value would speed
up/slow down the visualisation and could produce a pause effect. Using a FPS calculator will also be
a good solution to unify display generation (time to process and display each mesh implementation)
across different platforms and architectures.
GLUI
The GLUI toolkit offers an open source GUI library in the C++ language that can be used to quickly
build graphical user interfaces with interactive controls [Rademacher, 2006]. GLUI is built on top and
directly links to the GLUT libraries which mean it is platform independent and will operate on any
machine that supports GLUT. It relies on GLUT to handle all system-dependent issues, such as
window and mouse management so it is required that the GLUT libraries are present on the system to
15
in order to make use of GLUI. User interface features within the toolkit include the ability to add a
number of interface windows, the addition of interactive radio buttons, checkboxes, buttons and
spinners and ‘live variables’, where values linked to the interface controls are automatically updated
when the state of the control changes [Rademacher, 2006].
Figure 1.7.5.1. Example GLUI interface [Rademacher, 2006]
GLUI is known to be supported by the SOC windows machines and can be stalled on the Linux
computers without the need for administration privileges. A complete listing of features supported by
GLUI are available in [Appendix E].
1.8 OTT-2D Overview
The OTT-2D numerical model is part of a suite of numerical models ANEMONE, developed for HR
Wallingford, and funded by the UK Ministry of Agriculture, Fisheries and Food, and is intended for
use in the application of coastal engineering for predicting hazardous wave run-up and overtopping on
coastal structures. The model can “accurately model complex water motions in the nearshore region”,
something that existing linear models do poorly. OTT-2D can also overcome the simple wave and
beach profile selection limitations, of earlier empirical tools such as the flume and basin experiments
[De Waal, 1992] and the Manual on the Use of Rock on Coastal and Shoreline Engineering [MAN,
1991] by modelling complex wave behaviour without the need for flume tests. The 2D model (2D +1
in the fact that it models two directions of propagation, cross-shore and alongshore, and the element
of time) shares the fact that it is predominately based on nonlinear shallow water equations (NLSW)
with existing 1D models [Dodd, 1998] and [Titov, 1995]. However, it improves on 1D models by
offering simulations of “overtopping and regeneration by obliquely incident and multi-directional
waves over alongshore-inhomogeneous sea walls and complex, submerged or surface-piercing
features” [Hubbard, 2002]. To tackle the increased computational requirements of 2D over 1D
simulations, the model employs finite volume techniques and an adaptive Cartesian AMR algorithm.
16
Finite volume techniques allow the domain to be divided into a number of cells, where, in the case of
OTT-2D, the values of interest are typically located at the centre of the cell. Over time, AMR is then
employed to adaptively control the number of cells, using finer resolutions of grids where necessary
and as a result creating large computational savings. Within OTT-2D, increases in speed of 10 fold
are obtainable, [Hubbard, 2002] without any loss of accuracy when compared to a uniform mesh
displaying the same level of detail. The Adaptive Mesh Refinement algorithm used in OTT-2D was
developed by [Quirk, 1991] and works by refining with higher resolution, areas of the domain that
require more accuracy. It then calculates data values for the entire domain by using the values stored
in the finest mesh levels. The model has been extensively tested and in the majority of cases has
Titov, V.V., Synolakis, C.E., (1995).Modelling of breaking and non-breaking long-wave evolution
and run-up using VTCS-2. A.S.C.E J. Waterw. Port Coast. Ocean Eng. 121 (6), 308-316.
Titov, V.V., Synolakis, C.E., (1998). Numerical modelling of 3D long wave run-up. ASCE J. Waterw.
Port Coast. Ocean Eng. 124 (4), 157-171.
Tremblay, C., (2004). Chapter 16 - Space Partitioning: Cleaning Your Room, Mathematics for Game
Developers. Course Technology.
Wright R.S., Sweet, M., (2000). OpenGL SuperBible, Second Edition. Waite Group Press.
53
Accompanying Material A CD-ROM containing the visualisation user manual, several test run output files and the project
executables, libraries and source code, is available for Matthew Hubbard (School of Computing,
University of Leeds, UK).
Online images and videos of the simulations are available at:
www.personal.leeds.ac.uk/~scs2atw/fyp/
54
Appendices Appendix A Personal Reflection Throughout the course of this project, I have had the chance to show intuitiveness and demonstrate
initiative in tasks that proved to be both academically challenging and rewarding. It has offered me
the opportunity to undertake an individual project on a scale of which I will probably never again be
able to attempt and demonstrates the accumulation of 4 hard years study for a Computing Degree at
Leeds University. Researching the topics and building the final solution for this report has been an
enjoyable although at times frustrating, experience, that I hope I can look back on for inspiration and
support in my future career.
Over the course of the project, I feel that there have been many lessons learnt, two of the most
important being, the lack of a diary to make notes at convenient times and spending too much time on
the programming element of the project and neglecting the written report early on. I would there fore
suggest:
Keep a diary
Unfortunately this was something that I didn’t thing to use until the well into the implementation
stages of the project. Many a flash of inspiration was forgotten, as my memory tried to cope with
confusing theories and formulae. My advice would be to buy a small diary or pad and carry it around
with you at all times. There is nothing worse than knowing you had the answer but now, you just can’t
quite remember it.
Do not get carried away with the programming side of the project.
Everybody wants to build the latest and greatest, but remember, no matter how good it is it will only
get you a maximum of 20 out of 100 for the entire report. I fell into this trap, hurried trying to cram in
more and more improvements when really I should have been concentrating on the report.
Other helpful suggestions that I think people should consider before undertaking a project are:
Pick a subject you will enjoy.
If you don’t pick a subject you have a personal interest or feel particularly attracted to, then it is
unlikely that you will show enough commitment. When the deadlines start to approach and you
suddenly realise how much work is left, will you still have enough interest to stay up late working to
get it done?
55
Respect the people that offer you help.
Do not go looking for help and expect answers straight away. Nobody is going to sit and code your
project for you and people will be unwilling to help at all if you don’t show that you have at least tried
to solve or understand the problem. Leaving it late in the day to seek help with problems is also a bad
idea. Remember that if people offer to help you will have to patient. If they are spending their free
time to help you, then it is courteous to allow them to do it in their own time and not to be rushed by
you.
Behave professionally when dealing with the client
If you undertake a project that requires regular communication with a client, then remember to be
professional and polite at all times. This is an excellent opportunity to experience the interactions
between client and consultant, similar to that of a real company. Remember that the client will know
you are a student but won’t necessarily need to be reminded with scruffy clothes or lack of
punctuality. In the real world of work, you won’t keep clients for long if you show disrespect by
turning up late or not delivering work to schedule.
56
Appendix B Initial project plan:
57
Final project plan:
58
Appendix C Test Plan (Abridged).
A short section of the test plan:
Test Case Outcome Pass/Fail Fixed
Correct output file is found?
Application finds the first OTT-2D file and loads it correctly
Pass
Fixed – Extra 0 character found in input stream.
Correct sequence of files is found?
Application does not load OTT-2D files in correct sequence
Fail – Loads first 9 files only
Only loads files that are available, no matter how many are requested?
Application only loads the files that are available. User is alerted that files requested do not exist if they aren’t available in the immediate directory
Pass
Displays error message when incorrect number of files are loaded?
Correctly displays an error message informing the user that the number of files they have entered is incorrect.
Pass
Application loads full screen? Application loads full screen Pass
‘Exit’ button terminates application on single press?
Application terminated on pressing ‘Exit’ Button Pass
Scene rotation occurs when mouse button held down?
Scene only rotates when mouse button is not pressed. Fail
glutPassiveFunc replaced with glutMotionFunc
Scene is scaled appropriately on a widescreen display?
No, scene is stretched horizontally. Fail No fix implemented
Scene rotation is not limited to 360 degrees
Scene rotation goes beyond 360 degrees. Pass
59
Appendix D Visualisation User Manual (Windows)
Requirements:
• The GLUT libraries are installed on your system. If not, copy the file glui32.dll from the CD-
ROM and place in your system directory
$:\windows\system\ (where $ is your primary drive).
GLUT is already installed on the SOC Linux and Windows machines
• Unstructured output files present in same directory as mesh.exe executable
To Run:
• Simply double click the mesh.exe file and enter the number of output files to be processed
when prompted. After loading the files, the visualisation will load up as full screen.
Functionality:
• To run the simulation press the ‘Run’ button at the top right of the toolbar.
• To slow down and speed up the simulation use the increment/decrement slider (This only
works before and after the simulation has been run and not during!)
• To rotate the scene, press and hold the left mouse button and then move the mouse to control
the rotation. Optionally you can use the arcball rotation control on the toolbar.
• Scale the visualisation by click and dragging over the scale button
• Position the visualisation by click and dragging over the position button
• Pan the visualisation by click and dragging over the pan button
• Add or remove, seabed, water surface, transparent water and velocity vectors by sing the
check boxes.
• Convert to wireframe and anti-aliased wireframe by using the checkboxes provided.
Quit
• The visualisation can be terminated at any time by selecting the ‘Quit’ button.
60
Appendix E GLUI feature list
The following is a complete list of the GLUI features, taken directly from the GLUI website [##].
• Complete integration with GLUT toolkit
• Simple creation of a new user interface window with a single line of code
• Support for multiple user interface windows
• Standard user interface controls such as:
Buttons
Checkboxes for Boolean variables
Radio Buttons for mutually-exclusive options
Editable text boxes for inputting text, integers, and floating-point values
Spinners for interactively manipulating integer and floating-point values
Static text fields
Panels for grouping sets of controls
Separator lines to help visually organize groups of controls
• Controls can generate call-backs when their values change
• Variables can be linked to controls and automatically updated when the value of the control
changes
• ("live variables")
• Controls can be automatically synchronized to reflect changes in live variables
• Controls can trigger GLUT redisplay events when their values change