|
Tsunami Project Lab
|
Namespaces | |
| namespace | io |
| namespace | patches |
| namespace | setups |
| namespace | solvers |
Typedefs | |
| typedef std::size_t | t_idx |
| integral type for cell-ids, pointer arithmetic, etc. | |
| typedef float | t_real |
| floating point type | |
Variables | |
| t_real constexpr | g = 9.80665 |
| gravity constant (9.80665 m/s^2) | |
| t_real constexpr | gSqrt = 3.131557121 |
| square root of gravity | |
Constants / typedefs used throughout the code.
IO-routines for writing a snapshot as Comma Separated Values (CSV).
IO-routines for reading/writing simulation data as netCDF files (assignment 5: large data input/output).
Output side: the constructor creates one COARDS-conforming netCDF file, defines the (time, y, x) dimension layout with time as the unlimited record dimension, writes the coordinate variables and the (time-independent) bathymetry once. Each call to writeTimeStep() appends one record (height, momentum_x, momentum_y at the requested simulation time). The destructor closes the file.
Input side (added in 5.2): reads the (x, y, z) variables of an external netCDF file (e.g. GEBCO bathymetry, earthquake displacement) and exposes the values as a flat array plus a nearest-neighbor lookup.
Ghost cells are not written: callers pass the interior origin and a row stride; the writer copies the interior nx * ny cells into a contiguous slab for each record.
Time-series sampling at user-specified observation points (assignment 4.2).
A station has a name and a world-space (x, y) coordinate. The Stations class parses an XML config (one config per simulation), pins each station to its containing cell, and writes one CSV file per station as the simulation advances. All stations share a common time-based output frequency in seconds.
See Stations-Guide.md in the project root for the XML schema and CLI usage.
Base class of the wave propagation patches.
One-dimensional wave propagation patch.
Two-dimensional wave propagation patch (assignment 4.1).
Implements the unsplit donor-cell method (LeVeque, FVM 2002, ch. 21 — multidimensional systems, donor-cell upwind without transverse correction) for the 2d shallow water equations. In a single update step the cell Q_{i,j}^n receives contributions from all four surrounding edges:
Q_{i,j}^{n+1} = Q_{i,j}^n
Each edge re-uses the 1d f-wave Riemann solver T:
Memory layout (row-major): total cells = (m_nx + 2) * (m_ny + 2) stride = m_nx + 2 (= y-direction stride; x is stride-1) ghost rows/columns occupy i ∈ {0, m_nx+1}, j ∈ {0, m_ny+1} interior cell (ix, iy) ∈ [0, m_nx-1] × [0, m_ny-1] sits at memory index (ix+1) + (iy+1)*stride.
Two-dimensional artificial tsunami setup (assignment 5.2 task 1).
The setup mimics the structure of an earthquake-driven displacement scenario without reading any external data: bathymetry is a flat pool at b_in = -100 m and a hard-coded displacement d(x, y) is applied within a 1 km x 1 km square centred on the domain.
Displacement (relative to the centre x_c, y_c): x' = x - x_c, y' = y - y_c d(x, y) = 5 * f(x') * g(y') for |x'| <= 500 and |y'| <= 500 d(x, y) = 0 otherwise f(x') = sin( (x'/500 + 1) * pi ) g(y') = -(y'/500)^2 + 1
Initial values (with delta = 20 m, matching the 1d tsunami setup): h = max(-b_in, delta) = 100 m everywhere (b_in = -100 < 0) hu = hv = 0 b = min(b_in, -delta) + d = -100 + d
The course spec uses the domain [-5000, +5000]^2 with the centre at the origin; main.cpp instantiates this setup on the equivalent [0, 10000]^2 domain with the centre at (5000, 5000).
Restart setup driven by a netCDF checkpoint (assignment 7.1 task 2).
Loads a checkpoint file written by io::NetCdf::writeCheckpoint and exposes its (single, latest) state through the standard Setup interface so main.cpp can initialise the wave-propagation patch from it exactly like any other setup. The four fields are sampled with nearest-neighbor lookup on the recovered cell-centre grid.
Beyond the Setup interface the class exposes the scalar restart metadata (simulation time, time-step counter, constant dt) and the recovered geometry (cell size, interior extents) so the caller can continue the time loop where the interrupted run left off.
Two-dimensional circular dam break setup (assignment 4.1).
Initial condition (with the dam centred at (m_centerX, m_centerY)): [h, hu, hv]^T = [m_heightInside, 0, 0]^T if r < m_damRadius [h, hu, hv]^T = [m_heightOutside, 0, 0]^T otherwise with r = sqrt((x - m_centerX)^2 + (y - m_centerY)^2).
Bathymetry is identically zero (flat bottom). The course spec uses the domain [-50, 50]^2 with the dam at the origin, hIn = 10, hOut = 5, radius = 10; main.cpp instantiates this setup on the equivalent 100 x 100 m domain with the centre at (50, 50).
Two-dimensional circular dam break with a submarine Gaussian bump (assignment 4.1, "2D Bathymetry Support" — extension of the plain circular dam break).
Initial condition matches the plain circular dam break in surface elevation η = h + b: η(x, y) = m_heightInside if r_dam < m_damRadius = m_heightOutside otherwise
Bathymetry is a Gaussian bump centred OBSTACLE_OFFSET_X / _Y away from the dam centre: b(x, y) = OBSTACLE_PEAK · exp(-r_obs² / (2 σ²))
Water height is then h = η - b, which keeps the surface flat outside the dam (lake-at-rest) regardless of the bump. The peak stays well below m_heightOutside so no cell becomes dry.
One-dimensional dam break problem.
Declaration of the Rare-Rare Scenario in 1d
Declaration of the reservoir-village scenario
Simulation setup.
Declaration of the Shock-Shock scenario in 1d.
Declaration of the supercritical flow scenario.
Declaration of the subcritical flow scenario.
Declaration of the 1-dimensional tsunami event.
Two-dimensional tsunami event setup driven by netCDF input (assignment 5.2 task 3).
Loads two netCDF files at construction:
Initial values follow the spec (5.2), with delta = 20 m matching the wet/dry tolerance used by TsunamiEvent1d: h = max(-b_in, delta) if b_in < 0, else 0 hu = hv = 0 b = min(b_in, -delta) + d if b_in < 0 b = max(b_in, delta) + d else
Sampling outside the file extents uses nearest-neighbor clamping for the bathymetry (per spec the simulation domain matches the bathy grid) and a strict zero outside the displacement bbox.
Coordinate convention: the setup operates in 0-based simulation coordinates [0, domainLengthX] x [0, domainLengthY] (consistent with the other setups in the codebase). The bathy file may live in any frame (e.g. centred on the origin); on construction the setup auto-detects the file's lower-left corner and shifts every query by it before sampling. domainLengthX/Y() expose the corresponding extents so main.cpp can compute the cell width.
F-wave Riemann solver for the one-dimensional shallow water equations.
Unlike the Roe solver, the f-wave solver decomposes the jump in fluxes (Δf = f(q_r) - f(q_l)) rather than the jump in quantities. The resulting waves Z_p = α_p · r_p are used directly as net-updates without additional scaling by the wave speeds.
Unit tests for the f-wave Riemann solver.
Tests cover:
Roe Riemann solver for the one-dimensional shallow water equations.
Base class for generic usage of solvers
| typedef std::size_t tsunami_lab::t_idx |
integral type for cell-ids, pointer arithmetic, etc.
| typedef float tsunami_lab::t_real |
floating point type
|
constexpr |
gravity constant (9.80665 m/s^2)
|
constexpr |
square root of gravity