Peano
Loading...
Searching...
No Matches
radially-growing-region.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(
7 "ExaHyPE 2 - Finite Volumes Dynamic AMR Testing Script"
8)
9parser.set_defaults(
10 min_depth=2,
11 amr_levels=2,
12 degrees_of_freedom=4,
13 end_time=3.0,
14)
15args = parser.parse_args()
16
17max_patch_size = 1.1 * 10.0 / (3.0**args.min_depth)
18max_h = max_patch_size / args.degrees_of_freedom
19min_h = 0.9 * max_h * 3.0 ** (-args.amr_levels)
20
21initial_conditions = """
22 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
23 Q[i] = 0.0;
24 }
25"""
26
27boundary_conditions = """
28 for (int i = 0; i < NumberOfUnknowns + NumberOfAuxiliaryVariables; i++) {
29 Qoutside[i] = Qinside[i];
30 }
31"""
32
33refinement_criterion = """
34 auto result = ::exahype2::RefinementCommand::Keep;
35
36 tarch::la::Vector<DIMENSIONS, double> centre0(5.0);
37#if DIMENSIONS == 3
38 constexpr double maxRadius = 7.5;
39#else
40 constexpr double maxRadius = 5.0;
41#endif
42
43 constexpr double startRadius = MaxAdmissibleVolumeH;
44 constexpr double growthRate = 0.25; // radius = startRadius + growthRate*t
45 constexpr double bandWidth = 0.05;
46
47 const double frontRadius = std::min(maxRadius, startRadius + growthRate * t);
48 const double r = tarch::la::norm2(x - centre0);
49
50 if (tarch::la::equals(t, 0.0)) {
51 if (r < startRadius) {
52 result = ::exahype2::RefinementCommand::Refine;
53 }
54 } else {
55 const double innerEraseRadius = std::max(0.0, frontRadius - bandWidth);
56 if (r >= innerEraseRadius and r <= frontRadius) {
57 result = ::exahype2::RefinementCommand::Refine;
58 } else if (r < innerEraseRadius) {
59 result = ::exahype2::RefinementCommand::Erase;
60 }
61 }
62
63 return result;
64"""
65
66fv_solver = exahype2.solvers.fv.godunov.GlobalFixedTimeStep(
67 name="FVSolver",
68 patch_size=args.degrees_of_freedom,
69 unknowns=1,
70 auxiliary_variables=0,
71 min_volume_h=min_h,
72 max_volume_h=max_h,
73 normalised_time_step_size=0.01,
74)
75
76fv_solver.set_implementation(
77 initial_conditions=initial_conditions,
78 boundary_conditions=boundary_conditions,
79 refinement_criterion=refinement_criterion,
80 flux="""
81 for (int i = 0; i < NumberOfUnknowns; i++) {
82 F[i] = 0.0;
83 }
84""",
85 max_eigenvalue="return 1.0;",
86)
87
88project = exahype2.Project(
89 namespace=["tests", "exahype2", "fv"],
90 project_name=".",
91 directory=".",
92 executable="ExaHyPE",
93)
94project.add_solver(fv_solver)
95
96if args.number_of_snapshots <= 0:
97 time_in_between_plots = 0.0
98else:
99 time_in_between_plots = args.end_time / args.number_of_snapshots
100 project.set_output_path(args.output)
101
102project.set_global_simulation_parameters(
103 dimensions=args.dimensions,
104 size=[10.0, 10.0, 10.0][0 : args.dimensions],
105 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
106 min_end_time=args.end_time,
107 max_end_time=args.end_time,
108 first_plot_time_stamp=0.0,
109 time_in_between_plots=time_in_between_plots,
110 periodic_BC=[
111 False,
112 False,
113 False,
114 ],
115)
116
117project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
118project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
119project = project.generate_Peano4_project(verbose=False)
120project.output.makefile.set_target_device(args.target_device)
121project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)