Peano
Loading...
Searching...
No Matches
aderdg-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 AMR Testing Script")
7parser.set_defaults(
8 min_depth=3,
9 amr_levels=1,
10 degrees_of_freedom=4,
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.00 # 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="SWE",
26 directory=".",
27 executable="ADERDG-AMR"
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, true);
50""",
51 refinement_criterion="""
52 auto result = ::exahype2::RefinementCommand::Keep;
53 if (x[0] < 0.3) {
54 result = ::exahype2::RefinementCommand::Refine;
55 }
56 return result;
57""",
58 max_eigenvalue="""
59 constexpr double grav = 9.81;
60 const double u = Q[1 + normal] / Q[0];
61 const double c = std::sqrt(grav * Q[0]);
62 return std::max(std::abs(u + c), std::abs(u - c));
63""",
64 flux="""
65 const double ih = 1.0 / Q[0];
66 F[0] = Q[1 + normal];
67 F[1] = Q[1 + normal] * Q[1] * ih;
68 F[2] = Q[1 + normal] * Q[2] * ih;
69 F[3] = 0.0;
70""",
71 ncp="""
72 constexpr double grav = 9.81;
73 BTimesDeltaQ[0] = 0.0;
74 switch (normal) {
75 case 0:
76 BTimesDeltaQ[1] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
77 BTimesDeltaQ[2] = 0.0;
78 break;
79 case 1:
80 BTimesDeltaQ[1] = 0.0;
81 BTimesDeltaQ[2] = grav * Q[0] * (deltaQ[0] + deltaQ[3]);
82 break;
83 }
84 BTimesDeltaQ[3] = 0.0;
85""",
86)
87
88project.add_solver(solver)
89project.set_output_path("solutions")
90
91project.set_global_simulation_parameters(
92 dimensions=2,
93 offset=[0.0, 0.0],
94 size=size,
95 min_end_time=end_time,
96 max_end_time=end_time,
97 first_plot_time_stamp=0.0,
98 time_in_between_plots=plot_interval,
99 periodic_BC=[False, False],
100)
101
102project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
103project.set_Peano4_installation("../../../", mode=peano4.output.string_to_mode(args.build_mode))
104project = project.generate_Peano4_project(verbose=False)
105project.set_fenv_handler(True)
106project.build(make_clean_first=True)