Peano
Loading...
Searching...
No Matches
LOH1.py
Go to the documentation of this file.
2import peano4, exahype2
3import os, sys
4
5from exahype2.solvers.aderdg.ADERDG import Polynomials
6
7sys.path.insert(0, os.path.abspath("../../applications/exaseis/cartesian"))
8import Elastic
9
10parser = exahype2.ArgumentParser("ExaHyPE 2 - ADER-DG Coupled Solvers Testing Script")
11parser.set_defaults(
12 min_depth=2,
13 degrees_of_freedom=6,
14 number_of_snapshots=0,
15)
16args = parser.parse_args()
17
18order = args.degrees_of_freedom - 1
19
20if args.build_mode == "Debug":
21 end_time = 0.1
22else:
23 end_time = 2.0
24
25polynomials = "legendre"
26use_tracers = True
27
28offset = [-2.025, 0.0, -2.025]
29size = [12.15, 12.15, 12.15]
30
31unknowns = {"v": 3, "sigma": 6}
32auxiliary_variables = {"rho":1, "cp": 1, "cs": 1}
33
34max_h = 1.1 * min(size) / (3.0**args.min_depth)
35min_h = max_h * 3.0 ** (-args.amr_levels)
36
37project = exahype2.Project(["tests", "exahype2", "aderdg"], ".",
38 executable="coupled_LOH1" )
39
40hpSolver=exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
41 name="hpElastic", order=order,
42 unknowns=unknowns, auxiliary_variables=auxiliary_variables,
43 min_cell_h=min_h, max_cell_h=max_h, time_step_relaxation=0.9
44)
45
46hpSolver.add_kernel_optimisations(
47 precision = "fp64"
48)
49
50lpSolver=exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
51 name="lpElastic", order=order,
52 unknowns=unknowns, auxiliary_variables=auxiliary_variables,
53 min_cell_h=min_h, max_cell_h=max_h, time_step_relaxation=0.9
54)
55
56lpSolver.add_kernel_optimisations(
57 precision = "fp32"
58)
59
60if use_tracers:
61 tracer_particles = project.add_tracer(name="Tracer", particle_attributes=12)
62
63 project.add_action_set_to_initialisation(
64 exahype2.tracer.InsertParticlesByCoordinates(
65 particle_set=tracer_particles,
66 coordinates=[
67 [0.000, 0., 0.693], [0.000, 0., 5.543], [0.000, 0., 10.392],
68 [0.490, 0., 0.490], [3.919, 0., 3.919], [7.348, 0., 7.3480],
69 [0.577, 0., 0.384], [4.612, 0., 3.075], [8.647, 0., 5.7640]
70 ]
71 )
72 )
73
74 project.add_action_set_to_timestepping(
75 peano4.toolbox.particles.api.UpdateParallelState(particle_set=tracer_particles)
76 )
77
78 if not os.path.exists("tracers"):
79 os.makedirs("tracers")
80
81
82from fuseADERSolvers import fuseADERSolvers
83fuseADERSolvers(hpSolver, lpSolver, """
84 ( marker.getX()[0] < DomainOffset[0] + 9.1*marker.getH()[0] and
85 marker.getX()[1] < 8.1*marker.getH()[1] and
86 marker.getX()[2] < DomainOffset[2] + 11.1*marker.getH()[2])
87""", """
88 ( marker.getX()[0] > DomainOffset[0] + 8.9*marker.getH()[0] or
89 marker.getX()[1] > 7.9*marker.getH()[1] or
90 marker.getX()[2] > DomainOffset[2] + 10.9*marker.getH()[2])
91"""
92)
93
94
95for theSolver in [hpSolver, lpSolver]:
96
97 theSolver.set_implementation(
98 initial_conditions = Elastic.initial(),
99 boundary_conditions = Elastic.boundary(),
100 max_eigenvalue = Elastic.eigenvalue(),
101 flux = Elastic.flux(),
102 refinement_criterion = Elastic.refinement_criterion(),
103 riemann_solver=Elastic.riemann_solver(),
104 number_of_point_sources = 1,
105 point_source=Elastic.point_source(),
106 init_point_source_location=Elastic.init_point_source()
107 )
108
109 theSolver.add_kernel_optimisations(
110 is_linear=True, polynomials=(Polynomials.Gauss_Lobatto if polynomials=="lobatto" else Polynomials.Gauss_Legendre)
111 )
112
113 theSolver.add_user_solver_includes("""
114 #include "../../applications/exaseis/ExaSeis_core/Numerics/cartesianRoutines.h"
115 #include "../../applications/exaseis/ExaSeis_core/Numerics/riemannsolverIsotropic.h"
116 """)
117
118 project.add_solver(theSolver)
119
120 if use_tracers:
121 project.add_action_set_to_timestepping(
122 exahype2.tracer.DiscontinuousGalerkinTracing(
123 tracer_particles, theSolver,
124 project_on_tracer_properties_kernel="::exahype2::dg::projectAllValuesOntoParticle"
125 )
126 )
127
128 project.add_action_set_to_timestepping(
129 exahype2.tracer.DumpTracerIntoDatabase(
130 particle_set=tracer_particles, solver=theSolver,
131 filename="tracers/Cartesian_l"+str(args.min_depth)+"_o"+str(order)+"_"+polynomials+theSolver.get_name_of_global_instance(),
132 data_delta_between_two_snapsots=1e16, time_delta_between_two_snapsots=0.01,
133 output_precision=10, clear_database_after_flush=False
134 )
135 )
136
137 theSolver._abstract_solver_user_declarations += "double QuadraturePoints1d[Order+1];"
138 theSolver._start_simulation_implementation += """
139 std::copy_n(
140 kernels::{{SOLVER_NAME}}::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes,
141 (Order+1),
142 QuadraturePoints1d
143 );"""
144
145# sys.path.insert(0, os.path.abspath("./coupling"))
146# from coupling import StaticCoupling
147# limiter = StaticCoupling(
148# name = "limitingSolver",
149# regularSolver = hpSolver,
150# limitingSolver = lpSolver,
151# limiting_criterion_implementation = """
152# // return
153# return // 9x8x11
154# x[0] > -2.025 && x[0] < 2.025 &&
155# x[1] < 3.600 &&
156# x[2] > -2.025 && x[2] <= 2.925
157# ;
158# """
159# )
160# project.add_solver(limiter)
161
162
163if args.number_of_snapshots <= 0:
164 time_in_between_plots = 0.0
165else:
166 time_in_between_plots = end_time / args.number_of_snapshots
167 project.set_output_path(args.output)
168
169project.set_global_simulation_parameters(
170 dimensions = 3,
171 offset = offset[0:3],
172 size = size[0:3],
173 min_end_time = end_time,
174 first_plot_time_stamp = 0.0,
175 time_in_between_plots = time_in_between_plots,
176)
177
178project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration()")
179project.set_build_mode(mode=peano4.output.string_to_mode(args.build_mode))
180peano4_project = project.generate_Peano4_project("False")
181peano4_project.build(make_clean_first=True)
eigenvalue()
Definition Elastic.py:68
riemann_solver()
Definition Elastic.py:156
initial()
Definition Elastic.py:3
boundary()
Definition Elastic.py:32
refinement_criterion()
Definition Elastic.py:116
init_point_source()
Definition Elastic.py:149
point_source()
Definition Elastic.py:137
flux()
Definition Elastic.py:73