6parser = exahype2.ArgumentParser(
7 "ExaHyPE 2 - Finite Volumes Dynamic AMR Testing Script"
15args = parser.parse_args()
17max_patch_size = 1.1 * 10.0 / (3.0**args.min_depth)
18max_h = max_patch_size / args.degrees_of_freedom
19min_h = 0.9 * max_h * 3.0 ** (-args.amr_levels)
21initial_conditions =
"""
22 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
27boundary_conditions =
"""
28 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
33refinement_criterion =
"""
34 auto result = ::exahype2::RefinementCommand::Keep;
36 static constexpr double sourceRadius = 0.5;
37 const tarch::la::Vector<DIMENSIONS, double> sourceCentre(1.0);
39 static constexpr double t0 = 0.7;
40 if (tarch::la::greaterEquals(t, 0.0) and tarch::la::smallerEquals(t, t0)) {
41 if (tarch::la::smallerEquals(tarch::la::norm2(x - sourceCentre), sourceRadius)) {
42 result = ::exahype2::RefinementCommand::Refine;
47 const double pAbs = std::abs(Q[Shortcuts::p]);
50 for (int i = 0; i < DIMENSIONS; i++) {
51 const double ui = Q[Shortcuts::u + i];
54 const double uMag = std::sqrt(u2);
56 const double indicator = std::max(pAbs, (RHO * WAVE_SPEED) * uMag);
58 static constexpr double refineThreshold = 0.20;
59 static constexpr double eraseThreshold = 0.10;
61 if (tarch::la::greaterEquals(indicator, refineThreshold)) {
62 result = ::exahype2::RefinementCommand::Refine;
63 } else if (tarch::la::smallerEquals(indicator, eraseThreshold)) {
64 result = ::exahype2::RefinementCommand::Erase;
70fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
72 patch_size=args.degrees_of_freedom,
73 unknowns={
"p": 1,
"u": args.dimensions},
74 auxiliary_variables=0,
77 time_step_relaxation=0.5,
80fv_solver.set_implementation(
81 initial_conditions=initial_conditions,
82 boundary_conditions=boundary_conditions,
83 refinement_criterion=refinement_criterion,
85 static constexpr double K0 = RHO * WAVE_SPEED * WAVE_SPEED;
87 F[Shortcuts::p] = K0 * Q[normal + 1];
88 F[Shortcuts::u + 0] = 0.0;
89 F[Shortcuts::u + 1] = 0.0;
91 F[Shortcuts::u + 2] = 0.0;
93 F[normal + 1] = (1.0 / RHO) * Q[Shortcuts::p];
96 max_eigenvalue=
"return WAVE_SPEED;",
98 S[Shortcuts::p] = 0.0;
99 S[Shortcuts::u + 0] = 0.0;
100 S[Shortcuts::u + 1] = 0.0;
102 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, 1.0})) <= sourceRadius;
109 constexpr double sourceRadius = 0.10;
110 const bool sourceLocation = tarch::la::norm2(x - tarch::la::Vector<DIMENSIONS, double>({1.0, 1.0, 1.0})) <= sourceRadius;
113 if (sourceLocation) {
114 static constexpr double t0 = 0.7;
115 static constexpr double M0 = 1000.0;
116 const double force = M0 * std::exp(-((t - t0) * (t - t0)) / (2.0 * SIGMA * SIGMA));
117 S[Shortcuts::p] = force;
122project = exahype2.Project(
123 namespace=[
"tests",
"exahype2",
"fv"],
126 executable=
"ExaHyPE",
128project.add_solver(fv_solver)
130if args.number_of_snapshots <= 0:
131 time_in_between_plots = 0.0
133 time_in_between_plots = args.end_time / args.number_of_snapshots
134 project.set_output_path(args.output)
136project.set_global_simulation_parameters(
137 dimensions=args.dimensions,
138 size=[10.0, 10.0, 10.0][0 : args.dimensions],
139 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
140 min_end_time=args.end_time,
141 max_end_time=args.end_time,
142 first_plot_time_stamp=0.0,
143 time_in_between_plots=time_in_between_plots,
151project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
152project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
153project = project.generate_Peano4_project(verbose=
False)
154project.output.makefile.set_target_device(args.target_device)
155project.output.makefile.add_CXX_flag(
"-DRHO=2.7")
156project.output.makefile.add_CXX_flag(
"-DWAVE_SPEED=6.0")
157project.output.makefile.add_CXX_flag(
"-DSIGMA=0.1149")
158project.build(make=
True, make_clean_first=
True, throw_away_data_after_build=
True)