This notebook demonstrates experimental DOLFIN features (http://fenicsproject.org) for X3DOM (http://www.x3dom.org/) and HTML output. The objective is to support the interactive display of meshes and simulation outputs in web browsers, including in Jupyter notebooks.
These examples use a development version of DOLFIN at https://bitbucket.org/garth-wells/dolfin-coding-days, and the branch x3dom
.
In [1]:
from IPython.core.display import HTML
from dolfin import *
In [2]:
# Create mesh in 2D
mesh = UnitSquareMesh(32, 32)
In [3]:
# Display mesh
HTML(X3DOM.html(mesh))
Out[3]:
In [4]:
# Create mesh in 3D and display
mesh = UnitCubeMesh(16, 16, 16)
HTML(X3DOM.html(mesh))
Out[4]:
In [5]:
# Create a contour plot
e = Expression("sin(x[0])*sin(x[1])", degree=1)
V = FunctionSpace(mesh, "Lagrange", 1)
u = Function(V)
u.interpolate(e)
HTML(X3DOM.html(u))
In [ ]: