Peano
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
3 from .scenario import Scenario
4 
5 import os
6 import sys
7 from math import sqrt
8 
9 sys.path.insert(0, os.path.abspath("../equations"))
10 from 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_dimensions = dimensions
25  self._end_time_end_time_end_time = iterations * sqrt(dimensions)
26  self._K0_K0 = 4.0
27  self._rho_rho = 1.0
28  self._equation_equation_equation = Acoustic(dimensions, rho=self._rho_rho, K0=self._K0_K0)
29 
30  def initial_conditions(self):
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_K0)
49  + """;
50  constexpr double rho = """
51  + str(self._rho_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_K0)
82  + """;
83  constexpr double rho = """
84  + str(self._rho_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....
str
Definition: ccz4.py:55