Peano
Loading...
Searching...
No Matches
cartesian.py
Go to the documentation of this file.
2import peano4, exahype2
3import os
4
5from exahype2.solvers.aderdg.ADERDG import Polynomials
6
7import Elastic
8
9min_level = 3
10max_depth = 0
11order = 5
12precision = "float"
13e_t = 2.0
14plot_dt = 0.1
15polynomials = "legendre"
16use_tracers = True
17
18size = [ 9.0, 9.0, 9.0] # thousand meters
19offset = [-4.5, 0., -4.5] # thousand meters
20
21unknowns = {"v": 3, "sigma": 6}
22auxiliary_variables = {"rho":1, "cp": 1, "cs": 1}
23
24max_h = 1.1 * min(size) / (3.0**min_level)
25min_h = max_h / (3.0**max_depth)
26
27project = exahype2.Project( ["applications", "exahype2", "exaseis"], ".",
28 executable="LOH_level_"+str(min_level)+"_order_"+str(order)+"_"+polynomials+"_precision_"+str(precision) )
29
30theSolver=exahype2.solvers.aderdg.GlobalAdaptiveTimeStep(
31 name="elastic", order=order,
32 unknowns=unknowns, auxiliary_variables=auxiliary_variables,
33 min_cell_h=min_h, max_cell_h=max_h, time_step_relaxation=0.9,
34)
35
36theSolver.add_kernel_optimisations(
37 is_linear=True, polynomials=(Polynomials.Gauss_Lobatto if polynomials=="lobatto" else Polynomials.Gauss_Legendre)
38 ,precision=precision
39)
40
41theSolver.set_implementation(
42 initial_conditions = Elastic.initial(),
43 boundary_conditions = Elastic.boundary(),
44 max_eigenvalue = Elastic.eigenvalue(),
45 flux = Elastic.flux(),
46 refinement_criterion = Elastic.refinement_criterion(),
47 riemann_solver = Elastic.riemann_solver(),
48 number_of_point_sources = 1,
49 point_source = Elastic.point_source(),
50 init_point_source_location = Elastic.init_point_source()
51)
52
53theSolver.add_user_solver_includes("""
54#include "../ExaSeis_core/Numerics/cartesianRoutines.h"
55#include "../ExaSeis_core/Numerics/riemannsolverIsotropic.h"
56""")
57
58project.add_solver(theSolver)
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 project.add_action_set_to_timestepping(
79 exahype2.tracer.DiscontinuousGalerkinTracing(
80 tracer_particles, theSolver,
81 project_on_tracer_properties_kernel="::exahype2::dg::projectAllValuesOntoParticle"
82 )
83 )
84
85 project.add_action_set_to_timestepping(
86 exahype2.tracer.DumpTracerIntoDatabase(
87 particle_set=tracer_particles, solver=theSolver,
88 filename="tracers/Cartesian_level_"+str(min_level)+"_order_"+str(order)+"_"+polynomials+"_precision_"+str(precision),
89 data_delta_between_two_snapsots=1e16, time_delta_between_two_snapsots=0.01,
90 output_precision=10, clear_database_after_flush=False
91 )
92 )
93
94 # project.add_action_set_to_timestepping(
95 # exahype2.tracer.NewDGTracer(
96 # coordinates=[
97 # [0.000, 0., 0.693], [0.000, 0., 5.543], [0.000, 0., 10.392],
98 # [0.490, 0., 0.490], [3.919, 0., 3.919], [7.348, 0., 7.3480],
99 # [0.577, 0., 0.384], [4.612, 0., 3.075], [8.647, 0., 5.7640]
100 # ],
101 # solver=theSolver,
102 # filename="tracers/Cartesian_level_"+str(min_level)+"_order_"+str(order)+"_"+polynomials+"_precision_"+str(precision),
103 # data_delta_between_two_snapshots=1e16, time_delta_between_two_snapshots=0.01,
104 # output_precision=10, clear_database_after_flush=False
105 # ))
106
107 if not os.path.exists("tracers"):
108 os.makedirs("tracers")
109
110 theSolver._abstract_solver_user_declarations += "double QuadraturePoints1d[Order+1];"
111 # TODO: This is not good in many ways. A private variable member of the solver should not be hijacked like this!
112 theSolver._start_simulation_implementation += """
113 std::copy_n(
114 kernels::{{SOLVER_NAME}}::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes,
115 (Order+1),
116 QuadraturePoints1d
117 );"""
118
119if plot_dt > 0.0:
120 project.set_output_path("solutions")
121
122project.set_global_simulation_parameters(
123 dimensions = 3,
124 offset = offset[0:3],
125 size = size[0:3],
126 min_end_time = e_t,
127 first_plot_time_stamp = 0.0,
128 time_in_between_plots = plot_dt,
129)
130
131project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration()")
132project.set_build_mode(peano4.output.CompileMode.Release)
133peano4_project = project.generate_Peano4_project(verbose=False)
134peano4_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