josie.plot package¶
Submodules¶
josie.plot.backend module¶
Backends used to display mesh and mesh results
- class josie.plot.backend.PlotBackend¶
Bases:
object
An abstract interface representing a plot backend
- abstract append(solver, t)¶
Appends a new simulation time state
- Parameters
solver (Solver) – An instance of
Solver
that stores the state of the simulation associated to the time instant tt – The time instant of the simulation state
- abstract plot(mesh)¶
Allocate a drawing instance in order to draw a single image plot. The drawing state is stored in
plot_state
.- Parameters
mesh (Mesh) – The
Mesh
to be displayed
- abstract show(fields)¶
Show on screen a list of fields.
- Parameters
fields (
Union
[List
,str
]) – The list of fields to show. If None, then only the mesh is displayed
- abstract show_all()¶
Show on screen all the fields
- abstract show_grid()¶
Show the grid on screen
- abstract update(solver)¶
Updates the
plot_state
with the state (i.e. the field data stored in the mesh, e.g. cell data) in the Solver.By default each call to
update()
overrides the plot state (in order to save up memory).- Parameters
solver (Solver) – An instance of
Solver
that stores the current state of the simulation
josie.plot.matplotlib module¶
- class josie.plot.matplotlib.AnimateState(fig: Figure, animation: FuncAnimation)¶
Bases:
NamedTuple
A named tuple to store state when calling the
MatplotlibBackend.show()
method- animation: matplotlib.animation.FuncAnimation¶
Alias for field number 1
- fig: matplotlib.figure.Figure¶
Alias for field number 0
- class josie.plot.matplotlib.MatplotlibBackend¶
Bases:
josie.plot.backend.PlotBackend
A
matplotlib
-based backend to plot 2D meshes.- append(solver, t)¶
Appends a new simulation time state
- Parameters
solver (Solver) – An instance of
Solver
that stores the state of the simulation associated to the time instant tt – The time instant of the simulation state
- plot(mesh)¶
Allocate a drawing instance in order to draw a single image plot. The drawing state is stored in
plot_state
.- Parameters
mesh (Mesh) – The
Mesh
to be displayed
- show(fields, fps=25)¶
Show the plots on screen
The logic to plot here is that if
plot_state
is an iterable with only 1 class:StateElement:, then single images are shown. Otherwise an animation is shown.- Parameters
fields (
Union
[List
[str
],str
]) – The list of fields to show. If None, then only the mesh is displayedfps – When animating, the number of frame per second [Default: 25]
- show_all()¶
Show on screen all the fields
- show_grid()¶
Show the grid on screen
- update(solver)¶
Updates the
plot_state
with the state (i.e. the field data stored in the mesh, e.g. cell data) in the Solver.By default each call to
update()
overrides the plot state (in order to save up memory).- Parameters
solver (Solver) – An instance of
Solver
that stores the current state of the simulation
- class josie.plot.matplotlib.PlotState¶
Bases:
object
A class managing the global state of the plot backend
- state_elements¶
A list of
StateElement
objects storing information about the artists to be plotted or animated at each time instant
- collection¶
A global
PatchCollection
used for all the plots
- append(state_elem)¶
A proxy appending a state element to
state_elements
- Parameters
state_elem (
StateElement
) – The element to append
Module contents¶
- class josie.plot.MatplotlibBackend¶
Bases:
josie.plot.backend.PlotBackend
A
matplotlib
-based backend to plot 2D meshes.- plot_state¶
A
PlotState
storing the global state of the plot.
- append(solver, t)¶
Appends a new simulation time state
- Parameters
solver (Solver) – An instance of
Solver
that stores the state of the simulation associated to the time instant tt – The time instant of the simulation state
- plot(mesh)¶
Allocate a drawing instance in order to draw a single image plot. The drawing state is stored in
plot_state
.- Parameters
mesh (Mesh) – The
Mesh
to be displayed
- show(fields, fps=25)¶
Show the plots on screen
The logic to plot here is that if
plot_state
is an iterable with only 1 class:StateElement:, then single images are shown. Otherwise an animation is shown.- Parameters
fields (
Union
[List
[str
],str
]) – The list of fields to show. If None, then only the mesh is displayedfps – When animating, the number of frame per second [Default: 25]
- show_all()¶
Show on screen all the fields
- show_grid()¶
Show the grid on screen
- update(solver)¶
Updates the
plot_state
with the state (i.e. the field data stored in the mesh, e.g. cell data) in the Solver.By default each call to
update()
overrides the plot state (in order to save up memory).- Parameters
solver (Solver) – An instance of
Solver
that stores the current state of the simulation