5Create the illustrations of the page "Manipulate an existing solver's steps"
9~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10python3 documentation/exahype2/programmers-guide/manipulate-solver-steps-illustrations.py
11~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13The script writes two PNGs next to it:
15- manipulate-solver-steps-rusanov-original.png: the time stepping task graph
16 of exahype2.api.fv.RusanovWithExplicitEuler as the scheme builds it;
17- manipulate-solver-steps-rusanov-with-step.png: the same graph built by
18 the subclass RusanovWithPostprocessing, which inserts one step after the
19 task carrying exahype2.api.Solver.SolutionUpdateTaskTag. The subclass is
20 the example of the page.
22Both graphs are constructed from the actual numerical scheme, so the
23pictures always match the code. The kernels this requires are generated
24into a temporary directory.
32Here = os.path.dirname(os.path.abspath(__file__))
33sys.path.insert(0, os.path.abspath(os.path.join(Here,
"..",
"..",
"..",
"src")))
38import matplotlib.pyplot
as plt
47 """! The example of the page: insert a step after each solution update"""
52 for anchor
in time_step.find_tasks(exahype2.api.Solver.SolutionUpdateTaskTag):
53 if not anchor.name.startswith(solver.name +
"_"):
56 name=f
"{solver.name}_Postprocess solution",
57 entity=peano4.api.taskgraph.Task.GridEntity.CELL,
60 solver._patch, peano4.api.taskgraph.Task.DataAccess.READ_AND_WRITE
63 toolbox.blockstructured.api.ApplyPointWiselyToPatch(
65 implementation=
"Q[0] = std::max(Q[0], 0.9);",
66 guard=solver.grid_selector.createCellGuard(),
67 additional_includes=solver._get_default_includes()
68 + solver.user_solver_includes,
71 time_step.insert_after(anchor, task)
78 tempfile.gettempdir(),
"manipulate-solver-steps-illustrations-log.md"
80 with tempfile.TemporaryDirectory()
as directory:
82 [
"illustration"],
"illustration", directory=directory
87 solver.numerical_scheme = scheme(solver, 9)
88 exahype2_project = types.SimpleNamespace(periodic_BC=[
True,
True])
90 solver.numerical_scheme.construct_output(
91 exahype2_project, peano_project, time_step
93 time_step.visualise(title=title)
94 output = os.path.join(Here, file_name)
95 plt.gcf().savefig(output, dpi=90)
97 print(
"Wrote", output)
100if __name__ ==
"__main__":
103 "manipulate-solver-steps-rusanov-original.png",
104 "RusanovWithExplicitEuler",
107 RusanovWithPostprocessing,
108 "manipulate-solver-steps-rusanov-with-step.png",
109 "RusanovWithPostprocessing",
The conservative flux F(Q) of a hyperbolic PDE.
The maximum absolute eigenvalue of the flux Jacobian in a given direction, i.e.
Abstract base class for all ExaHyPE 2 solvers.
Finite Volumes with a Rusanov Riemann solver and explicit Euler time stepping, realised over a block-...
_solver
Build the reconstruction tasks befilling the patch_with_halo, which is logically temporary.
The example of the page: insert a step after each solution update.
construct_output(self, exahype2_project, peano_project, time_step)
Has to be implemented by subclass.
Singleton logger for the Peano 4 Python API.
Represents a Peano 4 project.
Holds a sequence of Task instances.
One task within a peano4.api.taskgraph.Graph.
plot_time_step(scheme, file_name, title)
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...