Peano
Loading...
Searching...
No Matches
aderdg-static-amr.py
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
3import peano4
4import exahype2
5
6parser = exahype2.ArgumentParser("ExaHyPE 2 - ADER-DG Static AMR Testing Script")
7parser.set_defaults(
8 min_depth=3,
9 amr_levels=2,
10 degrees_of_freedom=5,
11)
12args = parser.parse_args()
13
14size = [1.0, 1.0]
15order = args.degrees_of_freedom - 1
16max_h = 1.1 * min(size) / (3.0**args.min_depth)
17min_h = max_h * 3.0 ** (-args.amr_levels)
18plot_interval = 0.01
19end_time = 0.1
20
21polynomials = exahype2.solvers.aderdg.Polynomials.Gauss_Legendre
22
23project = exahype2.Project(
24 namespace=["tests", "exahype2", "aderdg"],
25 project_name=".",
26 directory=".",
27 executable="ExaHyPE",
28)
29
30solver = exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
31 name="ADERDGSolver",
32 order=order,
33 min_cell_h=min_h,
34 max_cell_h=max_h,
35 time_step_relaxation=0.8,
36 unknowns=4,
37 auxiliary_variables=0,
38)
39
40solver.set_implementation(
41 initial_conditions="""
42 double r = std::sqrt((x[0] - 0.5) * (x[0] - 0.5) + (x[1] - 0.5) * (x[1] - 0.5));
43 Q[0] = 1.;
44 Q[1] = 0.;
45 Q[2] = 0.;
46 Q[3] = r < 0.1 ? 0.0 : 0.05;
47""",
48 boundary_conditions="""
49 initialCondition(Qoutside, x, h);
50""",
51 refinement_criterion="""
52 auto result = ::exahype2::RefinementCommand::Keep;
53 double r = std::sqrt((x[0] - 0.5) * (x[0] - 0.5) + (x[1] - 0.5) * (x[1] - 0.5));
54 if (r < 0.2) {
55 result = ::exahype2::RefinementCommand::Refine;
56 }
57 return result;
58""",
59 max_eigenvalue="""
60 constexpr double grav = 9.81;
61 const double u = Q[1 + normal] / Q[0];
62 const double c = std::sqrt(grav * Q[0]);
63 return std::max(std::abs(u + c), std::abs(u - c));
64""",
65 flux="""
66 const double ih = 1.0 / Q[0];
67 F[0] = Q[1 + normal];
68 F[1] = Q[1 + normal] * Q[1] * ih;
69 F[2] = Q[1 + normal] * Q[2] * ih;
70 F[3] = 0.0;
71""",
72 ncp="""
73 constexpr double grav = 9.81;
74 BTimesDeltaQ[0] = 0.0;
75 switch (normal) {
76 case 0:
77 BTimesDeltaQ[1] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
78 BTimesDeltaQ[2] = 0.0;
79 break;
80 case 1:
81 BTimesDeltaQ[1] = 0.0;
82 BTimesDeltaQ[2] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
83 break;
84 }
85 BTimesDeltaQ[3] = 0.0;
86""",
87)
88
89project.add_solver(solver)
90project.set_output_path("solutions")
91
92project.set_global_simulation_parameters(
93 dimensions=2,
94 offset=[0.0, 0.0],
95 size=size,
96 min_end_time=end_time,
97 max_end_time=end_time,
98 first_plot_time_stamp=0.0,
99 time_in_between_plots=plot_interval,
100 periodic_BC=[False, False],
101)
102
103project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
104project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
105project = project.generate_Peano4_project(verbose=False)
106project.build(make_clean_first=True)