Peano
PlanarAcousticSolver.cpp
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 #include "PlanarAcousticSolver.h"
4 
6  "tutorials::exahype2::acoustic::PlanarAcousticSolver"
7 );
8 
9 void tutorials::exahype2::acoustic::PlanarAcousticSolver::initialCondition(
10  [[maybe_unused]] double* const NOALIAS Q, // Q[3+0]
11  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
12  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
13  [[maybe_unused]] const bool gridIsConstructed
14 ) {
15  // Simple translation in positive diagonal direction
16  const double val = cos(-std::numbers::pi * (x[0] + x[1]));
17 
18  Q[Shortcuts::v + 0] = val;
19  Q[Shortcuts::v + 1] = val;
20 
21  constexpr double K0 = 4.0;
22  constexpr double rho = 1.0;
23 
24  // These are defined by the eigenvector of the plane wave operator
25  const double kr = std::sqrt(2 * K0 * rho);
26  Q[Shortcuts::p] = kr * val;
27 }
28 
29 void tutorials::exahype2::acoustic::PlanarAcousticSolver::boundaryConditions(
30  [[maybe_unused]] const double* const NOALIAS Qinside, // Qinside[3+0]
31  [[maybe_unused]] double* const NOALIAS Qoutside, // Qoutside[3+0]
32  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
33  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
34  [[maybe_unused]] const double t,
35  [[maybe_unused]] const int normal
36 ) {
37  // Since we are using periodic boundary conditions, this need never be called.
38  assert(false);
39 }
40 
42  [[maybe_unused]] const double* const NOALIAS Q, // Q[3+0]
43  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
44  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
45  [[maybe_unused]] const double t,
46  [[maybe_unused]] const double dt,
47  [[maybe_unused]] const int normal
48 ) {
49  constexpr double K0 = 4.0;
50  constexpr double rho = 1.0;
51  const double c = std::sqrt(4.0 / rho);
52  return c;
53 }
54 
56  [[maybe_unused]] const double* const NOALIAS Q, // Q[3+0]
57  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& x,
58  [[maybe_unused]] const tarch::la::Vector<DIMENSIONS, double>& h,
59  [[maybe_unused]] const double t,
60  [[maybe_unused]] const double dt,
61  [[maybe_unused]] const int normal,
62  [[maybe_unused]] double* const NOALIAS F // F[3]
63 ) {
64  constexpr double K0 = 4.0;
65  constexpr double rho = 1.0;
66 
67  switch (normal) {
68  case 0: // Flux in x-direction
69  F[Shortcuts::p] = K0 * Q[Shortcuts::v + normal];
70  F[Shortcuts::v + 0] = Q[Shortcuts::p] / rho;
71  F[Shortcuts::v + 1] = 0.0;
72  break;
73  case 1: // Flux in y-direction
74  F[Shortcuts::p] = K0 * Q[Shortcuts::v + normal];
75  F[Shortcuts::v + 0] = 0.0;
76  F[Shortcuts::v + 1] = Q[Shortcuts::p] / rho;
77  }
78 }
static double maxEigenvalue(const double *const Q, int normal, const double CCZ4e, const double CCZ4ds, const double CCZ4GLMc, const double CCZ4GLMd)
flux
Definition: euler.py:29
h
Definition: swe.py:79
tarch::logging::Log _log
This is variant 1 of the fused kernels.