.. _diffusion-laplace_refine_interactive:
diffusion/laplace_refine_interactive.py
=======================================
**Description**
Example of solving Laplace's equation on a block domain refined with level 1
hanging nodes.
The domain is progressively refined towards the edge/face of the block, where
Dirichlet boundary conditions are prescribed by an oscillating function.
Find :math:`u` such that:
.. math::
\int_{\Omega} \nabla v \cdot \nabla u = 0
\;, \quad \forall s \;.
Notes
-----
The implementation of the mesh refinement with level 1 hanging nodes is a
proof-of-concept code with many unresolved issues. The main problem is the fact
that a user needs to input the cells to refine at each level, while taking care
of the following constraints:
- the level 1 hanging nodes constraint: a cell that has a less-refined
neighbour cannot be refined;
- the implementation constraint: a cell with a refined neighbour cannot be
refined.
The hanging nodes are treated by a basis transformation/DOF substitution, which
has to be applied explicitly by the user:
- call ``field.substitute_dofs(subs)`` before assembling and solving;
- then call ``field.restore_dofs()`` before saving results.
Usage Examples
--------------
Default options, 2D, storing results in 'output' directory::
$ python examples/diffusion/laplace_refine_interactive.py output
$ python postproc.py output/hanging.vtk --wireframe -b -d'u,plot_warp_scalar'
Default options, 3D, storing results in 'output' directory::
$ python examples/diffusion/laplace_refine_interactive.py -3 output
$ python postproc.py output/hanging.vtk --wireframe -b --3d
Finer initial domain, 2D, storing results in 'output' directory::
$ python examples/diffusion/laplace_refine_interactive.py --shape=11,11 output
$ python postproc.py output/hanging.vtk --wireframe -b -d'u,plot_warp_scalar'
Bi-quadratic approximation, 2D, storing results in 'output' directory::
$ python examples/diffusion/laplace_refine_interactive.py --order=2 output
# View solution with higher order DOFs removed.
$ python postproc.py output/hanging.vtk --wireframe -b -d'u,plot_warp_scalar'
# View full solution on a mesh adapted for visualization.
$ python postproc.py output/hanging_u.vtk --wireframe -b -d'u,plot_warp_scalar'
:download:`source code `
.. literalinclude:: /../examples/diffusion/laplace_refine_interactive.py