Peano
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
3 from .scenario import Scenario
4 
5 import os
6 import sys
7 
8 sys.path.insert(0, os.path.abspath("../equations"))
9 from equations import SWE_W_Bathymetry
10 
11 _initial_conditions = {
12  "bilinear": """
13  Q[1] = 0.0;
14  Q[2] = 0.0;
15  Q[3] = 1.0 - std::abs(x[0]) - std::abs(x[1]);
16  Q[0] = 2.0 - Q[3];
17 """,
18  "sinusoidal": """
19  Q[1] = 0.0;
20  Q[2] = 0.0;
21  Q[3] = sin( 2*M_PI * (x[0]+x[1]) );
22  Q[0] = 2.0 - Q[3];
23 """,
24  "constant": """
25  Q[1] = 0.0;
26  Q[2] = 0.0;
27  Q[3] = 1.0;
28  Q[0] = 2.0 - Q[3];
29 """,
30 }
31 
32 
34  """
35  Resting lake scenario for the shallow water equations.
36  The real water height H as defined by the sum of the water column h and
37  the bathymetry b is constant over the entire domain, meaning that there
38  should be no changes on the entire domain, but because we use the sum of
39  the derivatives of h and b (h' + b') instead of the derivative of the sum
40  (h + b)' some rounding errors will creep in, which causes unphysical
41  waves to appear.
42  As such this scenario is nice for testing how large these unphysical waves
43  are for a given algorithm, and how stable the algorithm is, i.e. does it
44  dampen out these waves or do they oscillate out of control.
45  """
46 
47  _plot_dt = 0.0
48  _offset = -0.5
49  _domain_size = 1.0
50  _periodic_bc = True
51  _dimensions = 2
52  _equation = SWE_W_Bathymetry()
53  _end_time = 1.0
54 
55  def __init__(
56  self,
57  initial_conditions="sinusoidal",
58  ):
59  self._init_init = _initial_conditions[initial_conditions]
60 
61  def initial_conditions(self):
62  return self._init_init
63 
65  return """
66  {{SOLUTION_STORAGE_PRECISION}} _Q[4];
67  initialCondition(
68  _Q,
69  x,
70  tarch::la::Vector<DIMENSIONS, double>(),
71  true
72  );
73 
74  solution[0] = _Q[0];
75  solution[1] = _Q[1];
76  solution[2] = _Q[2];
77  solution[3] = _Q[3];
78  """
Resting lake scenario for the shallow water equations.
def __init__(self, initial_conditions="sinusoidal")