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