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