Peano
Loading...
Searching...
No Matches
swe_resting_lake.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from .scenario import Scenario
4
5import os, sys
6import jinja2
7
8sys.path.insert(0, os.path.abspath("../equations"))
9from equations import SWE_W_Bathymetry
10
12 """
13 Resting lake scenario for the shallow water equations.
14 The real water height H as defined by the sum of the water column h and
15 the bathymetry b is constant over the entire domain, meaning that there
16 should be no changes on the entire domain, but because we use the sum of
17 the derivatives of h and b (h' + b') instead of the derivative of the sum
18 (h + b)' some rounding errors will creep in, which causes unphysical
19 waves to appear.
20 As such this scenario is nice for testing how large these unphysical waves
21 are for a given algorithm, and how stable the algorithm is, i.e. does it
22 dampen out these waves or do they oscillate out of control.
23 """
24
25 _plot_dt = 0.0
26 _offset = -0.5
27 _domain_size = 1.0
28 _periodic_bc = True
29 _dimensions = 2
30 _equation = SWE_W_Bathymetry()
31 _end_time = 1.0
32
34 self,
35 initial_conditions="sinusoidal",
36 ):
37 self._scenario = initial_conditions
38
39 def _initial_conditions(self, Q):
40 d = {"VARIABLE": Q}
41 return {
42 "bilinear": jinja2.Template("""
43 {{VARIABLE}}[1] = 0.0;
44 {{VARIABLE}}[2] = 0.0;
45 {{VARIABLE}}[3] = 1.0 - std::abs(x[0]) - std::abs(x[1]);
46 {{VARIABLE}}[0] = 2.0 - {{VARIABLE}}[3];
47""").render(**d),
48 "sinusoidal": jinja2.Template("""
49 {{VARIABLE}}[1] = 0.0;
50 {{VARIABLE}}[2] = 0.0;
51 {{VARIABLE}}[3] = sin( 2*M_PI * (x[0]+x[1]) );
52 {{VARIABLE}}[0] = 2.0 - {{VARIABLE}}[3];
53""").render(**d),
54 "constant": jinja2.Template("""
55 {{VARIABLE}}[1] = 0.0;
56 {{VARIABLE}}[2] = 0.0;
57 {{VARIABLE}}[3] = 1.0;
58 {{VARIABLE}}[0] = 2.0 - {{VARIABLE}}[3];
59""").render(**d)
60 }
61
63 return self._initial_conditions("Q")[self._scenario]
64
66 return self._initial_conditions("solution")[self._scenario]
Resting lake scenario for the shallow water equations.
__init__(self, initial_conditions="sinusoidal")