Peano
Loading...
Searching...
No Matches
breaking-dam.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
6from PDE import max_eigenvalue, flux
7
8initial_conditions = """
9 Q[Shortcuts::rho] = 0.1;
10 Q[Shortcuts::rhoU + 0] = 0.0;
11 Q[Shortcuts::rhoU + 1] = 0.0;
12#if DIMENSIONS == 3
13 Q[Shortcuts::rhoU + 2] = 0.0;
14#endif
15 Q[Shortcuts::rhoE] = ((x(0) < 0.5) ? (1.01) : (1.0));
16"""
17
18boundary_conditions = """
19 // Reflective boundary conditions
20 Qoutside[Shortcuts::rho] = Qinside[Shortcuts::rho];
21 Qoutside[Shortcuts::rhoU + 0] = -Qinside[Shortcuts::rhoU + 0];
22 Qoutside[Shortcuts::rhoU + 1] = -Qinside[Shortcuts::rhoU + 1];
23#if DIMENSIONS == 3
24 Qoutside[Shortcuts::rhoU + 2] = -Qinside[Shortcuts::rhoU + 2];
25#endif
26 Qoutside[Shortcuts::rhoE] = Qinside[Shortcuts::rhoE];
27"""
28
29refinement_criterion = """
30 auto result = ::exahype2::RefinementCommand::Keep;
31
32 if (tarch::la::equals(t, 0.0)) {
33 if (x(0) < 0.5) {
34 result = ::exahype2::RefinementCommand::Refine;
35 } else {
36 result = ::exahype2::RefinementCommand::Keep;
37 }
38 }
39
40 return result;
41"""
42
43parser = exahype2.ArgumentParser("ExaHyPE 2 - Finite Volumes Testing Script")
44parser.set_defaults(
45 min_depth=6,
46 degrees_of_freedom=16,
47)
48args = parser.parse_args()
49
50size = [1.0, 1.0, 1.0]
51max_h = 1.1 * min(size) / (3.0**args.min_depth)
52min_h = max_h * 3.0 ** (-args.amr_levels)
53
54fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
55 name="FVSolver",
56 patch_size=args.degrees_of_freedom,
57 unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
58 auxiliary_variables=0,
59 min_volume_h=min_h,
60 max_volume_h=max_h,
61 time_step_relaxation=0.5,
62 use_enclave_tasking=args.enclave_tasking,
63 number_of_enclave_tasks=args.ntasks,
64)
65
66fv_solver.set_implementation(
67 initial_conditions=initial_conditions,
68 boundary_conditions=boundary_conditions,
69 refinement_criterion=refinement_criterion,
70 max_eigenvalue=max_eigenvalue,
71 flux=flux,
72)
73
74project = exahype2.Project(
75 namespace=["tests", "exahype2", "fv"],
76 project_name="BreakingDam",
77 directory=".",
78 executable="ExaHyPE",
79)
80project.add_solver(fv_solver)
81
82if args.number_of_snapshots <= 0:
83 time_in_between_plots = 0.0
84else:
85 time_in_between_plots = args.end_time / args.number_of_snapshots
86 project.set_output_path(args.output)
87
88project.set_global_simulation_parameters(
89 dimensions=args.dimensions,
90 size=size[0 : args.dimensions],
91 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
92 min_end_time=args.end_time,
93 max_end_time=args.end_time,
94 first_plot_time_stamp=0.0,
95 time_in_between_plots=time_in_between_plots,
96 periodic_BC=[
97 args.periodic_boundary_conditions_x,
98 args.periodic_boundary_conditions_y,
99 args.periodic_boundary_conditions_z,
100 ],
101)
102
103project.set_load_balancer(
104 f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
105)
106project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
107project = project.generate_Peano4_project(verbose=False)
108project.output.makefile.set_target_device(args.target_device)
109project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
110project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)