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