15
Department of Informatics V Lab: Scientific Computing – Tsunami-Simulation Session 3: netCDF, Tsunamis A. Breuer, S. Rettenberger, M. Bader 13th May, 2013 A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation Session 3: netCDF, Tsunamis, 13th May, 2013 1

Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Lab: Scientific Computing –Tsunami-Simulation

Session 3: netCDF, Tsunamis

A. Breuer, S. Rettenberger, M. Bader

13th May, 2013

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 1

Page 2: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Outline

Presentations: Assignment 2

netCDF

Checkpointing

Preparation: Assignment 3

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 2

Page 3: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Schedule (big meetings)

Date Schedule15.04.2013 Kickoff29.04.2013 Presentation 113.05.2013 Presentation 227.05.2013 Presentation 310.06.2013 Presentation 424.06.2013 Report: Project Phase01.07.2013 Presentation Project

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 3

Page 4: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Presentations: Assignment 2

Prof. Dr. M. BaderDipl.-Math. A. BreuerS. Rettenberger, M. Sc.

TUM, SCCS (I5)Bachelor-Praktikum:Tsunami-Simulation April 29, 2013

In their differential form the two dimensional shallow water equations are given by:

h

hu

hv

t

+

hu

hu2 + 12gh2

huv

x

+

hv

huv

hv2 + 12gh2

y

= S(x,y, t). (1)

The quantities q = [h,hu,hv]T are defined by the space-time dependent water heighth(x,y, t), the momentum in spatial x-direction hu(x,y, t) and the momentum in y-directionhv(x,y, t). F := [hu,hu2 + 1

2gh2,huv]T is the flux function in x-direction and G :=

[hv,huv,hv2+ 12gh2]T in the flux function in y-direction. g is the gravitational constant (usu-

ally g := 9.81m/s2). As for the one-dimensional shallow water equations, we consider onlythe space-dependent effect of bathymetry in the source term S(x,y) = [0,−ghBx,−ghBy]

T .In this assignment we will first introduce bathymetry in our solver and simulate one di-

mensional flow over a weir in Chapter 1 and 2. The following Chapters 3 and 4 cover theextension of our one dimensional discretization to two spatial dimensions. After this assign-ment we have all numerics at hand and will be able to concentrate on Tsunami simulationsin the third assignment.

Literature

• Hydraulics over a weir : http://serc.carleton.edu/details/files/19076.html

• SWE Wiki : https://github.com/TUM-I5/SWE/wiki

• Documentation, GNU C Preprocessor : http://gcc.gnu.org/onlinedocs/cpp/

• Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite VolumeMethod, Valiani et. al., 2002

1 Bathymetry

1.1 Non-zero source term

Bathymetry is the topography of the ocean and the most important effect to be consideredin the source term of the shallow water equations for Tsunami simulations. As reference weuse the sea level: Bathymetry in dry cells (land) Ci is zero or positive: bi > 0, wet cells(water) have negative values: bi < 0.

Introduction of bathymetry into the f-wave solver is comparably simple, because it canbe directly incorporated into the decomposition of the jump in the flux function:

∆f− ∆xΨi−1/2 =

2∑

p=1

Zp, (2)

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 4

Page 5: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

netCDF (Network Common Data Form)

• Interface to store and retrieve data in arrays• Support for n-dimensional arrays• Self-describing• Portable• Binary file format

→ a factor of 4-5 smaller than text files

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 5

Page 6: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

netCDF (Network Common Data Form)

• Interface to store and retrieve data in arrays• Support for n-dimensional arrays• Self-describing• Portable• Binary file format→ a factor of 4-5 smaller than text files

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 5

Page 7: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

netCDF – Data Model

Source: http://www.unidata.ucar.edu/software/netcdf/docs/data_model.html

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 6

Page 8: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

CDL (network Common data form DescriptionLanguage)

• Text representation of netCDF datasets• Conversion between netCDF and CDL:

Source: http://www.unidata.ucar.edu/software/netcdf/workshops/2011/utilities/NcgenNcdump.html

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 7

Page 9: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

CDL – Example

netcdf foo { // example netCDF specification in CDL

dimensions:

lat = 10, lon = 5, time = unlimited;

variables:

int lat(lat), lon(lon), time(time);

float z(time,lat,lon), t(lat,lon);

lat:units = "degrees_north";

lon:units = "degrees_east";

time:units = "seconds";

z:valid_range = 0., 5000.;

data:

lat = 0, 10, 20, 30, 40, 50, 60, 70, 80, 90;

}

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 8

Page 10: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Coordinate Variables

• Variables with the same name as a dimension• Physical coordinate of the corresponding dimension• Example:

int lat(lat), lon(lon), level(level);

short time(time);

...

data:

level = 1000, 850, 700, 500;

lat = 20, 30, 40, 50, 60;

lon = -160,-140,-118,-96,-84,-52,-45,-35,-25,-15;

time = 12;

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 9

Page 11: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Coordinate Variables

int lat(lat), lon(lon), level(level);

short time(time);

...

data:

level = 1000, 850, 700, 500;

lat = 20, 30, 40, 50, 60;

lon = -160,-140,-118,-96,-84,-52,-45,-35,-25,-15;

time = 12;

In our files:• Only monotonically increasing coordinate variables• Coordinate variables are uniformly spaced (except time)

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 9

Page 12: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Hardware failure

• Assume a computer fails with the probability of 0.1% during asimulation⇒ In 1 of 1000 cases, we simply restart the simulation

Source: http://www.pcmech.com/article/hp-support-problems-cheap-hardware-or-both/

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 10

Page 13: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Hardware failure

• Assume a computer fails with the probability of 0.1% during asimulation⇒ In 1 of 1000 cases, we simply restart the simulation

• We want to run the simulation on 100 computers in parallel⇒ Now, the probability that one of them fails is:

1− (99.9%)100 ≈ 9.5%⇒ In 1 of 10 cases, we have to restart the simulation

Source: http://www.pcmech.com/article/hp-support-problems-cheap-hardware-or-both/

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 10

Page 14: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Checkpointing

• Save the current state of the simulation after defined timeintervals⇒ Checkpoints

• In case of an error, load the last available checkpoint andcontinue the simulation⇒ Only the time steps between the last checkpoint and the errorare lost

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 11

Page 15: Lab: Scientific Computing – Tsunami-Simulation · Case Study: Malpasset Dam-Break Simulation using a Two-Dimensional Finite Volume Method, Valiani et. al., 2002 1 Bathymetry 1.1

Department of Informatics V

Preparation: Assignment 3

Prof. Dr. M. BaderDipl.-Math. A. BreuerS. Rettenberger, M. Sc.

TUM, SCCS (I5)Bachelor-Praktikum:Tsunami-Simulation May 13, 2013

This assignment extends our current implementation, which was already able to simulateartificial scenarios, with the most important data for Tsunami simulations: Bathymetry andvertical displacements of the sea bottom generated by earthquakes. Data for the Great To-hoku Earthquake and Tsunami (11th March 2011) and the February 27, 2010 Chile TsunamiEvent is provided as binary netCDF files. We simulate both Tsunamis in Chapter 4 afterwe programmed the file handling of netCDF files in Chapter 1, 2 and 3.

Literature

• NOAA/WDS Global Historical Tsunami Database at NGDC : http://www.ngdc.noaa.gov/hazard/tsu_db.shtml

• netCDF Users Guide: http://www.unidata.ucar.edu/software/netcdf/docs/user_guide.html

• Conventions for the standardization of netCDF files : http://ferret.wrc.noaa.gov/noaa_coop/coop_cdf_profile.html

1 netCDF Output

In this chapter we will switch the file format from VTK to netCDF (Network Common DataForm). You can find an introduction to netCDF as well as a description of the data modelin the user guide.

netCDF output has two main advantages over plain text VTK. First, netCDF files arebinary files, thus a lot smaller than VTK files. Second, we can store all time steps in a singlenetCDF file, removing the overhead introduced by large number of files.

SWE already has a netCDF writer. To enable this writer, you first have to install thenetCDF library for C (the C++ version is not required). If the library is included in yourdistribution, you can use the package manager, otherwise you need to install it from source1.The netCDF library depends on the HDF5 library2, hence do not forget to install this libraryas well. To build SWE with netCDF support use the option writeNetCDF=’yes’. If youinstalled it from source, it is very likely that you have to set netCDFDir as well, specifyingthe netCDF install directory.

Tasks

1. Recompile SWE with the netCDF writer enabled and rerun your example from the lastassignment.

2. The netCDF writer implements the COARDS conventions, which allows Paraview todisplay your newly created output files. Visualize the output files with Paraview andcompare them with the VTK files.

1http://www.unidata.ucar.edu/downloads/netcdf/index.jsp2http://www.hdfgroup.org/HDF5/

A. Breuer, S. Rettenberger, M. Bader: Lab: Scientific Computing – Tsunami-Simulation

Session 3: netCDF, Tsunamis, 13th May, 2013 12