Peano 4
Loading...
Searching...
No Matches
AcousticWaveKernels.h
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#pragma once
4
5#include "Constants.h"
6#include "tarch/Assertions.h"
7#include "tarch/la/Vector.h"
8
10 static double maxEigenvalue() InlineMethod { return WAVE_SPEED; }
11
12 static void flux(const double* __restrict__ Q, int normal, double* __restrict__ F) InlineMethod {
13#ifdef GPUOffloadingOff
14 assertion(normal >= 0);
15 assertion(normal < Dimensions);
16#endif
17
18 static constexpr double K0 = RHO * WAVE_SPEED * WAVE_SPEED;
19
20 F[0] = K0 * Q[normal + 1];
21 F[1] = 0.0;
22 F[2] = 0.0;
23#if Dimensions == 3
24 F[3] = 0.0;
25#endif
26 F[normal + 1] = (1.0 / RHO) * Q[0];
27 }
28
29 static void sourceTerm(const double* __restrict__ Q, const tarch::la::Vector<Dimensions, double>& x, double t, double* __restrict__ S) InlineMethod {
30 S[0] = 0.0;
31 S[1] = 0.0;
32 S[2] = 0.0;
33#if Dimensions == 3
34 S[3] = 0.0;
35#endif
36
37#if Dimensions == 2
38 const bool pointSource = tarch::la::norm2(x - tarch::la::Vector<Dimensions, double>({5, 5})) <= 1.0;
39#else
40 const bool pointSource = tarch::la::norm2(x - tarch::la::Vector<Dimensions, double>({5, 5, 5})) <= 1.0;
41#endif
42
43 if (pointSource) {
44 static constexpr double t0 = 0.7;
45 static constexpr double M0 = 1000.0;
46 const double force = M0 * std::exp(-((t - t0) * (t - t0)) / (2.0 * SIGMA * SIGMA));
47 S[0] = force;
48 }
49 }
50} // namespace applications::exahype2::acousticwave
#define assertion(expr)
static double maxEigenvalue() InlineMethod
static void sourceTerm(const double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &x, double t, double *__restrict__ S) InlineMethod
static void flux(const double *__restrict__ Q, int normal, double *__restrict__ F) InlineMethod
Scalar norm2(const Vector< Size, Scalar > &vector)
Computes the 2-norm of the vector, i.e.
Simple vector class.
Definition Vector.h:134
#define InlineMethod
This is the marker that is to be used after the argument list of a function declaration.
Definition tarch.h:58