Peano
Loading...
Searching...
No Matches
smooth-convergence.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 + 0.2 * std::cos(2.0 * tarch::la::PI * x[0]);
10 Q[Shortcuts::rhoU + 0] = 1.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] = PRESSURE / (GAMMA - 1) + 0.5 / Q[Shortcuts::rho] * (Q[Shortcuts::rhoU] * Q[Shortcuts::rhoU]);
16"""
17
18boundary_conditions = """
19 // Outflow 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
29parser = exahype2.ArgumentParser("ExaHyPE 2 - Finite Volumes Testing Script")
30parser.set_defaults(
31 min_depth=6,
32 end_time=0.01,
33 time_step_size=0.0001, # Suitable up to roughly min_depth = 6 based on speed of sound and max eigenvalue estimation
34 degrees_of_freedom=16,
35)
36args = parser.parse_args()
37
38size = [0.2, 0.2, 0.2]
39max_h = 1.1 * min(size) / (3.0**args.min_depth)
40min_h = max_h * 3.0 ** (-args.amr_levels)
41
42fv_solver = exahype2.solvers.fv.musclhancock.GlobalFixedTimeStep(
43 name="MUSCLHancockSolver",
44 patch_size=args.degrees_of_freedom,
45 unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
46 auxiliary_variables=0,
47 min_volume_h=min_h,
48 max_volume_h=max_h,
49 normalised_time_step_size=args.time_step_size,
50)
51
52fv_solver.set_implementation(
53 initial_conditions=initial_conditions,
54 boundary_conditions=boundary_conditions,
55 flux=flux,
56 max_eigenvalue=max_eigenvalue,
57 limiter=exahype2.solvers.fv.musclhancock.Limiter.vanalbada,
58)
59
60project = exahype2.Project(
61 namespace=["tests", "exahype2", "fv"],
62 project_name="SmoothConvergence",
63 directory=".",
64 executable="ExaHyPE",
65)
66project.add_solver(fv_solver)
67
68if args.number_of_snapshots <= 0:
69 time_in_between_plots = 0.0
70else:
71 time_in_between_plots = args.end_time / args.number_of_snapshots
72 project.set_output_path(args.output)
73
74project.set_global_simulation_parameters(
75 dimensions=args.dimensions,
76 size=size[0 : args.dimensions],
77 offset=[-0.1, -0.1, -0.1][0 : args.dimensions],
78 min_end_time=args.end_time,
79 max_end_time=args.end_time,
80 first_plot_time_stamp=0.0,
81 time_in_between_plots=time_in_between_plots,
82 periodic_BC=[
83 args.periodic_boundary_conditions_x,
84 args.periodic_boundary_conditions_y,
85 args.periodic_boundary_conditions_z,
86 ],
87)
88
89project.set_load_balancer(
90 f"new ::exahype2::LoadBalancingConfiguration({args.load_balancing_quality}, 1, {args.trees})"
91)
92project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
93project = project.generate_Peano4_project(verbose=False)
94project.output.makefile.set_target_device(args.target_device)
95project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
96project.output.makefile.add_CXX_flag("-DPRESSURE=1.0")
97project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)