Peano
cartesian.py
Go to the documentation of this file.
1 
2 import peano4, exahype2
3 import os
4 
5 from exahype2.solvers.aderdg.ADERDG import Polynomials
6 
7 import Elastic
8 
9 min_level = 3
10 max_depth = 0
11 order = 5
12 precision = "float"
13 e_t = 2.0
14 plot_dt = 0.1
15 polynomials = "legendre"
16 use_tracers = True
17 
18 size = [ 9.0, 9.0, 9.0] # thousand meters
19 offset = [-4.5, 0., -4.5] # thousand meters
20 
21 unknowns = {"v": 3, "sigma": 6}
22 auxiliary_variables = {"rho":1, "cp": 1, "cs": 1}
23 
24 max_h = 1.1 * min(size) / (3.0**min_level)
25 min_h = max_h / (3.0**max_depth)
26 
27 project = exahype2.Project( ["applications", "exahype2", "exaseis"], ".",
28  executable="LOH_level_"+str(min_level)+"_order_"+str(order)+"_"+polynomials+"_precision_"+str(precision) )
29 
30 theSolver=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 
36 theSolver.add_kernel_optimisations(
37  is_linear=True, polynomials=(Polynomials.Gauss_Lobatto if polynomials=="lobatto" else Polynomials.Gauss_Legendre)
38  ,solution_persistent_storage_precision=precision
39  ,predictor_computation_precisions=[precision]
40  ,corrector_computation_precision=precision
41 )
42 
43 theSolver.set_implementation(
44  initial_conditions = Elastic.initial(),
45  boundary_conditions = Elastic.boundary(),
46  max_eigenvalue = Elastic.eigenvalue(),
47  flux = Elastic.flux(),
48  refinement_criterion = Elastic.refinement_criterion(),
49  riemann_solver=Elastic.riemann_solver(),
50  number_of_point_sources = 1,
51  point_source=Elastic.point_source(),
52  init_point_source_location=Elastic.init_point_source()
53 )
54 
55 theSolver.add_user_solver_includes("""
56 #include "../ExaSeis_core/Numerics/cartesianRoutines.h"
57 #include "../ExaSeis_core/Numerics/riemannsolverIsotropic.h"
58 """)
59 
60 project.add_solver(theSolver)
61 
62 if use_tracers:
63  # tracer_particles = project.add_tracer(name="Tracer", attribute_count=12)
64 
65  # project.add_action_set_to_initialisation(
66  # exahype2.tracer.InsertParticlesByCoordinates(
67  # particle_set=tracer_particles,
68  # coordinates=[
69  # [0.000, 0., 0.693], [0.000, 0., 5.543], [0.000, 0., 10.392],
70  # [0.490, 0., 0.490], [3.919, 0., 3.919], [7.348, 0., 7.3480],
71  # [0.577, 0., 0.384], [4.612, 0., 3.075], [8.647, 0., 5.7640]
72  # ]
73  # )
74  # )
75 
76  # project.add_action_set_to_timestepping(
77  # peano4.toolbox.particles.api.UpdateParallelState(particle_set=tracer_particles)
78  # )
79 
80  # project.add_action_set_to_timestepping(
81  # exahype2.tracer.DiscontinuousGalerkinTracing(
82  # tracer_particles, theSolver,
83  # project_on_tracer_properties_kernel="::exahype2::dg::projectAllValuesOntoParticle"
84  # )
85  # )
86 
87  # project.add_action_set_to_timestepping(
88  # exahype2.tracer.DumpTracerIntoDatabase(
89  # particle_set=tracer_particles, solver=theSolver,
90  # filename="tracers/Cartesian_level_"+str(min_level)+"_order_"+str(order)+"_"+polynomials+"_precision_"+str(precision),
91  # data_delta_between_two_snapsots=1e16, time_delta_between_two_snapsots=0.01,
92  # output_precision=10, clear_database_after_flush=False
93  # )
94  # )
95 
96  project.add_action_set_to_timestepping(
97  exahype2.tracer.NewDGTracer(
98  coordinates=[
99  [0.000, 0., 0.693], [0.000, 0., 5.543], [0.000, 0., 10.392],
100  [0.490, 0., 0.490], [3.919, 0., 3.919], [7.348, 0., 7.3480],
101  [0.577, 0., 0.384], [4.612, 0., 3.075], [8.647, 0., 5.7640]
102  ],
103  solver=theSolver,
104  filename="tracers/Cartesian_level_"+str(min_level)+"_order_"+str(order)+"_"+polynomials+"_precision_"+str(precision),
105  data_delta_between_two_snapshots=1e16, time_delta_between_two_snapshots=0.01,
106  output_precision=10, clear_database_after_flush=False
107  ))
108 
109  if not os.path.exists("tracers"):
110  os.makedirs("tracers")
111 
112  theSolver._abstract_solver_user_declarations += "double QuadraturePoints1d[Order+1];"
113  theSolver._constructor_implementation += """
114  std::copy_n(
115  kernels::{{SOLVER_NAME}}::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes,
116  (Order+1),
117  QuadraturePoints1d
118  );"""
119 
120 if plot_dt > 0.0:
121  project.set_output_path("solutions")
122 
123 project.set_global_simulation_parameters(
124  dimensions = 3,
125  offset = offset[0:3],
126  size = size[0:3],
127  min_end_time = e_t,
128  first_plot_time_stamp = 0.0,
129  time_in_between_plots = plot_dt,
130 )
131 
132 project.set_load_balancer("new ::exahype2::LoadBalancingConfiguration()")
133 project.set_Peano4_installation("../../../../", peano4.output.CompileMode.Release)
134 peano4_project = project.generate_Peano4_project(verbose=False)
135 peano4_project.build(make_clean_first=True)
def point_source()
Definition: Elastic.py:137
def flux()
Definition: Elastic.py:73
def refinement_criterion()
Definition: Elastic.py:116
def initial()
Definition: Elastic.py:3
def init_point_source()
Definition: Elastic.py:149
def eigenvalue()
Definition: Elastic.py:68
def boundary()
Definition: Elastic.py:32
def riemann_solver()
Definition: Elastic.py:156
static double min(double const x, double const y)
str
Definition: ccz4.py:55