Skip to content
Snippets Groups Projects
Commit cc52a9f3 authored by Martin Bauer's avatar Martin Bauer
Browse files

Documentation refactoring [WIP]

parent 30af410a
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ from .assignment import Assignment ...@@ -10,6 +10,7 @@ from .assignment import Assignment
from .sympyextensions import SymbolCreator from .sympyextensions import SymbolCreator
from .datahandling import create_data_handling from .datahandling import create_data_handling
from .kernel_decorator import kernel from .kernel_decorator import kernel
from . import fd
__all__ = ['Field', 'FieldType', 'fields', __all__ = ['Field', 'FieldType', 'fields',
'TypedSymbol', 'TypedSymbol',
...@@ -20,5 +21,6 @@ __all__ = ['Field', 'FieldType', 'fields', ...@@ -20,5 +21,6 @@ __all__ = ['Field', 'FieldType', 'fields',
'Assignment', 'Assignment',
'SymbolCreator', 'SymbolCreator',
'create_data_handling', 'create_data_handling',
'kernel'] 'kernel',
'fd']
...@@ -17,8 +17,7 @@ AssignmentOrAstNodeList = List[Union[Assignment, ast.Node]] ...@@ -17,8 +17,7 @@ AssignmentOrAstNodeList = List[Union[Assignment, ast.Node]]
def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "kernel", type_info='double', def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "kernel", type_info='double',
split_groups=(), iteration_slice=None, ghost_layers=None, split_groups=(), iteration_slice=None, ghost_layers=None,
skip_independence_check=False) -> KernelFunction: skip_independence_check=False) -> KernelFunction:
""" """Creates an abstract syntax tree for a kernel function, by taking a list of update rules.
Creates an abstract syntax tree for a kernel function, by taking a list of update rules.
Loops are created according to the field accesses in the equations. Loops are created according to the field accesses in the equations.
......
...@@ -5,8 +5,7 @@ from tempfile import NamedTemporaryFile ...@@ -5,8 +5,7 @@ from tempfile import NamedTemporaryFile
import base64 import base64
import sympy as sp import sympy as sp
__all__ = ['log_progress', 'make_imshow_animation', 'make_surface_plot_animation', __all__ = ['log_progress', 'make_imshow_animation', 'display_animation', 'set_display_mode']
'display_animation', 'set_display_mode']
def log_progress(sequence, every=None, size=None, name='Items'): def log_progress(sequence, every=None, size=None, name='Items'):
...@@ -98,28 +97,6 @@ def make_imshow_animation(grid, grid_update_function, frames=90, **_): ...@@ -98,28 +97,6 @@ def make_imshow_animation(grid, grid_update_function, frames=90, **_):
return animation.FuncAnimation(fig, partial(update_figure, image=grid), frames=frames) return animation.FuncAnimation(fig, partial(update_figure, image=grid), frames=frames)
def make_surface_plot_animation(run_function, frames=90, interval=30):
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.animation as animation
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x, y, data = run_function(1)
ax.plot_surface(x, y, data, rstride=2, cstride=2, color='b', cmap=cm.coolwarm,)
ax.set_zlim(-1.0, 1.0)
def update_figure(*_):
x_grid, y_grid, d = run_function(1)
ax.clear()
plot = ax.plot_surface(x_grid, y_grid, d, rstride=2, cstride=2, color='b', cmap=cm.coolwarm,)
ax.set_zlim(-1.0, 1.0)
return plot,
return animation.FuncAnimation(fig, update_figure, interval=interval, frames=frames, blit=False)
# ------- Version 1: Embed the animation as HTML5 video --------- ---------------------------------- # ------- Version 1: Embed the animation as HTML5 video --------- ----------------------------------
def display_as_html_video(animation, fps=30, show=True, **_): def display_as_html_video(animation, fps=30, show=True, **_):
......
...@@ -251,3 +251,25 @@ def vector_field_magnitude_animation(run_function, plot_setup_function=lambda *_ ...@@ -251,3 +251,25 @@ def vector_field_magnitude_animation(run_function, plot_setup_function=lambda *_
return im, return im,
return animation.FuncAnimation(fig, update_figure, interval=interval, frames=frames) return animation.FuncAnimation(fig, update_figure, interval=interval, frames=frames)
def surface_plot_animation(run_function, frames=90, interval=30):
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.animation as animation
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x, y, data = run_function(1)
ax.plot_surface(x, y, data, rstride=2, cstride=2, color='b', cmap=cm.coolwarm,)
ax.set_zlim(-1.0, 1.0)
def update_figure(*_):
x_grid, y_grid, d = run_function(1)
ax.clear()
plot = ax.plot_surface(x_grid, y_grid, d, rstride=2, cstride=2, color='b', cmap=cm.coolwarm,)
ax.set_zlim(-1.0, 1.0)
return plot,
return animation.FuncAnimation(fig, update_figure, interval=interval, frames=frames, blit=False)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment