48 figure, axes = plt.subplots(figsize=(6.5, 7.4))
49 for i
in range(-HALO, PATCH_SIZE + HALO):
50 for j
in range(-HALO, PATCH_SIZE + HALO):
51 outside_x = i < 0
or i >= PATCH_SIZE
52 outside_y = j < 0
or j >= PATCH_SIZE
53 if outside_x
and outside_y:
54 colour, hatch = COLOUR_HALO_CORNER,
"////"
55 elif outside_x
or outside_y:
56 colour, hatch = COLOUR_HALO,
None
58 colour, hatch = COLOUR_PATCH,
None
65 edgecolor=COLOUR_GRID,
73 for distance
in range(1, HALO + 1):
74 for dx, dy
in [(distance, 0), (-distance, 0), (0, distance), (0, -distance)]:
77 (centre[0] + dx + 0.15, centre[1] + dy + 0.15),
80 facecolor=COLOUR_DIFFERENCES,
87 (centre[0] + 0.15, centre[1] + 0.15),
90 facecolor=COLOUR_GRID_CELL,
96 for offset, linewidth
in [(-HALO, 2.0), (0, 2.0)]:
97 size = PATCH_SIZE - 2 * offset
110 axes.set_xlim(-margin, PATCH_SIZE + margin)
111 axes.set_ylim(-margin, PATCH_SIZE + margin)
112 axes.set_aspect(
"equal")
114 total_size = PATCH_SIZE + 2 * HALO
116 f
"Reconstructed patch, {total_size}x{total_size}:\n"
117 f
"{PATCH_SIZE}x{PATCH_SIZE} patch plus a halo of {HALO}",
122 Patch(facecolor=COLOUR_PATCH, edgecolor=COLOUR_GRID, label=
"patch"),
123 Patch(facecolor=COLOUR_HALO, edgecolor=COLOUR_GRID, label=
"halo"),
125 facecolor=COLOUR_HALO_CORNER,
126 edgecolor=COLOUR_GRID,
128 label=
"halo corner (not used)",
131 facecolor=COLOUR_GRID_CELL,
133 label=
"grid cell to update",
136 facecolor=COLOUR_DIFFERENCES,
138 label=
"fourth-order central differences",
146 figure.tight_layout(rect=(0, 0.13, 1, 1))
147 output = os.path.join(
148 os.path.dirname(os.path.abspath(__file__)),
149 "central-differences-with-runge-kutta-stencil.png",
151 figure.savefig(output, dpi=100, bbox_inches=
"tight")
153 print(
"Wrote", output)
166 tempfile.gettempdir(),
167 "central-differences-with-runge-kutta-illustrations-log.md",
170 with tempfile.TemporaryDirectory()
as directory:
172 [
"illustration"],
"illustration", directory=directory
177 solver.add_pde_term(exahype2.api.DirichletBoundaryConditions(stateless=
False))
179 solver, patch_size=PATCH_SIZE, rk_order=2
183 [
"illustration"],
"illustration",
"illustration", directory=directory
185 exahype2_project.set_global_simulation_parameters(
190 periodic_BC=[
False,
False],
193 solver.numerical_scheme.construct_output(
194 exahype2_project, peano_project, time_step
198 title=
"Time stepping task graph of CentralDifferencesWithRungeKutta (rk_order=2)"
200 output = os.path.join(
201 os.path.dirname(os.path.abspath(__file__)),
202 "central-differences-with-runge-kutta-time-step-task-graph.png",
204 plt.gcf().savefig(output, dpi=90)
206 print(
"Wrote", output)