Peano
Loading...
Searching...
No Matches
CCZ4.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 "CCZ4.h"
4
5#include "Constants.h"
6#include "exahype2/RefinementControl.h"
7#include "tarch/NonCriticalAssertions.h"
8
9#include <algorithm>
10#include <cstring>
11#include <limits>
12#include <stdio.h>
13#include <string.h>
14
15tarch::logging::Log benchmarks::exahype2::ccz4::CCZ4::_log("benchmarks::exahype2::ccz4::CCZ4");
16
18 double* NOALIAS Q,
19 const tarch::la::Vector<DIMENSIONS, double>& volumeX,
20 const tarch::la::Vector<DIMENSIONS, double>& volumeH
21) {
22 constexpr int nVars = 59;
23 constexpr double pi = M_PI;
24 constexpr double peak_number = 2.0;
25 constexpr double ICA = 0.1;
26 double HH = 1.0 - ICA * sin(peak_number * pi * (volumeX[0] - 0));
27 double dxH = -peak_number * pi * ICA * cos(peak_number * pi * (volumeX[0] - 0));
28 double dxphi = -pow(HH, (-7.0 / 6.0)) * dxH / 6.0;
29 double phi = pow((1.0 / HH), (1.0 / 6.0));
30 double Kxx = -0.5 * peak_number * pi * ICA * cos(peak_number * pi * (volumeX[0] - 0))
31 / sqrt(1.0 - ICA * sin(peak_number * pi * (volumeX[0] - 0)));
32 double traceK = Kxx / HH;
33 std::memset(Q, .0, nVars * sizeof(double));
34 Q[0] = phi * phi * HH; //\tilde(\gamma)_xx
35 Q[3] = phi * phi; //\tilde(\gamma)_yy
36 Q[5] = phi * phi; //\tilde(\gamma)_zz
37 Q[6] = phi * phi * (Kxx - 1.0 / 3.0 * traceK * HH); //\tilde(A)_xx
38 Q[9] = phi * phi * (0.0 - 1.0 / 3.0 * traceK * 1.0); //\tilde(A)_yy
39 Q[11] = phi * phi * (0.0 - 1.0 / 3.0 * traceK * 1.0); //\tilde(A)_zz
40 Q[16] = sqrt(HH); //\alpha
41 Q[13] = 2.0 / (3.0 * pow(HH, (5.0 / 3.0))) * dxH; //\hat(\Gamma)^x
42 Q[23] = 1.0 / (2.0) * dxH * pow(HH, (-1.0 / 2.0)); // A_x
43 Q[35] = pow(HH, (-1.0 / 3.0)) * dxH / 3.0; // D_xxx
44 Q[38] = phi * dxphi; // D_xyy
45 Q[40] = phi * dxphi; // D_xzz
46 Q[53] = traceK; // K
47 Q[54] = phi; //\phi
48 Q[55] = dxphi; // P_x
49
50 for (int i = 0; i < NumberOfUnknowns; i++) {
51 assertion2(std::isfinite(Q[i]), volumeX, i);
52 }
53}
54
56 const double* NOALIAS Qinside, // Qinside[59+0]
57 double* NOALIAS Qoutside, // Qoutside[59+0]
58 const tarch::la::Vector<DIMENSIONS, double>& faceCentre,
59 const tarch::la::Vector<DIMENSIONS, double>& volumeH,
60 double t,
61 int normal
62) {
63 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
64 assertion4(Qinside[i] == Qinside[i], faceCentre, t, normal, i);
65 Qoutside[i] = Qinside[i];
66 }
67}
68
70 const double* NOALIAS Q,
71 const tarch::la::Vector<DIMENSIONS, double>& volumeCentre,
72 const tarch::la::Vector<DIMENSIONS, double>& volumeH,
73 double t
74) {
75 ::exahype2::RefinementCommand result = ::exahype2::RefinementCommand::Keep;
76
77 const double radius = tarch::la::norm2(volumeCentre);
78 constexpr int NumberOfRefinementLayers = 3;
79
80 const double radii[NumberOfRefinementLayers] = {40, 15, 6};
81 const double maxH[NumberOfRefinementLayers] = {0.32, 0.12, 0.04};
82
83 result = ::exahype2::RefinementCommand::Keep;
84 for (int i = 0; i < NumberOfRefinementLayers; i++) {
85 if (radius < radii[i] and tarch::la::max(volumeH) > maxH[i]) {
86 result = ::exahype2::RefinementCommand::Refine;
87 }
88 }
89
90 return result;
91}
void initialCondition(double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH) override
Definition CCZ4.cpp:17
::exahype2::RefinementCommand refinementCriterion(const double *NOALIAS Q, const tarch::la::Vector< DIMENSIONS, double > &volumeCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t) override
Refinement criterion.
Definition CCZ4.cpp:69
virtual void boundaryConditions(const double *NOALIAS Qinside, double *NOALIAS Qoutside, const tarch::la::Vector< DIMENSIONS, double > &faceCentre, const tarch::la::Vector< DIMENSIONS, double > &volumeH, double t, int normal) override
Definition CCZ4.cpp:55
static tarch::logging::Log _log
Definition CCZ4.h:32