Peano
Loading...
Searching...
No Matches
swe.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 .equation import Equation
4
5
7 def __init__(self, dimensions=2):
8 if dimensions != 2:
9 raise Exception("SWE must be in 2 dimensions")
13
14 def eigenvalues(self):
15 return """
16 constexpr double grav = 9.81;
17
18 const double u = Q[1 + normal] / Q[0];
19 const double c = std::sqrt(grav * Q[0]);
20
21 return std::max(std::abs(u + c), std::abs(u - c));
22"""
23
24 def flux(self):
25 return """
26 double ih = 1.0 / Q[0];
27
28 F[0] = Q[1 + normal];
29 F[1] = Q[1 + normal] * Q[1] * ih;
30 F[2] = Q[1 + normal] * Q[2] * ih;
31 F[3] = 0.0;
32"""
33
34 def ncp(self):
35 return """
36 constexpr double grav = 9.81;
37 BTimesDeltaQ[0] = 0.0;
38 switch (normal) {
39 case 0:
40 BTimesDeltaQ[1] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
41 BTimesDeltaQ[2] = 0.0;
42 break;
43 case 1:
44 BTimesDeltaQ[1] = 0.0;
45 BTimesDeltaQ[2] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
46 break;
47 }
48 BTimesDeltaQ[3] = 0.0;
49"""
50
51
53 def __init__(self, dimensions=2):
54 if dimensions != 2:
55 raise Exception("SWE must be in 2 dimensions")
59
60 def eigenvalues(self):
61 return """
62 constexpr double grav = 9.81;
63
64 const double u = Q[1 + normal] / Q[0];
65 const double c = std::sqrt(grav * Q[0]);
66
67 return std::max(std::abs(u + c), std::abs(u - c));
68"""
69
70 def flux(self):
71 return """
72 constexpr double grav = 9.81;
73 double ih = 1.0 / Q[0];
74
75 F[0] = Q[1 + normal];
76 F[1] = Q[1 + normal] * Q[1] * ih;
77 F[2] = Q[1 + normal] * Q[2] * ih;
78
79 F[normal+1] += 0.5 * grav * Q[0] * Q[0];
80"""
__init__(self, dimensions=2)
Definition swe.py:53
__init__(self, dimensions=2)
Definition swe.py:7