--- Begin Message ---
------------------------------------------------------------
revno: 9
committer: Garth N. Wells <gnw20@xxxxxxxxx>
branch nick: fenics-doc
timestamp: Tue 2010-04-27 12:12:29 +0100
message:
Add some source code. Looks nice.
modified:
source/demos/common/pde/poisson.txt
source/demos/cpp/pde/cpp_poisson.rst
--
lp:fenics-doc
https://code.launchpad.net/~fenics-core/fenics-doc/main
You are subscribed to branch lp:fenics-doc.
To unsubscribe from this branch go to https://code.launchpad.net/~fenics-core/fenics-doc/main/+edit-subscription
=== modified file 'source/demos/common/pde/poisson.txt'
--- source/demos/common/pde/poisson.txt 2010-04-27 10:34:48 +0000
+++ source/demos/common/pde/poisson.txt 2010-04-27 11:12:29 +0000
@@ -1,7 +1,9 @@
Explain what the Poisson demo does and how. Link to download code.
-Strong:
+The Poisson equation is the cannonical elliptic partial differential equation.
+For a domain :math:`\Omega \in \mathbb{R}^{n}`, the Poisson equation with
+particular boundary conditions reads:
.. math::
- \nabla^{2} u &= f \quad {\rm in} \ \Omega \\
@@ -9,10 +11,21 @@
\nabla u \cdot \boldsymbol{n} &= h \quad {\rm on} \ \Gamma_{N} \\
-Variational:
+Find :math:`u \in V` such that
+
+.. math::
+ a(u, v) = L(v) \quad \forall v \in V,
+
+where
.. math::
a(u, v) &= \int_{\Omega} \nabla u \cdot \nabla v \, d\Omega \\
L(v) &= \int_{\Omega} f v \, d\Omega + \int_{\Gamma_{N}} h v \, d\Omega
+The expression :math:`a(u, v)` is the bilinear form and :math:`L(v)`
+is the linear form.
+
+In the demo :math:`f = 10\exp(-((x - 0.5)^2 + (y - 0.5)^2) / 0.02)`
+and :math:`h = -\sin(5x)`.
+
=== modified file 'source/demos/cpp/pde/cpp_poisson.rst'
--- source/demos/cpp/pde/cpp_poisson.rst 2010-04-27 10:34:48 +0000
+++ source/demos/cpp/pde/cpp_poisson.rst 2010-04-27 11:12:29 +0000
@@ -9,3 +9,65 @@
.. include:: ../../common/pde/poisson.txt
This text is C++ specific
+
+Some UFL code in ``Poisson.h``
+
+.. code-block:: python
+
+ element = FiniteElement("Lagrange", triangle, 1)
+
+ v = TestFunction(element)
+ u = TrialFunction(element)
+ f = Coefficient(element)
+ g = Coefficient(element)
+
+ a = inner(grad(v), grad(u))*dx
+ L = v*f*dx + v*h*ds
+
+
+Some C++
+
+.. code-block:: c++
+
+ #include <dolfin.h>
+ #include "Poisson.h"
+
+ using namespace dolfin;
+
+Some more C++
+
+.. code-block:: c++
+
+ // Source term (right-hand side)
+ class Source : public Expression
+ {
+ void eval(Array<double>& values, const Array<double>& x) const
+ {
+ double dx = x[0] - 0.5;
+ double dy = x[1] - 0.5;
+ values[0] = 10*exp(-(dx*dx + dy*dy) / 0.02);
+ }
+ };
+
+ // Boundary flux (Neumann boundary condition)
+ class Flux : public Expression
+ {
+ void eval(Array<double>& values, const Array<double>& x) const
+ {
+ values[0] = -sin(5*x[0]);
+ }
+ };
+
+Yet more C++
+
+.. code-block:: c++
+
+ // Sub domain for Dirichlet boundary condition
+ class DirichletBoundary : public SubDomain
+ {
+ bool inside(const Array<double>& x, bool on_boundary) const
+ {
+ return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS;
+ }
+ };
+
--- End Message ---