Peano
Loading...
Searching...
No Matches
two-radially-growing-regions.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#if DIMENSIONS == 3
37 tarch::la::Vector<DIMENSIONS, double> centre0 = {2.0, 5.0, 5.0};
38 tarch::la::Vector<DIMENSIONS, double> centre1 = {8.0, 5.0, 5.0};
39 constexpr double maxRadius = 7.5;
40#else
41 tarch::la::Vector<DIMENSIONS, double> centre0 = {2.0, 5.0};
42 tarch::la::Vector<DIMENSIONS, double> centre1 = {8.0, 5.0};
43 constexpr double maxRadius = 5.0;
44#endif
45
46 constexpr double startRadius = MaxAdmissibleVolumeH;
47 constexpr double growthRate = 0.25; // radius = startRadius + growthRate*t
48 constexpr double bandWidth = 0.10;
49
50 const double frontRadius = std::min(maxRadius, startRadius + growthRate * t);
51 const double r0 = tarch::la::norm2(x - centre0);
52 const double r1 = tarch::la::norm2(x - centre1);
53
54 auto command0 = ::exahype2::RefinementCommand::Keep;
55 auto command1 = ::exahype2::RefinementCommand::Keep;
56
57 if (tarch::la::equals(t, 0.0)) {
58 if (r0 < startRadius) command0 = ::exahype2::RefinementCommand::Refine;
59 if (r1 < startRadius) command1 = ::exahype2::RefinementCommand::Refine;
60 } else {
61 const double innerEraseRadius = std::max(0.0, frontRadius - bandWidth);
62
63 if (r0 >= innerEraseRadius and r0 <= frontRadius) {
64 command0 = ::exahype2::RefinementCommand::Refine;
65 } else if (r0 < innerEraseRadius) {
66 command0 = ::exahype2::RefinementCommand::Erase;
67 }
68
69 if (r1 >= innerEraseRadius and r1 <= frontRadius) {
70 command1 = ::exahype2::RefinementCommand::Refine;
71 } else if (r1 < innerEraseRadius) {
72 command1 = ::exahype2::RefinementCommand::Erase;
73 }
74 }
75
76 if (command0 == ::exahype2::RefinementCommand::Refine or command1 == ::exahype2::RefinementCommand::Refine) {
77 result = ::exahype2::RefinementCommand::Refine;
78 } else if (command0 == ::exahype2::RefinementCommand::Erase or command1 == ::exahype2::RefinementCommand::Erase) {
79 result = ::exahype2::RefinementCommand::Erase;
80 } else {
81 result = ::exahype2::RefinementCommand::Keep;
82 }
83
84 return result;
85"""
86
87fv_solver = exahype2.solvers.fv.godunov.GlobalFixedTimeStep(
88 name="FVSolver",
89 patch_size=args.degrees_of_freedom,
90 unknowns=1,
91 auxiliary_variables=0,
92 min_volume_h=min_h,
93 max_volume_h=max_h,
94 normalised_time_step_size=0.01,
95)
96
97fv_solver.set_implementation(
98 initial_conditions=initial_conditions,
99 boundary_conditions=boundary_conditions,
100 refinement_criterion=refinement_criterion,
101 flux="""
102 for (int i = 0; i < NumberOfUnknowns; i++) {
103 F[i] = 0.0;
104 }
105""",
106 max_eigenvalue="return 1.0;",
107)
108
109project = exahype2.Project(
110 namespace=["tests", "exahype2", "fv"],
111 project_name=".",
112 directory=".",
113 executable="ExaHyPE",
114)
115project.add_solver(fv_solver)
116
117if args.number_of_snapshots <= 0:
118 time_in_between_plots = 0.0
119else:
120 time_in_between_plots = args.end_time / args.number_of_snapshots
121 project.set_output_path(args.output)
122
123project.set_global_simulation_parameters(
124 dimensions=args.dimensions,
125 size=[10.0, 10.0, 10.0][0 : args.dimensions],
126 offset=[0.0, 0.0, 0.0][0 : args.dimensions],
127 min_end_time=args.end_time,
128 max_end_time=args.end_time,
129 first_plot_time_stamp=0.0,
130 time_in_between_plots=time_in_between_plots,
131 periodic_BC=[
132 False,
133 False,
134 False,
135 ],
136)
137
138project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration")
139project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
140project = project.generate_Peano4_project(verbose=False)
141project.output.makefile.set_target_device(args.target_device)
142project.build(make=True, make_clean_first=True, throw_away_data_after_build=True)