6parser = exahype2.ArgumentParser(
"ExaHyPE 2 - ADER-DG Dynamic AMR Testing Script")
13args = parser.parse_args()
15max_h = 1.1 * 10.0 / (3.0**args.min_depth)
16min_h = 0.9 * max_h * 3.0 ** (-args.amr_levels)
18end_time = args.end_time
20polynomials = exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
22project = exahype2.Project(
23 namespace=[
"tests",
"exahype2",
"aderdg"],
29solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
31 order=(args.degrees_of_freedom - 1),
34 time_step_relaxation=0.5,
35 unknowns={
"p": 1,
"u": args.dimensions},
36 auxiliary_variables=0,
39solver.set_implementation(
40 initial_conditions=
"""
41 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
45 boundary_conditions=
"""
46 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
50 refinement_criterion=
"""
51 auto result = ::exahype2::RefinementCommand::Keep;
53 static constexpr double sourceRadius = 2.2;
54 const tarch::la::Vector<DIMENSIONS, double> sourceCentre(1.0);
56 static constexpr double t0 = 0.8;
57 if (tarch::la::greaterEquals(t, 0.0) and tarch::la::smallerEquals(t, t0)) {
58 if (tarch::la::smallerEquals(tarch::la::norm2(x - sourceCentre), sourceRadius)) {
59 result = ::exahype2::RefinementCommand::Refine;
64 const double pAbs = std::abs(Q[Shortcuts::p]);
67 for (int i = 0; i < DIMENSIONS; i++) {
68 const double ui = Q[Shortcuts::u + i];
71 const double uMag = std::sqrt(u2);
73 const double indicator = std::max(pAbs, (RHO * WAVE_SPEED) * uMag);
75 static constexpr double refineThreshold = 0.10;
76 static constexpr double eraseThreshold = 0.05;
78 if (tarch::la::greaterEquals(indicator, refineThreshold)) {
79 result = ::exahype2::RefinementCommand::Refine;
80 } else if (tarch::la::smallerEquals(indicator, eraseThreshold)) {
81 result = ::exahype2::RefinementCommand::Erase;
86 max_eigenvalue=
"""return WAVE_SPEED;
89 static constexpr double K0 = RHO * WAVE_SPEED * WAVE_SPEED;
91 F[Shortcuts::p] = K0 * Q[normal + 1];
92 F[Shortcuts::u + 0] = 0.0;
93 F[Shortcuts::u + 1] = 0.0;
95 F[Shortcuts::u + 2] = 0.0;
97 F[normal + 1] = (1.0 / RHO) * Q[Shortcuts::p];
100 S[Shortcuts::p] = 0.0;
101 S[Shortcuts::u + 0] = 0.0;
102 S[Shortcuts::u + 1] = 0.0;
104 S[Shortcuts::u + 2] = 0.0;
106 constexpr double sourceRadius = 0.10;
107 const bool sourceLocation = tarch::la::norm2(x - tarch::la::Vector<DIMENSIONS, double>(1.0)) <= sourceRadius;
109 if (sourceLocation) {
110 static constexpr double t0 = 0.7;
111 static constexpr double M0 = 1000.0;
112 const double force = M0 * std::exp(-((t - t0) * (t - t0)) / (2.0 * SIGMA * SIGMA));
113 S[Shortcuts::p] = force;
118project.add_solver(solver)
120if args.number_of_snapshots <= 0:
121 time_in_between_plots = 0.0
123 time_in_between_plots = args.end_time / args.number_of_snapshots
124 project.set_output_path(args.output)
126project.set_global_simulation_parameters(
127 dimensions=args.dimensions,
128 size=[10.0, 10.0, 10.0][0 : args.dimensions],
129 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
130 min_end_time=args.end_time,
131 max_end_time=args.end_time,
132 first_plot_time_stamp=0.0,
133 time_in_between_plots=time_in_between_plots,
141project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
142project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
143project = project.generate_Peano4_project(verbose=
False)
144project.output.makefile.set_target_device(args.target_device)
145project.output.makefile.add_CXX_flag(
"-DRHO=2.7")
146project.output.makefile.add_CXX_flag(
"-DWAVE_SPEED=6.0")
147project.output.makefile.add_CXX_flag(
"-DSIGMA=0.1149")
148project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)