Peano 4
Loading...
Searching...
No Matches
Project.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
5
6import dastgen2
7
8import os
9import sys
10
11import exahype2.grid
13
14from exahype2.solvers.aderdg.ADERDG import ADERDG
15from exahype2.solvers.aderdg.kernelgenerator import Configuration
16
17
18class Project(object):
19 """!
20
21 ExaHyPE 2 project
22
23 Represents an ExaHyPE2 project. An ExaHyPE2 project is a Peano4
24 project with a particular set of actions (algorithmic phases)
25 that you can choose from and with particular solver types. It
26 realises a builder mechanism, i.e. you build up your ExaHyPE2
27 project and then you finally tell the project "give me the Peano4
28 project". From hereon, you can use this Peano4 project to actually
29 set up the Peano4 application.
30
31 The project will have a marker per cell that encodes stuff alike
32 a boundary marker. But it is also used to coordinate different
33 solver types.
34
35 @see generate_Peano4_project()
36 """
37
38 def __init__(self, namespace, project_name, executable, directory="."):
39 self._project = peano4.Project(namespace, project_name, directory)
40 self._project.output.makefile.add_cmake_core_library("ExaHyPE2Core")
41
42 self._solvers = []
43 self._domain_offset = [0.0, 0.0, 0.0]
44 self._domain_size = [1.0, 1.0, 1.0]
45 self._dimensions = 2
52 self._log_filter_file = "exahype.log-filter"
53 self._number_of_threads = "tarch::multicore::Core::UseDefaultNumberOfThreads"
54 self._multicore_orchestration = "tarch::multicore::orchestration::createDefaultStrategy()"
55 self._timeout = 3600
56 self._gpus = []
57 self._additional_includes = [ "tarch/logging/LogFilterFileReader.h",
58 "tarch/multicore/orchestration/StrategyFactory.h",
59 "tarch/accelerator/Device.h"
60 ]
62 self._build_mode = peano4.output.CompileMode.Asserts
63 self._executable_name = executable
64 self._periodic_BC = [False, False, False]
65 self._plot_filters = []
66 self._output_path = "./"
70
71 self.create_grid = peano4.solversteps.Step("CreateGrid", False)
72 self.init_grid = peano4.solversteps.Step("InitGrid", False)
74 "CreateGridButPostponeRefinement", False
75 )
77 "CreateGridAndConvergeLoadBalancing", False
78 )
79 self.plot_solution = peano4.solversteps.Step("PlotSolution", False)
81
82
83 def set_load_balancing(self, load_balancer_name, load_balancer_arguments=""):
84 """
85 load_balancer_name: string
86 Should be full-qualified name of the load balancer.
87 By default, I recommend to pass "toolbox::loadbalancing::strategies::RecursiveSubdivision".
88
89 load_balancer_arguments: string
90 If your load balancing requires parameters, add them
91 here. It is a string that will be copied into the C++ class instantiation.
92 Please add the brackets yourself, i.e. "(3,4,5)" is fine, but "3,4,5" is not.
93 The only exception is the empty parameter list. Here, you can/should simply
94 add the empty string.
95 """
96 self._load_balancer_name = load_balancer_name
97 self._load_balancer_arguments = load_balancer_arguments
98
99
100 def set_log_filter_file(self, file_name):
101 """! Set a log filter file name
102 Pass in the empty string, if you want the code to use the hard-coded
103 defaults.
104 """
105 self._log_filter_file = file_name
106
107
108 def set_number_of_threads(self, value):
109 """! Set number of threads to use
110 Pass in number of threads (positive integer) or a string such as
111 "tarch::multicore::Core::UseDefaultNumberOfThreads".
112 """
113 self._number_of_threads = value
114
115
117 """! Set orchestration
118 value has to be a string which creates an orchestration object,
119 i.e., an object of the type tarch::multicore::orchestration::Orchestration.
120 You can either create it directly (in this case you need to add a new),
121 or you can use a factory method such as
122 "tarch::multicore::orchestration::StrategyFactory::createDefaultStrategy()".
123 """
124 self._multicore_orchestration = value
125
126
127 def set_timeout(self, value):
128 """! Set timeout
129 value has to be a number greater or equal to zero, this then sets the
130 timeout in seconds after which a node waiting for an MPI message shall
131 quit an shutdown the whole application with an error report.
132 If zero is passed, this feature is switched off and nodes will wait
133 indefinitely.
134 """
135 if value < 0:
136 raise Exception("Timeout has to be greater or equal to 0")
137 self._timeout = value
138
139
140 def set_gpus(self, value):
141 """! Set GPUs to be used
142 value is a list of integers or the empty list if you want the code to
143 use all GPUs that are visible to a rank.
144 """
145 self._gpus = value
146
147
148 """
149 The standard extensions that I use for both Peano and ExaHyPE.
150 """
151 LibraryDebug = "_debug"
152 LibraryRelease = ""
153 LibraryTrace = "_trace"
154 LibraryAsserts = "_asserts"
155 LibraryStats = "_stats"
156
157 def set_Peano4_installation(self, src_path, mode=peano4.output.CompileMode.Release):
158 """
159 src_path: string
160 Path (relative or absolute) to the src directory of Peano. This path
161 should hold both the headers (in subdirectories) and all the static
162 libraries.
163
164 mode: peano4.output.CompileMode
165 """
166 self._Peano_src_directory = src_path
167 self._build_mode = mode
168
169 def add_solver(self, solver):
170 self._solvers.append(solver)
171
172 def add_plot_filter(self, offset, size, frequency=1):
173 """
174 Add a new filter to Peano/ExaHyPE
175
176 offset: (float,float,float)
177
178 size: (float,float,float)
179
180 frequency: int
181 A positive value. Peano makes snapshots every dt simulation
182 units. This is something you specify once per simulation. But
183 you might decide only to splot every k of these snapshots.
184 """
185 new_entry = "{{"
186 new_entry += str(offset[0])
187 for i in offset[1:]:
188 new_entry += ","
189 new_entry += str(i)
190 new_entry += "},{"
191 new_entry += str(size[0])
192 for i in size[1:]:
193 new_entry += ","
194 new_entry += str(i)
195 new_entry += "},"
196 new_entry += str(frequency)
197 new_entry += "}"
198
199 self._plot_filters.append(new_entry)
200
202 self._solvers = []
203 self._project.cleanup()
204
206 """
207 We export ExaHyPE's constants. Besides the constants from ExaHyPE,
208 I also export some parameters from Peano onto the ExaHyPE constants
209 file. Therefore, it is important that you parse the configure output
210 before we export the constants.
211 """
212 self._project.constants.clear()
213 offset_string = "{" + str(self._domain_offset[0])
214 size_string = "{" + str(self._domain_size[0])
215 for i in range(1, self._dimensions):
216 offset_string += ","
217 size_string += ","
218 offset_string += str(self._domain_offset[i])
219 size_string += str(self._domain_size[i])
220 offset_string += "}"
221 size_string += "}"
222 self._project.constants.add_include("""#include <bitset>""")
223 self._project.constants.add_include("""#include "tarch/la/Vector.h" """)
224 self._project.constants.add_include("""#include "peano4/utils/Globals.h" """)
225 self._project.constants.export_const_with_type(
226 "DomainOffset", offset_string, "tarch::la::Vector<Dimensions,double>"
227 )
228 self._project.constants.export_const_with_type(
229 "DomainSize", size_string, "tarch::la::Vector<Dimensions,double>"
230 )
231 self._project.constants.export("MinTerminalTime", str(self._min_terminal_time))
233 self._project.constants.export(
234 "MaxTerminalTime", str(self._max_terminal_time)
235 )
236 else:
237 self._project.constants.export(
238 "MaxTerminalTime", "std::numeric_limits<double>::max()"
239 )
240 self._project.constants.export(
241 "FirstPlotTimeStamp", str(self._first_plot_time_stamp)
242 )
243 self._project.constants.export(
244 "TimeInBetweenPlots", str(self._time_in_between_plots)
245 )
246 self._project.constants.export("PlotterPrecision", str(self._plotter_precision))
247 self._project.constants.export_boolean_sequence("PeriodicBC", self._periodic_BC)
248
249 build_string = "python3 "
250 for i in sys.argv:
251 build_string += " "
252 build_string += i
253 self._project.constants.export_string("BuildInformation", build_string)
254 self._project.constants.export_string(
255 "ConfigureInformation", self._project.output.makefile.configure_call
256 )
257
258 self._project.output.readme.add_package_description(
259 """
260
261### ExaHyPE 2
262
263This code uses ExaHyPE in its second generation. The first generation of the
264code was developed through an EU FET HPC project called ExaHyPE. This first
265generation was built on top of Peano in its third generation. The present
266code uses ExaHyPE 2 which is a complete rewrite built on top of Peano 4. We
267do not yet have a release paper for this second generation of ExaHyPE, and
268thus appreciate any citation of the original release paper
269
270 @article{Reinarz:2020:ExaHyPE,
271 title = {ExaHyPE: An engine for parallel dynamically adaptive simulations of wave problems},
272 journal = {Computer Physics Communications},
273 volume = {254},
274 pages = {107251},
275 year = {2020},
276 issn = {0010-4655},
277 doi = {https://doi.org/10.1016/j.cpc.2020.107251},
278 url = {https://www.sciencedirect.com/science/article/pii/S001046552030076X},
279 author = {Anne Reinarz and Dominic E. Charrier and Michael Bader and Luke Bovard and Michael Dumbser and Kenneth Duru and Francesco Fambri and Alice-Agnes Gabriel and Jean-Matthieu Gallard and Sven K\"oppel and Lukas Krenz and Leonhard Rannabauer and Luciano Rezzolla and Philipp Samfass and Maurizio Tavelli and Tobias Weinzierl},
280 keywords = {Hyperbolic, PDE, ADER-DG, Finite volumes, AMR, MPI, TBB, MPI+X},
281 abstract = {ExaHyPE (An Exascale Hyperbolic PDE Engine) is a software engine for solving systems of first-order hyperbolic partial differential equations (PDEs). Hyperbolic PDEs are typically derived from the conservation laws of physics and are useful in a wide range of application areas. Applications powered by ExaHyPE can be run on a student's laptop, but are also able to exploit thousands of processor cores on state-of-the-art supercomputers. The engine is able to dynamically increase the accuracy of the simulation using adaptive mesh refinement where required. Due to the robustness and shock capturing abilities of ExaHyPE's numerical methods, users of the engine can simulate linear and non-linear hyperbolic PDEs with very high accuracy. Users can tailor the engine to their particular PDE by specifying evolved quantities, fluxes, and source terms. A complete simulation code for a new hyperbolic PDE can often be realised within a few hours - a task that, traditionally, can take weeks, months, often years for researchers starting from scratch. In this paper, we showcase ExaHyPE's workflow and capabilities through real-world scenarios from our two main application areas: seismology and astrophysics.
282 Program summary
283 Program title: ExaHyPE-Engine Program Files doi: http://dx.doi.org/10.17632/6sz8h6hnpz.1 Licensing provisions: BSD 3-clause Programming languages: C++, Python, Fortran Nature of Problem: The ExaHyPE PDE engine offers robust algorithms to solve linear and non-linear hyperbolic systems of PDEs written in first order form. The systems may contain both conservative and non-conservative terms. Solution method: ExaHyPE employs the discontinuous Galerkin (DG) method combined with explicit one-step ADER (arbitrary high-order derivative) time-stepping. An a-posteriori limiting approach is applied to the ADER-DG solution, whereby spurious solutions are discarded and recomputed with a robust, patch-based finite volume scheme. ExaHyPE uses dynamical adaptive mesh refinement to enhance the accuracy of the solution around shock waves, complex geometries, and interesting features.
284 }
285 }
286"""
287 )
288
289 for i in self._solvers:
290 self._project.output.readme.add_entry(
291 i.create_readme_descriptor(self._domain_offset[0], self._domain_size[0])
292 )
293 # self._min_volume_h = min_volume_h
294 # self._max_volume_h = max_volume_h
295
297 self._project.output.makefile.set_dimension(self._dimensions)
298 self._project.output.makefile.set_executable_name(self._executable_name)
299
301 self,
302 dimensions,
303 offset,
304 size,
305 min_end_time,
306 first_plot_time_stamp,
307 time_in_between_plots,
308 periodic_BC=[False, False, False],
309 plotter_precision=5,
310 max_end_time=0.0,
311 ):
312 """
313 offset and size should be lists with dimensions double entries.
314
315 first_plot_time_stamp: Float
316 Is irrelevant if time_in_between_plots equals zero
317
318 time_in_between_plots: Float
319 Set to zero if you don't want to have any plots
320
321 max_end_time: Float
322 If you set it zero (or actually any value msmaller than min_end_time), then
323 the code will run until the cell that lags behind the most hits the min time.
324 If you specify a valid max time however, you can stop the sim as soon as the
325 most advanced cell exceeds this threshold.
326 """
327 self._domain_offset = offset
328 self._domain_size = size
329 self._dimensions = dimensions
330
331 assert (
332 len(self._domain_offset) == dimensions
333 ), "domain offset vector and dimensions don't match"
334 assert (
335 len(self._domain_size) == dimensions
336 ), "domain offset vector and dimensions don't match"
337
338 self._max_terminal_time = max_end_time
339 self._min_terminal_time = min_end_time
340 self._first_plot_time_stamp = first_plot_time_stamp
341 self._time_in_between_plots = time_in_between_plots
342 self._periodic_BC = []
343 self._plotter_precision = plotter_precision
344 for d in range(0, dimensions):
345 self._periodic_BC.append(periodic_BC[d])
346 if plotter_precision <= 0:
347 raise Exception("Plotter precision has to be bigger than 0")
348
349 def set_output_path(self, path):
350 self._output_path = path
351 if not os.path.exists(self._output_path):
352 try:
353 os.makedirs(self._output_path)
354 except:
355 print("Couldn't create the defined output path, please ensure that this path exists")
356 if not self._output_path.endswith("/"):
357 self._output_path += "/"
358
359 def add_mainfile_include(self,value):
360 self._additional_includes.append( value )
361
363 """
364 I have to call finishedTraversal() for each tracer set. As tracers
365 are a subclass of DoF, they have a name property.
366 """
367 solverRepositoryDictionary = {
368 "SOLVERS": [],
369 "LOAD_BALANCER": self._load_balancer_name,
370 "LOAD_BALANCER_ARGUMENTS": self._load_balancer_arguments,
371 "PLOT_FILTER": self._plot_filters,
372 "TRACERS": [x.name for x in self._tracer_particles],
373 "LOG_FILTER_FILE": self._log_filter_file,
374 "NUMBER_OF_THREADS": self._number_of_threads,
375 "MULTICORE_ORCHESTRATION": self._multicore_orchestration,
376 "TIMEOUT": self._timeout,
377 "GPUS": self._gpus,
378 "ADDITIONAL_INCLUDES": self._additional_includes,
379 }
380
381 for solver in self._solvers:
382 solverRepositoryDictionary["SOLVERS"].append(
383 (solver._name, solver.get_name_of_global_instance())
384 )
385
386 templatefile_prefix = (
387 os.path.realpath(__file__).replace(".pyc", "").replace(".py", "")
388 )
389 generated_solver_files = (
391 templatefile_prefix + "SolverRepository.template.h",
392 templatefile_prefix + "SolverRepository.template.cpp",
393 "SolverRepository",
394 self._project.namespace + ["repositories"],
395 "repositories",
396 solverRepositoryDictionary,
397 True,
398 )
399 )
400
401 self._project.output.add(generated_solver_files)
402 self._project.output.makefile.add_cpp_file(
403 "repositories/SolverRepository.cpp", generated=True
404 )
405
407 self,
408 name,
409 attribute_count=0,
410 plot=True,
411 sort_descend_invocation_order_within_action_sets=-1,
412 plot_descend_invocation_order_within_action_sets=65536,
413 ):
414 """!
415
416 Add a tracer to the project
417
418 Tracers have to be the very last thing you add to your project.
419 At this point, all solvers have to be added to the project.
420 However, you have to add the tracers prior to any user-defined
421 routines. See docu of register_new_user_defined_algorithmic_step().
422
423 We rely on the particle toolbox. Therefore, our particles have
424 already a position x, a search radius (which we don't usually
425 use here), and a (parallel) state. The search radius determines
426 how Peano sorts particles within the tree, and we can set it to
427 zero here. This ensures that the particle has no real volume and
428 thus is always sieved through to the finest grid level.
429
430 @see peano4.toolbox.particles.Particle
431
432
433 ## Projection of data onto particles and database dumping
434
435 The projection onto the particle has to be realised separatedly, as
436 it depends on the solver variant chosen. The same holds for the
437 dump of particle data into a database if this shall happen
438 on-the-fly.
439
440 Most bigger applications add their solvers an add_tracer() operation,
441 which takes all of this domain knowledge into account. This
442 add_tracer() then forwards to this routine, adding further
443 behaviour.
444
445 See the class application.exahype2.ccz.CCZ4Solver and its derived
446 variants for examples.
447
448
449 ## Moving particles
450
451 Tracers in ExaHyPE can move, though they do not have to move. Even if
452 they move, they never have a native velocity, i.e. their velocity will
453 always be a projection of an ExaHyPE solution. We are talking about
454 tracers after all and not about a proper PIC approach. Due to this
455 constraint, we do not need a velocity vector. However, we need an
456 additional enumeration which clarifies if a
457 particle has moved already or not. This enumeration is needed by the
458 particle update routines. Obviously, nothing stops you from adding
459 a separate velocity field to the tracer object and thus to redefine
460 this behaviour.
461
462
463 ## ExaHyPE-specific particle attributes
464
465 We add each
466 particle a number which is a tuple consisting of the tree number
467 (on which tree has a particle been generationed plus what was the
468 tree-local number of this particle at the time). Through this
469 tuple, we can track tracers later on even if they move accross
470 domains.
471
472 We can plot the data - if there is data to be tracked - directly,
473 as it is a large double array. For the index, we have to type cast
474 the data, as this is a tuple of integers, and Peano's VTK plotter
475 supports only double vectors.
476
477 @see peano4.toolbox.particles.PlotParticlesInVTKFormat.add_attribute_to_plot()
478
479
480 ## Action set order
481
482 We add the particle ordering with descend order -1. This should do the job
483 for most setups, but we might be wrong. The following action sets are
484 automatically added:
485
486 - UpdateParallelState is added to each and every time step and plotting
487 sweep. As we also add
488 - peano4.toolbox.particles.api.UpdateParticleGridAssociation_LiftDrop to each and every time step,
489 particles can move at any point. We always resort them immediately.
490
491 Both action sets are assigned the standard priority of sort_descend_invocation_order_within_action_sets.
492
493
494 ## Arguments
495
496 name: String
497 Has to be a unique name for this tracer
498
499 attribute_count: integer
500 Number of attributes that we track per particle (scalar values added
501 pre particle). Can be 0 if you don't want any attributes.
502
503 h and noise:
504 See tracer.InsertParticles
505
506 plot: Boolean
507 If this flag is set, ExaHyPE dumps the particles as vtu files whenever
508 it writes patch files. You can switch this behaviour off. A lot of codes
509 do so if they dump the tracer data independently into another database
510 anyway.
511
512 sort_descend_invocation_order_within_action_sets: Integer
513 You have to clarify what the priority of the tracer is within the
514 action sets. By default, all ExaHyPE solvers start with priority
515 0 and then up to n. So you are fine with using the default of -1
516 which means that the tracer precedes any solver. However, there
517 might be cases where you wanna move the priorities manually.
518
519 Returns the particle set that you can use to modify further
520 """
521 particle = peano4.toolbox.particles.Particle(name)
522
523 if attribute_count > 0:
524 particle_attr = peano4.dastgen2.Peano4DoubleArray(
525 "data", str(attribute_count)
526 )
527 particle.data.add_attribute(particle_attr)
528
529 particle.data.add_attribute(
530 dastgen2.attributes.Enumeration("MoveState", ["NotMovedYet", "Moved"])
531 )
532
533 particle_number = peano4.dastgen2.Peano4IntegerArray("number", "2")
534 particle.data.add_attribute(particle_number)
535
536 particles = peano4.toolbox.particles.ParticleSet(particle)
537
538 self._project.datamodel.add_global_object(particle)
539 self._project.datamodel.add_vertex(particles)
540
541 self.plot_solution.use_vertex(particles)
542 self.init_grid.use_vertex(particles)
543 self.perform_time_step.use_vertex(particles)
544 self.create_grid.use_vertex(particles)
545 self.create_grid_but_postpone_refinement.use_vertex(particles)
546 self.create_grid_and_converge_lb.use_vertex(particles)
547
548 #
549 # Initialisation
550 #
551 self.init_grid.add_action_set(
553 )
554
555 update_particle_association_action_set = (
557 )
558 update_particle_association_action_set.descend_invocation_order = sort_descend_invocation_order_within_action_sets
559 update_particle_association_action_set.parallel = True
560
561 update_particle_parallel_state_action_set = (
563 )
564 update_particle_parallel_state_action_set.descend_invocation_order = (
565 sort_descend_invocation_order_within_action_sets
566 )
567 update_particle_parallel_state_action_set.parallel = True
568
569 #
570 # Move particles
571 #
572 self.perform_time_step.add_action_set(update_particle_association_action_set)
573 self.perform_time_step.add_action_set(update_particle_parallel_state_action_set)
574
575 #
576 # Plotter: The timestamp here is slightly wrong, as I use the min time stamp. It
577 # really should be the time stamp of the underlying solver. However, tracers are
578 # not tied to one solver, so I have to find a quantity that makes sense. If the
579 # user requres the time stamp, they have to add this one as data field to the
580 # particle
581 #
582 if plot:
584 filename=name,
585 particle_set=particles,
586 time_stamp_evaluation="repositories::getMinTimeStamp()",
587 additional_includes="""
588#include "repositories/SolverRepository.h"
589""",
590 )
591 if attribute_count > 0:
592 particle_plotter.add_attribute_to_plot(particle_attr, attribute_count)
593 particle_plotter.add_attribute_to_plot(
594 particle_number, 2, "tarch::la::convertScalar<double>(p->getNumber())"
595 )
596 particle_plotter.descend_invocation_order = plot_descend_invocation_order_within_action_sets
597 self.plot_solution.add_action_set(particle_plotter)
598
599 self.plot_solution.add_action_set(update_particle_association_action_set)
600 self.plot_solution.add_action_set(update_particle_parallel_state_action_set)
601
602 self._tracer_particles.append(particle)
603 self._tracer_particle_sets.append(particles)
604
605 return particles
606
607 def add_action_set_to_timestepping(self, action_set):
608 """!
609
610 Add a new action set to the time stepping
611
612 You have to be careful with the priorities, i.e. you might want to
613 use myproject.perform_time_step.max_priority() or myproject.perform_time_step.min_priority()
614 to find out which
615 priority you should assign to action_set.
616
617 """
618 self.perform_time_step.add_action_set(action_set)
619
620 def add_action_set_to_plot_solution(self, action_set):
621 """!
622
623 Add a new action set to the plotting
624
625 """
626 self.plot_solution.add_action_set(action_set)
627
628 def add_action_set_to_initialisation(self, action_set):
629 self.init_grid.add_action_set(action_set)
630
631 def add_action_set_to_create_grid(self, action_set):
632 """!
633
634 Add an action set to create grid
635
636 This routine actually adds an action set to each and every grid
637 creation routine. After all, we distinguish three flavours of it
638
639 - with refinement;
640 - without refinement as we've just refined or split up domain;
641 - without refinement to let load balancing converge.
642
643 """
644 self.create_grid.add_action_set(action_set)
645 self.create_grid_but_postpone_refinement.add_action_set(action_set)
646 self.create_grid_and_converge_lb.add_action_set(action_set)
647
648 def generate_Peano4_project(self, verbose=False):
649 """!
650
651 Construct a Peano 4 project and return it
652
653 Build the Peano4 project, i.e., all the action sets et al that you require
654 to run this ExaHyPE2 application. The project is built within self._project
655 and eventually returned.
656
657 This routine generates a Peano project, i.e. the domain-specific ExaHyPE
658 view is translated into a Peano model. Once you have called this routine,
659 any changes to the ExaHyPE 2 configuration do not propagate into the Peano
660 setup anymore. If you alter the ExaHyPE setup, you have to call
661 generate_Peano4_project() again to get a new snapshot/version of the
662 Peano setup.
663 """
664 # self._project.cleanup()
665
666 self._project.solversteps.add_step(self.create_grid)
667 self._project.solversteps.add_step(self.init_grid)
668 self._project.solversteps.add_step(self.create_grid_but_postpone_refinement)
669 self._project.solversteps.add_step(self.create_grid_and_converge_lb)
670 self._project.solversteps.add_step(self.plot_solution)
671 self._project.solversteps.add_step(self.perform_time_step)
672
673 for solver in self._solvers:
674 print("---------------------------------------")
675 print("Create data for solver " + solver._name)
676 print("---------------------------------------")
677 print(str(solver))
678
679 solver.add_to_Peano4_datamodel(self._project.datamodel, verbose)
680
681 solver.add_use_data_statements_to_Peano4_solver_step(self.create_grid)
682 solver.add_use_data_statements_to_Peano4_solver_step(self.plot_solution)
683 solver.add_use_data_statements_to_Peano4_solver_step(self.perform_time_step)
684 solver.add_use_data_statements_to_Peano4_solver_step(self.init_grid)
685 solver.add_use_data_statements_to_Peano4_solver_step(
687 )
688 solver.add_use_data_statements_to_Peano4_solver_step(
690 )
691
692 solver.add_actions_to_create_grid(
693 self.create_grid, evaluate_refinement_criterion=True
694 )
695 solver.add_actions_to_init_grid(self.init_grid)
696 solver.add_actions_to_create_grid(
698 evaluate_refinement_criterion=False,
699 )
700 solver.add_actions_to_create_grid(
701 self.create_grid_and_converge_lb, evaluate_refinement_criterion=False
702 )
703 solver.add_actions_to_plot_solution(self.plot_solution, self._output_path)
704 solver.add_actions_to_perform_time_step(self.perform_time_step)
705
706 solver.add_implementation_files_to_project(
707 self._project.namespace, self._project.output, self._dimensions
708 )
709
711
712 self._project.main = exahype2.ExaHyPEMain(self._project)
713
714 # maybe use ..
716 self._project.output.makefile.parse_configure_script_outcome(
718 )
719 self.__export_constants()
720
721 # self._project.output.makefile.add_library( "ExaHyPE2Core$(DIMENSIONS)d$(LIBRARY_POSTFIX)", self._Peano_src_directory + "/src/exahype2" )
722 # self._project.output.makefile.add_library( "ToolboxLoadBalancing$(DIMENSIONS)d$(LIBRARY_POSTFIX)", self._Peano_src_directory + "/src/toolbox/loadbalancing" )
723
724 # if self._add_particles_library:
725 # self._project.output.makefile.add_library( "ToolboxParticles$(DIMENSIONS)d$(LIBRARY_POSTFIX)", self._Peano_src_directory + "/src/toolbox/particles" )
726
727 self._project.output.makefile.set_mode(self._build_mode)
728
729 for solver in self._solvers:
730 if isinstance(solver, ADERDG):
731 pathToExaHyPERoot = Configuration.pathToExaHyPERoot
732 if solver._use_BLIS:
733 archname = ""
734 for root, dirs, files in os.walk(pathToExaHyPERoot+ "/submodules/blis/include"):
735 archname = dirs[0]
736 break
737 self._project.output.makefile.add_header_search_path(" " + pathToExaHyPERoot + "/submodules/blis/include/" + archname)
738 self._project.output.makefile.add_linker_flag(pathToExaHyPERoot + "/submodules/blis/lib/" + archname + "/libblis.a")
739 self._project.output.makefile.add_library("-lpthread")
740 elif solver._use_Eigen:
741 self._project.output.makefile.add_header_search_path(" " + pathToExaHyPERoot + "/submodules/eigen")
742 elif solver._use_libxsmm_JIT:
743 self._project.output.makefile.add_header_search_path(" " + pathToExaHyPERoot + "/submodules/libxsmmJIT/include")
744 self._project.output.makefile.add_linker_flag(pathToExaHyPERoot + "/submodules/libxsmmJIT/lib/libxsmm.a")
745 self._project.output.makefile.add_linker_flag(pathToExaHyPERoot + "/submodules/OpenBLAS/libopenblas.a")
746 self._project.output.makefile.add_library("-lpthread")
747 break
748 return self._project
749
750
752 step,
753 ):
754 """! Add all the use operations to new algorithmic step
755
756 Use this routine whenever you have created your own
757 @ref page_architecture "algorithmic step". Please note that the routine
758 should be called after you have created all of your solvers. Otherwise,
759 we'll miss out a few of your solvers and the data access patterns
760 will/might be corrupted. Also all tracers have to be added at this
761 point already.
762
763 The routine has no side-effects, i.e. does not alter the underlying
764 project. It only manipulates the step. Therefore, you can even call it
765 after you have distilled the Peano project from the ExaHyPE project,
766 i.e. after you have called exahype2.Project.generate_Peano4_project().
767
768 @param step: peano4.solversteps.Step
769
770 """
771 for solver in self._solvers:
772 solver.add_use_data_statements_to_Peano4_solver_step(step)
773
774 for tracer_set in self._tracer_particle_sets:
775 step.use_vertex(tracer_set)
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
Definition Enumeration.py:6
ExaHyPE 2 project.
Definition Project.py:18
__generate_solver_repository(self)
I have to call finishedTraversal() for each tracer set.
Definition Project.py:362
add_action_set_to_timestepping(self, action_set)
Add a new action set to the time stepping.
Definition Project.py:607
set_load_balancing(self, load_balancer_name, load_balancer_arguments="")
load_balancer_name: string Should be full-qualified name of the load balancer.
Definition Project.py:83
set_number_of_threads(self, value)
Set number of threads to use Pass in number of threads (positive integer) or a string such as "tarch:...
Definition Project.py:108
set_Peano4_installation(self, src_path, mode=peano4.output.CompileMode.Release)
src_path: string Path (relative or absolute) to the src directory of Peano.
Definition Project.py:157
register_new_user_defined_algorithmic_step(self, step)
Add all the use operations to new algorithmic step.
Definition Project.py:753
add_solver(self, solver)
Definition Project.py:169
set_output_path(self, path)
Definition Project.py:349
__init__(self, namespace, project_name, executable, directory=".")
Definition Project.py:38
add_plot_filter(self, offset, size, frequency=1)
Add a new filter to Peano/ExaHyPE.
Definition Project.py:172
generate_Peano4_project(self, verbose=False)
Construct a Peano 4 project and return it.
Definition Project.py:648
add_tracer(self, name, attribute_count=0, plot=True, sort_descend_invocation_order_within_action_sets=-1, plot_descend_invocation_order_within_action_sets=65536)
Add a tracer to the project.
Definition Project.py:413
set_timeout(self, value)
Set timeout value has to be a number greater or equal to zero, this then sets the timeout in seconds ...
Definition Project.py:127
add_action_set_to_plot_solution(self, action_set)
Add a new action set to the plotting.
Definition Project.py:620
set_multicore_orchestration(self, value)
Set orchestration value has to be a string which creates an orchestration object, i....
Definition Project.py:116
add_action_set_to_create_grid(self, action_set)
Add an action set to create grid.
Definition Project.py:631
add_mainfile_include(self, value)
Definition Project.py:359
set_global_simulation_parameters(self, dimensions, offset, size, min_end_time, first_plot_time_stamp, time_in_between_plots, periodic_BC=[False, False, False], plotter_precision=5, max_end_time=0.0)
offset and size should be lists with dimensions double entries.
Definition Project.py:311
set_log_filter_file(self, file_name)
Set a log filter file name Pass in the empty string, if you want the code to use the hard-coded defau...
Definition Project.py:100
__export_constants(self)
We export ExaHyPE's constants.
Definition Project.py:205
set_gpus(self, value)
Set GPUs to be used value is a list of integers or the empty list if you want the code to use all GPU...
Definition Project.py:140
add_action_set_to_initialisation(self, action_set)
Definition Project.py:628
Represents a Peano 4 project.
Definition Project.py:16
Specialisation of dastgen2.attributes.DoubleArray which relies on Peano's tarch.
Update the parallel state of particles and keep stats of them.