Peano
Loading...
Searching...
No Matches
fv-dynamic-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 - Finite Volumes Dynamic AMR Testing Script")
7available_precisions = ["float", "double"]
8parser.add_argument(
9 "-pr", "--precision", default="double", help="|".join(available_precisions)
10)
11parser.set_defaults(
12 min_depth=3,
13 amr_levels=2,
14 degrees_of_freedom=4,
15 end_time=0.2,
16 number_of_snapshots=0,
17)
18args = parser.parse_args()
19
20max_h = 1.1 / 3.0**args.min_depth
21min_h = max_h * 3.0 ** (-args.amr_levels)
22
23initial_conditions = """
24 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
25 Q[i] = std::sin(x(0) * tarch::la::PI) * std::sin(x(1) * tarch::la::PI)
26#if DIMENSIONS == 3
27 * std::sin(x(2) * tarch::la::PI)
28#endif
29 ;
30 }
31"""
32
33boundary_conditions = """
34 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
35 Qoutside[i] = Qinside[i];
36 }
37"""
38
39refinement_criterion = """
40 auto result = ::exahype2::RefinementCommand::Keep;
41
42#if DIMENSIONS == 3
43 tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5, 0.5};
44#else
45 tarch::la::Vector<DIMENSIONS, double> circleCentre = {0.5, 0.5};
46#endif
47
48 if (tarch::la::equals(t, 0.0)) {
49 if (tarch::la::norm2(x - circleCentre) < 0.1) {
50 result = ::exahype2::RefinementCommand::Refine;
51 }
52 }
53
54 if (tarch::la::greater(t, 0.1) /*and h[0] <= MinAdmissibleVolumeH*/) {
55 if (tarch::la::norm2(x - circleCentre) < 0.1) {
56 result = ::exahype2::RefinementCommand::Erase;
57 }
58 }
59
60 return result;
61"""
62
63fv_solver = exahype2.solvers.fv.godunov.GlobalAdaptiveTimeStep(
64 name="FVSolver",
65 patch_size=args.degrees_of_freedom,
66 unknowns={"rho": 1, "rhoU": args.dimensions, "rhoE": 1},
67 auxiliary_variables=0,
68 min_volume_h=min_h,
69 max_volume_h=max_h,
70 time_step_relaxation=0.5,
71 use_enclave_tasking=args.enclave_tasking,
72 number_of_enclave_tasks=args.ntasks,
73)
74
75fv_solver.set_implementation(
76 initial_conditions=initial_conditions,
77 boundary_conditions=boundary_conditions,
78 refinement_criterion=refinement_criterion,
79 flux="""
80 for (int i = 0; i < NumberOfUnknowns; i++) {
81 F[i] = 0.0;
82 }
83 F[normal] = Q[normal];
84""",
85 max_eigenvalue="return 1.0;",
86)
87
88fv_solver.set_solver_precisions(
89 storage_precision=args.precision, compute_precision=args.precision
90)
91
92project = exahype2.Project(
93 namespace=["tests", "exahype2", "fv"],
94 project_name=".",
95 directory=".",
96 executable="ExaHyPE",
97)
98project.add_solver(fv_solver)
99
100if args.number_of_snapshots <= 0:
101 time_in_between_plots = 0.0
102else:
103 time_in_between_plots = args.end_time / args.number_of_snapshots
104 project.set_output_path(args.output)
105
106project.set_global_simulation_parameters(
107 dimensions=args.dimensions,
108 size=[1.0, 1.0, 1.0][0 : args.dimensions],
109 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
110 min_end_time=args.end_time,
111 max_end_time=args.end_time,
112 first_plot_time_stamp=0.0,
113 time_in_between_plots=time_in_between_plots,
114 periodic_BC=[
115 args.periodic_boundary_conditions_x,
116 args.periodic_boundary_conditions_y,
117 args.periodic_boundary_conditions_z,
118 ],
119)
120
121project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
122project.set_Peano4_installation(
123 "../../../", mode=peano4.output.string_to_mode(args.build_mode)
124)
125project = project.generate_Peano4_project(verbose=False)
126project.set_fenv_handler(args.fpe)
127project.output.makefile.set_target_device(args.target_device)
128project.output.makefile.add_CXX_flag("-DGAMMA=1.4")
129project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)