
This demo illustrates how to

* Import data from file
* Use complex user-defined JIT-compiled expressions

The solution :math:`u` will look like this

.. image:: ../tensorweighted-poisson_u.png
    :scale: 75 %

Equation and problem definition
-------------------------------

The Poisson equation is the canonical elliptic partial differential
equation. For a domain :math:`\Omega \subset \mathbb{R}^n` with
boundary :math:`\partial \Omega = \Gamma_{D} \cup \Gamma_{N}`, the
Poisson equation with variational conductivity :math:`C` and
particular boundary conditions reads:

.. math::

	- \nabla \cdot (C \nabla u) &= f \quad {\rm in} \ \Omega, \\
             u &= 0 \quad {\rm on} \ \Gamma_{D}, \\
             \frac{\partial u}{\partial n} &= 0 \quad {\rm on} \ \Gamma_{N}. \\

Here, :math:`f` is input data and :math:`n` denotes the outward
directed boundary normal. The variational form of the Poisson equation
reads: find :math:`u \in V` such that

.. math::

	a(u, v) = L(v) \quad \forall \ v \in V,

where :math:`V` is a suitable function space and

.. math::

	a(u, v) &= \int_{\Omega} C \nabla u \cdot \nabla v \, {\rm d} x, \\
	L(v)    &= \int_{\Omega} f v \, {\rm d} x.

The expression :math:`a(u, v)` is the bilinear form and :math:`L(v)`
is the linear form. It is assumed that all functions in :math:`V`
satisfy the Dirichlet boundary conditions (:math:`u = 0 \ {\rm on}
\Gamma_{D}`).

In this demo, we shall consider the following definitions of the domain, the boundaries and the input function:

* :math:`\Omega = [0,1] \times [0,1]` (a unit square)
* :math:`\Gamma_{D} = \{(0, y) \cup (1, y) \subset \partial \Omega\}` (Dirichlet boundary)
* :math:`\Gamma_{N} = \{(x, 0) \cup (x, 1) \subset \partial \Omega\}` (Neumann boundary)
* :math:`f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)` (source term).

The conductivity  is a symmetric :math:`2 \times 2` matrix which varies throughout the domain. In the left part of the domain the conductivity is

.. math::

	C = \begin{bmatrix}
			1 & 0.3 \\
			0.3 & 2
		\end{bmatrix}

and in the right part it is

.. math::

	C = \begin{bmatrix}
			3 & 0.5 \\
			0.5 & 4
		\end{bmatrix}.
