Skip to content

Commit 82c5262

Browse files
authored
Update of fundamentals.md (#169)
* Update fundamentals.md Fixed some typos and wording * Update fundamentals.md Fixed typos and wording. * Update intro.md Fixed typos. * Update nonlinpoisson.md Fixed typos. * Update membrane.md Fixed typos.
1 parent 253edf7 commit 82c5262

File tree

4 files changed

+47
-46
lines changed

4 files changed

+47
-46
lines changed

chapter1/fundamentals.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Authors: Hans Petter Langtangen, Anders Logg
44

55
Adapted to FEniCSx by Jørgen S. Dokken
66

7-
The goal of this tutorial is to solve one of the most basic PDEs, the Poisson equations, with a few lines of code in FEniCSx. We start by introducing the most fundamental FEniCSx objects, such as `Function`, `FunctionSpace`, `TrialFunction` and `TestFunction`, and learn how to write a basic PDE solver.
7+
The goal of this tutorial is to solve one of the most basic PDEs, the Poisson equation, with a few lines of code in FEniCSx. We start by introducing some fundamental FEniCSx objects, such as `Function`, `FunctionSpace`, `TrialFunction` and `TestFunction`, and learn how to write a basic PDE solver.
88
This will include:
99
- How to formulate a mathematical variational problem
1010
- How to apply boundary conditions
@@ -17,11 +17,12 @@ The Poisson equation is the following boundary-value problem
1717
u(\mathbf{x}) &= u_D(\mathbf{x})&& \mathbf{x} \in \partial\Omega
1818
\end{align}
1919

20-
Here, $u=u(\mathbf{x})$ is the unknown function, $f=f(\mathbf{x})$ is a prescribed function, $\nabla^2$ the Laplace operator, often written as $\Delta$, $\Omega$ the spatial domain, and $\partial\Omega$ is the boundary of $\Omega$. The Poisson problem, including both the PDE $-\nabla^2 u = f$ and the boundary condition $u=u_D$ on $\partial\Omega$, is an example of a _boundary-value problem_, which must be precisely state before it makes sense to start solving it numerically with FEniCSx.
20+
Here, $u=u(\mathbf{x})$ is the unknown function, $f=f(\mathbf{x})$ a prescribed function, $\nabla^2$ the Laplace operator
21+
(often written as $\Delta$), $\Omega$ the spatial domain, and $\partial\Omega$ the boundary of $\Omega$. The Poisson problem, including both the PDE, $-\nabla^2 u = f$, and the boundary condition, $u=u_D$ on $\partial\Omega$, is an example of a _boundary-value problem_, which must be precisely stated before we can start solving it numerically with FEniCSx.
2122

22-
In the two dimensional space with coordinates $x$ and $y$, we can expand the Poisson equation as
23+
In the two-dimensional space with coordinates $x$ and $y$, we can expand the Poisson equation as
2324

24-
$ -\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = f(x,y)$
25+
$-\frac{\partial^2 u}{\partial x^2} - \frac{\partial^2 u}{\partial y^2} = f(x,y)$
2526

2627
The unknown $u$ is now a function of two variables, $u=u(x,y)$, defined over the two-dimensional domain $\Omega$.
2728

@@ -35,57 +36,57 @@ Solving a boundary value problem in FEniCSx consists of the following steps:
3536

3637
1. Identify the computational domain $\Omega$, the PDE, and its corresponding boundary conditions and source terms $f$.
3738
2. Reformulate the PDE as a finite element variational problem.
38-
3. Write a Python program defining the computational domain, the boundary conditions, the variational problem and the source terms, using FEniCSx.
39+
3. Write a Python program defining the computational domain, the boundary conditions, the variational problem, and the source terms, using FEniCSx.
3940
4. Run the Python program to solve the boundary-value problem. Optionally, you can extend the program to derive quantities such as fluxes and averages,
4041
and visualize the results.
4142

42-
As we have already covered step 1, we shall now cover step 2-4.
43+
As we have already covered step 1, we shall now cover steps 2-4.
4344

4445
## Finite element variational formulation
4546

4647
FEniCSx is based on the finite element method, which is a general and
47-
efficient mathematical machinery for the numerical solution of
48-
PDEs. The starting point for the finite element methods is a PDE
49-
expressed in _variational form_. For readers not familiar with variational problems, it is suggested to reading a proper book on the finite element method in addition, as this tutorial is meant as a brief introduction to the subject. See the original tutorial {cite}`FenicsTutorial` (Chapter 1.6.2).
48+
efficient mathematical technique for the numerical solution of
49+
PDEs. The starting point for finite element methods is a PDE
50+
expressed in _variational form_. For readers not familiar with variational problems, we suggest reading a proper treatment on the finite element method, as this tutorial is meant as a brief introduction to the subject. See the original tutorial {cite}`FenicsTutorial` (Chapter 1.6.2).
5051

5152
The basic recipe for turning a PDE into a variational problem is:
5253
- Multiply the PDE by a function $v$
5354
- Integrate the resulting equation over the domain $\Omega$
54-
- Perform integration by parts of terms with second order derivatives.
55+
- Perform integration by parts of those terms with second order derivatives
5556

5657
The function $v$ which multiplies the PDE is called a _test function_. The unknown function $u$ that is to be approximated is referred to as a _trial function_.
5758
The terms trial and test functions are used in FEniCSx too. The test and trial functions belong to certain _function spaces_ that specify the properties of the functions.
5859

59-
In the present case, we multiply the equation by a test function $v$ and integrate over $\Omega$:
60+
In the present case, we multiply the Poisson equation by a test function $v$ and integrate over $\Omega$:
6061

61-
$\int_\Omega -\nabla^2 u v \mathrm{d} x = \int_\Omega f v ~\mathrm{d} x.$
62+
$\int_\Omega (-\nabla^2 u) v~\mathrm{d} x = \int_\Omega f v~\mathrm{d} x.$
6263

63-
Here $\mathrm{d} x$ denotes the differential element for integration over the domain $\Omega$. We will later let $\mathrm{d} s$ denote the differential element for integration over the boundary of $\Omega$.
64+
Here $\mathrm{d} x$ denotes the differential element for integration over the domain $\Omega$. We will later let $\mathrm{d} s$ denote the differential element for integration over $\partial\Omega$, the boundary of $\Omega$.
6465

65-
A rule of thumb is that when we derive variational formulations is that one tries to keep the order of derivatives of $u$ and $v$ as small as possible.
66+
A rule of thumb when deriving variational formulations is that one tries to keep the order of derivatives of $u$ and $v$ as small as possible.
6667
Here, we have a second-order differential of $u$, which can be transformed to a first derivative by employing the technique of
6768
[integration by parts](https://en.wikipedia.org/wiki/Integration_by_parts).
6869
The formula reads
6970

70-
$ -\int_\Omega (\nabla^2 u)v~\mathrm{d}x
71-
= \int_\Omega\nabla u\cdot\nabla v \mathrm{d}x-
71+
$-\int_\Omega (\nabla^2 u)v~\mathrm{d}x
72+
= \int_\Omega\nabla u\cdot\nabla v~\mathrm{d}x-
7273
\int_{\partial\Omega}\frac{\partial u}{\partial n}v~\mathrm{d}s,$
7374

74-
where $\frac{\partial u}{\partial n}=\nabla u \cdot n$ is the derivative of $u$ in the outward normal direction $n$ on the boundary.
75+
where $\frac{\partial u}{\partial n}=\nabla u \cdot \vec{n}$ is the derivative of $u$ in the outward normal direction $\vec{n}$ on the boundary.
7576

7677
Another feature of variational formulations is that the test function $v$ is required to vanish on the parts of the boundary where the solution $u$ is known. See for instance {cite}`Langtangen_Mardal_FEM_2019`.
7778

78-
In the present problem, this means that $v$ is $0$ on the whole boundary $\partial\Omega$. Thus, the second term in the integration by parts formula is zero, and we have that
79+
In the present problem, this means that $v$ is $0$ on the whole boundary $\partial\Omega$. Thus, the second term in the integration by parts formula vanishes, and we have that
7980

80-
$\int_\Omega \nabla u \cdot \nabla v \mathrm{d} x = \int_\Omega f v~\mathrm{d} x.$
81+
$\int_\Omega \nabla u \cdot \nabla v~\mathrm{d} x = \int_\Omega f v~\mathrm{d} x.$
8182

8283
If we require that this equation holds for all test functions $v$ in some suitable space $\hat{V}$, the so-called _test space_, we obtain a well-defined mathematical problem that uniquely determines the solution $u$ which lies in some function space $V$. Note that $V$ does not have to be the same space as
83-
$\hat{V}$. We call the space $V$ the _trial space_. We refer to the equation above as the _weak form_/_variational form_ of the original boundary value problem. We now properly state our variational problem:
84+
$\hat{V}$. We call the space $V$ the _trial space_. We refer to the equation above as the _weak form_/_variational form_ of the original boundary-value problem. We now properly state our variational problem:
8485
Find $u\in V$ such that
8586

86-
$\int_\Omega \nabla u \cdot \nabla v \mathrm{d} x = \int_\Omega f v\mathrm{d} x\qquad \forall v \in \hat{V}.$
87+
$\int_\Omega \nabla u \cdot \nabla v~\mathrm{d} x = \int_\Omega f v~\mathrm{d} x\qquad \forall v \in \hat{V}.$
8788

88-
For the present problem, the test and trial spaces $V$ and $\hat{V}$ is defined as
89+
For the present problem, the trial and test spaces $V$ and $\hat{V}$ are defined as
8990
\begin{align}
9091
V&=\{v\in H^1(\Omega) \vert v=u_D&&\text{on } \partial \Omega \},\\
9192
\hat{V}&=\{v\in H^1(\Omega) \vert v=0 &&\text{on } \partial \Omega \}.
@@ -99,28 +100,28 @@ such as intervals, triangles, quadrilaterals, tetrahedra and
99100
hexahedra.
100101

101102
The variational problem is a _continuous problem_: it defines the solution $u$ in the infinite-dimensional function space $V$.
102-
The finite element method for the Poisson equation finds an approximate solution of the variational problem by replacing the infinite-dimensional function spaces $V$ and $\hat V$ by _discrete_ (finite dimensional) trial and test spaces $V_h\subset V$ and $\hat{V}_h \subset \hat{V}$. The discrete
103+
The finite element method for the Poisson equation finds an approximate solution of the variational problem by replacing the infinite-dimensional function spaces $V$ and $\hat{V}$ by _discrete_ (finite dimensional) trial and test spaces $V_h\subset V$ and $\hat{V}_h \subset \hat{V}$. The discrete
103104
variational problem reads: Find $u_h\in V_h$ such that
104105
\begin{align}
105-
\int_\Omega \nabla u_h \cdot \nabla v ~\mathrm{d} x &= \int_\Omega fv~ \mathrm{d} x && \forall v \in \hat{V}_h.
106+
\int_\Omega \nabla u_h \cdot \nabla v~\mathrm{d} x &= \int_\Omega fv~\mathrm{d} x && \forall v \in \hat{V}_h.
106107
\end{align}
107108
This variational problem, together with suitable definitions of $V_h$ and $\hat{V}_h$ uniquely define our approximate numerical solution of the Poisson equation.
108109
Note that the boundary condition is encoded as part of the test and trial spaces. This might seem complicated at first glance,
109-
but means that the finite element variational problem and the continuous variational problem looks the same.
110+
but means that the finite element variational problem and the continuous variational problem look the same.
110111

111112
## Abstract finite element variational formulation
112113

113-
We will introduce the following notations for variational problems:
114+
We will introduce the following notation for variational problems:
114115
Find $u\in V$ such that
115116
\begin{align}
116117
a(u,v)&=L(v)&& \forall v \in \hat{V}.
117118
\end{align}
118119
For the Poisson equation, we have:
119120
\begin{align}
120-
a(u,v) &= \int_{\Omega} \nabla u \cdot \nabla v ~\mathrm{d} x,\\
121-
L(v) &= \int_{\Omega} fv ~\mathrm{d} x.
121+
a(u,v) &= \int_{\Omega} \nabla u \cdot \nabla v~\mathrm{d} x,\\
122+
L(v) &= \int_{\Omega} fv~\mathrm{d} x.
122123
\end{align}
123-
From literature $a(u,v)$ is known as the _bilinear form_ and $L(v)$ as a _linear form_.
124+
In the literature $a(u,v)$ is known as the _bilinear form_ and $L(v)$ as a _linear form_.
124125
For every linear problem, we will identify all terms with the unknown $u$ and collect them in $a(u,v)$, and collect all terms with only known functions in $L(v)$.
125126

126127
To solve a linear PDE in FEniCSx, such as the Poisson equation, a user thus needs to perform two steps:

chapter1/membrane.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Deflection of a membrane
22
Authors: Hans Petter Langtangen and Anders Logg.
33

4-
Modified to DOLFINx by Jørgen S. Dokken
4+
Modified for DOLFINx by Jørgen S. Dokken
55

66
In the first FEniCSx program, we solved a simple problem which we could easily use to verify the implementation.
77
In this section, we will turn our attentition to a physically more relevant problem with solutions of a somewhat more exciting shape.
@@ -12,13 +12,13 @@ We would like to compute the deflection $D(x,y)$ of a two-dimensional, circular
1212
\end{align}
1313
Here, $T$ is the tension in the membrane (constant), and $p$ is the external pressure load. The boundary of the membrane has no deflection. This implies that $D=0$ is the boundary condition. We model a localized load as a Gaussian function:
1414
\begin{align}
15-
p(x,y)&=\frac{A}{2\pi\sigma}e^{-\frac{1}{2}\left(\frac{x-x_0}{\sigma}\right)^2-\frac{1}{2}\left(\frac{y-y_0}{\sigma}\right)^2}
15+
p(x,y)&=\frac{A}{2\pi\sigma}e^{-\frac{1}{2}\left(\frac{x-x_0}{\sigma}\right)^2-\frac{1}{2}\left(\frac{y-y_0}{\sigma}\right)^2}.
1616
\end{align}
17-
The parameter $A$ is the amplitude of the pressure, $(x_0, y_0)$ the localization of the maximum point of the load, and $\sigma$ the "width" of $p$. We will take the center $(x_0,y_0)$ to be $(0,R_0)$ for some $0<R_0<R$.
17+
The parameter $A$ is the amplitude of the pressure, $(x_0, y_0)$ the location of the maximum point of the load, and $\sigma$ the "width" of $p$. We will take the center $(x_0,y_0)$ to be $(0,R_0)$ for some $0<R_0<R$.
1818
Then we have
1919
\begin{align}
2020
p(x,y)&=\frac{A}{2\pi\sigma}e^{-\frac{1}{2}\left(\left(\frac{x}{\sigma}\right)^2
21-
+\left(\frac{y-R_0}{\sigma}\right)^2\right)}
21+
+\left(\frac{y-R_0}{\sigma}\right)^2\right)}.
2222
\end{align}
2323
## Scaling the equation
2424

@@ -36,7 +36,7 @@ With $D_e=\frac{AR^2}{8\pi\sigma T}$ and dropping the bars we obtain the scaled
3636
\begin{align}
3737
-\nabla^2 w = 4e^{-\beta^2(x^2+(y-R_0)^2)}
3838
\end{align}
39-
to be solved over the unit disc with $w=0$ on the boundary. Now there are only two parameters to vary the dimensionless extent of the pressure, $\beta$, and the localization of the pressure peak, $R_0\in[0,1]$. As $\beta\to 0$, the solution will approach the special case $1-x^2-y^2$. Given a computed scaed solution $w$, the physical deflection can be computed by
39+
to be solved over the unit disc with $w=0$ on the boundary. Now there are only two parameters which vary the dimensionless extent of the pressure, $\beta$, and the location of the pressure peak, $R_0\in[0,1]$. As $\beta\to 0$, the solution will approach the special case $w=1-x^2-y^2$. Given a computed scaed solution $w$, the physical deflection can be computed by
4040
\begin{align}
41-
D=\frac{AR^2}{8\pi\sigma T}w
41+
D=\frac{AR^2}{8\pi\sigma T}w.
4242
\end{align}

chapter2/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# A Gallery of finite element solvers
22

33
The goal of this chapter is to demonstrate how a range of important PDEs from science and engineering can be quickly solved with a few lines of DOLFINx code.
4-
We will start with the heat equation, then continue with the non-linear Poisson equation, the equations for linear elasticity, the Navier-Stokes equations, and finally look at how to solve systems of nonlinear advection-diffusion-reaction equations. These problems illustrate how to solve time-dependent problems, non-linear problems, vector-values problems and systems of PDEs. For each problem, we derive the variational formulation and express the problem in Python in a way that closely resembels the mathematics.
4+
We will start with the heat equation, then continue with the nonlinear Poisson equation, the equations for linear elasticity, the Navier-Stokes equations, and finally look at how to solve systems of nonlinear advection-diffusion-reaction equations. These problems illustrate how to solve time-dependent problems, nonlinear problems, vector-valued problems and systems of PDEs. For each problem, we derive the variational formulation and express the problem in Python in a way that closely resembles the mathematics.

chapter2/nonlinpoisson.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# A nonlinear Poisson equation
22
Authors: Anders Logg and Hans Petter Langtangen
33

4-
We shall now address how to solve non-linear PDEs. We will see that non-linear problems introduce some subtle differences on how we define the variational form.
4+
We shall now address how to solve nonlinear PDEs. We will see that nonlinear problems introduce some subtle differences in how we define the variational form.
55

66
## The PDE problem
7-
As a model for the solution of non-linear PDEs, we take the following non-linear Poisson equation
7+
As a model for the solution of nonlinear PDEs, we take the following nonlinear Poisson equation
88
\begin{align}
99
- \nabla \cdot (q(u) \nabla u)&=f && \text{in } \Omega,\\
10-
u&=u_D && \text{on } \partial \Omega,
10+
u&=u_D && \text{on } \partial \Omega.
1111
\end{align}
12-
and the coefficients $q(u)$ makes the problem non-linear (unless q(u) is constant in $u$).
12+
The coefficients $q(u)$ make the problem nonlinear (unless $q(u)$ is constant in $u$).
1313

1414
## Variational formulation
15-
As usual, we multiply the PDE by a test function $v\in \hat{V}$, integrate over the domain, and integrate second-order derivatives by parts. The boundary integrals arising from integration by parts vanishes wherever we employ Dirichlet conditions. The resulting variational formulation of our model problem becomes:
15+
As usual, we multiply the PDE by a test function $v\in \hat{V}$, integrate over the domain, and integrate second-order derivatives by parts. The boundary integrals arising from integration by parts vanish wherever we employ Dirichlet conditions. The resulting variational formulation of our model problem becomes:
1616

1717
Find $u\in V$ such that
1818
\begin{align}
@@ -24,14 +24,14 @@ where
2424
\end{align}
2525
and
2626
\begin{align}
27-
V&=\left\{v\in H^1(\Omega)\vert v=u_D \text{on } \partial \Omega \right\}\\
28-
\hat{V}&=\left\{v\in H^1(\Omega)\vert v=0 \text{on } \partial \Omega \right\}
27+
V&=\left\{v\in H^1(\Omega)\vert v=u_D \text{ on } \partial \Omega \right\}\\
28+
\hat{V}&=\left\{v\in H^1(\Omega)\vert v=0 \text{ on } \partial \Omega \right\}
2929
\end{align}
3030

31-
The discrete problem arises as usual by restricting $V$ and $\hat{V}$ to a pair of discrete spaces. The discrete non-linear problem can therefore be written as:
31+
The discrete problem arises as usual by restricting $V$ and $\hat{V}$ to a pair of discrete spaces. The discrete nonlinear problem can therefore be written as:
3232

3333
Find $u_h \in V_h$ such that
3434
\begin{align}
35-
F(u_h, v) &=0 \quad \forall v \in \hat{V}_h,
35+
F(u_h; v) &=0 \quad \forall v \in \hat{V}_h,
3636
\end{align}
37-
with $u_h=\sum_{j=1}^N U_j\phi_j$. Since $F$ is non-linear in $u$, the variational statement gives rise to a system of non-linear algebraic equation in the unknowns $U_1,\dots,U_N$.
37+
with $u_h=\sum_{j=1}^N U_j\phi_j$. Since $F$ is nonlinear in $u$, the variational statement gives rise to a system of nonlinear algebraic equations in the unknowns $U_1,\dots,U_N$.

0 commit comments

Comments
 (0)