| 1 |
This demo illustrates how to: |
| 2 |
|
| 3 |
* Solve a linear partial differential equation |
| 4 |
* Read mesh and subdomains from file |
| 5 |
* Create and apply Dirichlet and periodic boundary conditions |
| 6 |
|
| 7 |
The solution for u in this demo will look as follows: |
| 8 |
|
| 9 |
.. image:: ../plot_u.png |
| 10 |
|
| 11 |
Equation and problem definition |
| 12 |
------------------------------- |
| 13 |
|
| 14 |
The Poisson equation is the canonical elliptic partial differential |
| 15 |
equation. For a domain :math:`\Omega \subset \mathbb{R}^n` with |
| 16 |
boundary :math:`\partial \Omega = \Gamma_{D} \cup \Gamma_{P}`, the |
| 17 |
Poisson equation with particular boundary conditions reads: |
| 18 |
|
| 19 |
.. math:: |
| 20 |
- \nabla \cdot (\nabla u) &= f \quad {\rm in} \ \Omega, \\ |
| 21 |
u &= 0 \quad {\rm on} \ \Gamma_{D}, \\ |
| 22 |
u(0, y) &= u(1, y) \quad {\rm on} \ \Gamma_{P}. \\ |
| 23 |
|
| 24 |
Here, :math:`f` is a given source function. The most standard |
| 25 |
variational form of Poisson equation reads: find :math:`u \in V` such |
| 26 |
that |
| 27 |
|
| 28 |
.. math:: |
| 29 |
|
| 30 |
a(u, v) = L(v) \quad \forall \ v \in V, |
| 31 |
|
| 32 |
where :math:`V` is a suitable function space and |
| 33 |
|
| 34 |
.. math:: |
| 35 |
|
| 36 |
a(u, v) &= \int_{\Omega} \nabla u \cdot \nabla v \, {\rm d} x, \\ |
| 37 |
L(v) &= \int_{\Omega} f v \, {\rm d} x. |
| 38 |
|
| 39 |
The expression :math:`a(u, v)` is the bilinear form and :math:`L(v)` |
| 40 |
is the linear form. It is assumed that all functions in :math:`V` |
| 41 |
satisfy the Dirichlet boundary conditions (:math:`u = 0 \ {\rm on} \ |
| 42 |
\Gamma_{D}`). |
| 43 |
|
| 44 |
In this demo, we shall consider the following definitions of the input |
| 45 |
functions, the domain, and the boundaries: |
| 46 |
|
| 47 |
* :math:`\Omega = [0,1] \times [0,1]` (a unit square) |
| 48 |
* :math:`\Gamma_{D} = \{(x, 0) \cup (x, 1) \subset \partial \Omega\}` (Dirichlet boundary) |
| 49 |
* :math:`\Gamma_{P} = \{(0, y) \cup (1, y) \subset \partial \Omega\}` (Periodic boundary) |
| 50 |
* :math:`f = x \sin(5.0 \pi y) + \exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)` (source term) |