Now you are ready to follow the Tutorial you can find in the wiki.
After the simulation finished you will find some files with the suffix .vtk in The folder ApplicationExamples/Euler/Euler_ADERDG, which you can open in Paraview.
## Requirements ##
If you don't have a g++ compiler install it via apt-get
```sudo apt-get install g++```
You might need to install [Java 1.8](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04) jre and jdk
To run programms on multiple threads it is **nescessary** that you have Intel TBB installed. You can find the most recent version at [TBB](https://github.com/01org/tbb/releases)
In case you get an error like this ```Can not find libtbb.so.2```
To be able to look at the generated _.vtu_ output it is **nescessary** to have [Paraview](https://www.paraview.org/download) installed.
## Support ##
We only support default Linux systems like Ubuntu and Mint.
With a few adjustions you can get ExaHyPE running on a Mac: Before compilation hit:
```bash
export SHAREDMEM=None
```
and in the file ```./ExaHyPE/Makefile``` comment out all lines containing a ```-lrt```
There currently is no support for Windows, please use a virtual machine like [VirtualBox](https://www.virtualbox.org/)
## SWE Tutorial ##
# The Shallow Water Equations
The system of hyperbolic PDEs we regard are the Shallow Water Equations ([wiki](https://en.wikipedia.org/wiki/Shallow_water_equations))
The Shallow Water Equations (SWE)model the flow of flat water. The equations neglect any vertical velocities, which is as sufficient approximation as long as the the height of the water is significantly smaller than the regarded domain. We thus only need to consider the water height $`h`$ and velocitys in $`x`$ any $`y`$ dimension, $`u`$ and $`v`$.
The flux models the conservation of mass and momentum and considers hydrostatic pressure. The gravitational constant g will be set to 1.
The eigenvalues of the PDE system are needed later on for the computation of an admissible time step size. For the SWE in two dimension they are:
```math
u\textrm{, }u-\sqrt{g\cdot h}\textrm{ and } u+\sqrt{g\cdot h}
```
# Setting up the specification file
After the equation is defined we need to set up the specification file which for all applications carries the suffix \*.exahype. In the folder ApplicationExamples you can find a template *ADERDG_template.exahype* for an application that is solved by the ADER-DG method.
Set up a new directory *SWE* in ApplicationExamples and copy the template there and name it SWE_ADERDG.exahype.
In this file all place holders are marked by ## and need to be filled to get a working application. (All other options are only used for optimizations and don't need to be touched or understood):
## `exahype-project`
* The name of the project. We use SWE.
```javascript
exahype-project SWE
```
## `output-directory const`
* Defines where the the code body will be generated relative to the root directory
* In our case we use *./ApplicationExamples/SWE/SWE_ADERDG*
* Here we define the number of dimensions, the simulated domain and the physical end time of the application
* The SWE are defined in two dimensions we want to do our simulation on the cube $`[-0.5,0.5]^2`$ and for one second:
```javascript
computational-domain
dimension const = 2
width = 1.0, 1.0
offset = -0.5, -0.5
end-time = 1.0
end computational-domain
```
## `solver ADER-DG` ...
* This region defines the characteristics of the simulated PDE and the used solver.
* `variables const` By lokking at the formula you see that the SWE consist of 3 quantities $'h,hu,hv'$ which we will denote with h and a vector p of length 2.
* `order const` The polynomial degreee of the high order representation. We'll use order 3.
* `maximum-mesh-size` The maximum size of a single cell. ExaHyPE always has to hold a power of 3 cells in one dimension<sup>1</sup>. By setting this value you define an lower limit for the number of cells which is the rounded up to the next power of 3. For our example setting `maximum-mesh-size` to 0.05 gives us a theoretical number of 20 cells in one dimension. The next power of three is 27, so our mesh will end up with 27 cells in each dimension and a mesh size of $`\frac{1}{27}`$.
* `type const` Here you can choose between a linear or nonlinear PDE. SWE are nonlinear (as the flux is).
* `terms const` The type of terms that occur in the PDE system. SWE only hold a flux.
```javascript
solver ADER-DG SWE_ADERDG
variables const = h:1,p:2
order const = 3
/* 27 points: 0.05, 9 points: 0.15 */
maximum-mesh-size = 0.05
time-stepping = globalfixed
type const = nonlinear
terms const = flux
optimisation const = generic
language const = C
end solver
```
<sup>1</sup> The explanation for this takes too long at this point, but believe me there is a reason.
## Adding a plotter
* In this example we add a simple vtk output plotter which is sufficient for our needs.
* Place these lines after `language const` and before `end solver`:
```javascript
plot vtk::Cartesian::vertices::ascii VtkWriter
variables const = 3
time = 0.0
repeat = 1e-2
output = ./swe
end plot
```
* This results in a writer plotting all 3 variables every 0.02 secons starting at time 0. The files will have a prefix swe and be placed in the project directory.
# Run the Toolkit
To generate the code body apply the toolkit to the specification file we just created. Make sure that you ran the setUp.sh script in advance. Go back to the ExaHyPE root directory and hit :
The eigenvalues can directly be taken from upper mathematical formulation. They need to passed with respect to the dimension defined by the argument `const int d`. For $`d=0`$ in x and $`d=1`$ in y (in 3D we additionally get $`d=2`$ in z).
In our case d defines the considered velocity field.
```c++
void SWE::SWE_ADERDG::eigenvalues(const double* const Q,const int d,double* lambda) {
This method implements conditions that are applied along the boundary of the domain.
The engine passes the fields `stateIn` and `fluxIn` which hold the respective state and flux of the simulated domain.
In this short example we implement reflecting boundary conditions. For SWE this means we have to invert the velocity vector along the normal of the interface. As our mesh is Cartesian, the normal can be defined by the single index where it is one `const int normalNonZero`.
The state can then be inverted by:
```c++
void SWE::SWE_ADERDG::boundaryValues(const double* const x,const double t,const double dt,const int faceIndex,const int normalNonZero,