Peano
Loading...
Searching...
No Matches
acoustic_planar_waves.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
6import sys
7from math import sqrt
8
9sys.path.insert(0, os.path.abspath("../equations"))
10from equations import Acoustic
11
12
14 """
15 Scenario reproduced from Dumbser & Käser, https://doi.org/10.1111/j.1365-246X.2006.03120.x (Chapter 5, p. 328)
16 """
17
18 _plot_dt = 0.0
19 _offset = -1.0
20 _domain_size = 2.0
21 _periodic_bc = True
22
23 def __init__(self, dimensions, iterations=2):
24 self._dimensions = dimensions
25 self._end_time = iterations * sqrt(dimensions)
26 self._K0 = 4.0
27 self._rho = 1.0
28 self._equation = Acoustic(dimensions, rho=self._rho, K0=self._K0)
29
31 return (
32 """
33 // simple translation in positive diagonal direction
34 const double val = cos( - std::numbers::pi*(
35 x[0] + x[1]
36#if DIMENSIONS==3
37 + x[2]
38#endif
39 ));
40
41 Q[1] = val;
42 Q[2] = val;
43#if DIMENSIONS==3
44 Q[3] = val;
45#endif
46
47 constexpr double K0 = """
48 + str(self._K0)
49 + """;
50 constexpr double rho = """
51 + str(self._rho)
52 + """;
53
54 // These are defined by the eigenvector of the plane wave operator
55#if DIMENSIONS==3
56 const double kr = K0*std::sqrt(rho/(3.0*K0)) + 2*std::sqrt(K0*rho/3.0);
57#else
58 const double kr = std::sqrt(2*K0*rho);
59#endif
60
61 Q[0] = kr*val;
62"""
63 )
64
66 return (
67 """
68 const double w = 2*std::sqrt(DIMENSIONS)*M_PI;
69
70 const double val = cos( w*t - std::numbers::pi*(
71 x[0] + x[1]
72#if DIMENSIONS==3
73 + x[2]
74#endif
75 ));
76
77 solution[1] = val;
78 solution[2] = val;
79
80 constexpr double K0 = """
81 + str(self._K0)
82 + """;
83 constexpr double rho = """
84 + str(self._rho)
85 + """;
86
87#if DIMENSIONS==3
88 solution[3] = val;
89 const double kr = K0*std::sqrt(rho/(3.0*K0)) + 2*std::sqrt(K0*rho/3.0);
90#else
91 const double kr = std::sqrt(2*K0*rho);
92#endif
93
94 solution[0] = kr*val;
95"""
96 )
Scenario reproduced from Dumbser & Käser, https://doi.org/10.1111/j.1365-246X.2006....