diff --git a/doc/source/L1_introduction.rst b/doc/source/L1_introduction.rst index 278682d..666b0c0 100644 --- a/doc/source/L1_introduction.rst +++ b/doc/source/L1_introduction.rst @@ -13,8 +13,6 @@ Introduction frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - In this section we provide an introduction that establishes some initial ideas about how the finite element method works and what it is about. @@ -41,8 +39,6 @@ Poisson's equation in the unit square frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - In this introduction we concentrate on the specific model problem of Poisson's equation in the unit square. @@ -50,7 +46,7 @@ Poisson's equation in the unit square. Let `\Omega=[0,1]\times[0,1]`. For a given function `f`, we seek `u` such that - + .. math:: :label: eq:strong_Poisson @@ -63,7 +59,7 @@ to find the corresponding unknown function `u` that satisfies the equation (including the boundary conditions). Here we have combined a mixture of Dirichlet boundary conditions specifying the value of the function `u`, and Neumann boundary conditions specifying the value of -the normal derivative `\partial u/\partial n`. This is because these +the normal derivative `\partial u/\partial n := n \cdot \nabla u`. This is because these two types of boundary conditions are treated differently in the finite element method, and we would like to expose both treatments in the same example. The treatment of boundary conditions is one of the @@ -73,7 +69,7 @@ Triangulations -------------- .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -82,8 +78,6 @@ Triangulations frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - The description of our finite element method starts by considering a triangulation. @@ -102,7 +96,7 @@ Our first finite element space ------------------------------ .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -111,8 +105,6 @@ Our first finite element space frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - The idea is that we will approximate functions which are polynomial (at some chosen degree) when restricted to each triangle, with some chosen continuity conditions between triangles. We shall call the @@ -125,7 +117,7 @@ space. Let `\mathcal{T}` be a triangulation of `\Omega`. Then the P1 finite element space is a space `V_h` containing all functions `v` such that - #. `v\in C^0(\Omega)`, + #. `v\in C^0(\Omega)` the space of continuous functions at every point in `\Omega`, #. `v|_{K_i}` is a linear function for each `K_i\in \mathcal{T}`. We also define the following subspace, @@ -148,7 +140,7 @@ Integral formulations and `L_2` ------------------------------- .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -157,12 +149,10 @@ Integral formulations and `L_2` frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - The finite element method is based upon integral formulations of partial differential equations. Rather than checking if two functions are equal by checking their value at every point, we will just check -that they are equal in an integral sense. We do this by introducing +that they are equal in an integral sense. We do this by introducing the `L^2` norm, which is a way of measuring the "magnitude" of a function. .. proof:definition:: @@ -183,25 +173,25 @@ This motivates us to say that two functions are equal if the `L^2` norm of their difference is zero. It only makes sense to do that if the functions individually have finite `L^2` norm, which then also motivates the `L^2` function space. - + .. proof:definition:: We define `L^2(\Omega)` as the set of functions .. math:: - + L^2(\Omega) = \left\{ f:\|f\|_{L^2(\Omega)}<\infty\right\}, and identify two functions `f` and `g` if `\|f-g\|_{L^2(\Omega)}=0`, in which case we write `f\equiv g` in `L^2`. .. proof:example:: - + Consider the two functions `f` and `g` defined on `\Omega=[0,1]\times[0,1]` with .. math:: - + f(x,y) = \left\{\begin{array}{cc} 1 & x\geq 0.5, \\ 0 & x < 0.5, \\ @@ -210,7 +200,7 @@ motivates the `L^2` function space. 1 & x> 0.5, \\ 0 & x \leq 0.5. \\ \end{array}\right. - + Since `f` and `g` only differ on the line `x=0.5` which has zero area, then `\|f-g\|_{L^2(\Omega)}=0`, and so `f\equiv g` in `L^2`. @@ -218,7 +208,7 @@ Finite element derivative ------------------------- .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -227,8 +217,6 @@ Finite element derivative frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - Functions in `V_h` do not have derivatives everywhere. This means that we have to work with a more general definition (and later we shall learn when it does and does not work). @@ -240,7 +228,7 @@ learn when it does and does not work). `L^2(\Omega)` such that restricted to `K_i`, we have .. math:: - + \frac{\partial^{FE}u}{\partial x_i}|_{K_i}= \frac{\partial u}{\partial x_i}. Here we see why we needed to introduce `L^2`: we have a definition @@ -260,7 +248,7 @@ triangles. This is verified in the following exercises. partial derivatives at every point in `\Omega`). Show that the finite element partial derivative and the usual derivative are equal in `L^2(\Omega)`. - + In view of this second exercise, in this section we will consider all derivatives to be finite element derivatives. In later sections we shall consider an even more general definition of the derivative which @@ -271,7 +259,7 @@ Towards the finite element discretisation ----------------------------------------- .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -280,8 +268,6 @@ Towards the finite element discretisation frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - We will now use the finite element derivative to develop the finite element discretisation. We assume that we have a solution `u` to Equation :eq:`eq:strong_Poisson` that is sufficiently smooth @@ -289,7 +275,26 @@ Equation :eq:`eq:strong_Poisson` that is sufficiently smooth types of solutions to this equation, but this assumption just motivates things for the time being.) -We take `v\in \mathring{V}_h`, multiply by Equation :eq:`eq:strong_Poisson`, and integrate over the domain. Integration by parts in each triangle then gives +We take `v\in \mathring{V}_h`, multiply by Equation :eq:`eq:strong_Poisson`, +and integrate over the domain. + +We then use the following integration by parts result. + +.. proof:theorem:: Integration by parts + + Let `u\in C^1(\Omega)` and `n` an outward normal to the boundary `\partial + \Omega`. Then + + .. math:: + + \int_{\Omega} (- \Delta u) v \, d x = \int_{\Omega} \nabla u \cdot \nabla v + \, dx - \int_{\partial \Omega} v \, (n \cdot \nabla u) \, d S. + + .. proof:proof:: + + See e.g. Brenner and Scott Section 5.1 including weaker assumptions. + +Using this integration by parts in each triangle `K_i` then gives .. math:: @@ -299,7 +304,7 @@ We take `v\in \mathring{V}_h`, multiply by Equation :eq:`eq:strong_Poisson`, and \int_\Omega vf \, d x, where `n` is the unit outward pointing normal to `K_i`. - + Next, we consider each interior edge `f` in the triangulation, formed as the intersection between two neighbouring triangles `K_i\cap K_j`. If `i>j`, then we label the `K_i` side of `f` with a `+`, and @@ -310,20 +315,20 @@ such interior edges, we can rewrite our equation as \int_\Omega \nabla v \cdot \nabla u \, d x - \int_\Gamma vn^+\cdot\nabla u + vn^-\cdot\nabla u \, d S - - \int_{\partial\Omega} vn\cdot \nabla u \, d S + - \int_{\partial\Omega} vn\cdot \nabla u \, d S = \int_\Omega vf \, d x, where `n^{\pm}` is the unit normal to `f` pointing from the `\pm` side into the `\mp` side. Since `n^-=-n^+`, the interior edge integrals vanish. - + Further, on the boundary, either `v` vanishes (at `x=0` and `x=1`) or `n\cdot\nabla u` vanishes (at `y=0` and `y=1`), and we obtain .. math:: - - \int_\Omega \nabla v \cdot \nabla u \, d x - = \int_\Omega vf \, d x. + + \int_\Omega \nabla v \cdot \nabla u \, d x + = \int_\Omega vf \, d x. The finite element approximation is then defined by requiring that this equation holds for all `v\in \mathring{V}_h` and when we approximate @@ -331,7 +336,7 @@ this equation holds for all `v\in \mathring{V}_h` and when we approximate `u_h\in \mathring{V}_h`. .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -340,18 +345,16 @@ this equation holds for all `v\in \mathring{V}_h` and when we approximate frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - .. _def-discrete-poisson: .. proof:definition:: - + The finite element approximation `u_h \in \mathring{V}_h` to the solution `u` of Poisson's equation is defined by - + .. math:: :label: eq:fe_poisson - + \int_\Omega \nabla v \cdot \nabla u_h \, d x = \int_\Omega vf \, d x, \quad \forall v\in \mathring{V}_h. @@ -359,7 +362,7 @@ this equation holds for all `v\in \mathring{V}_h` and when we approximate End of week 1 material .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -368,8 +371,6 @@ this equation holds for all `v\in \mathring{V}_h` and when we approximate frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - We now present some numerical results for the case `f = 2\pi^2\sin(\pi x)\sin(2\pi y)`. @@ -401,7 +402,7 @@ We see that for this example, the error is decreasing as we increase the number of triangles, for the meshes considered. .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -410,8 +411,6 @@ the number of triangles, for the meshes considered. frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - In general, our formulation raises a number of questions. #. Is `u_h` unique? @@ -464,7 +463,7 @@ areas. `u=x(1-x)` on the entire boundary. .. _def-robin: - + .. proof:exercise:: Derive a finite element approximation for the following problem. @@ -477,12 +476,12 @@ areas. in the `1\times 1` square region, with boundary conditions `u+\frac{\partial u}{\partial n}=x(1-x)` on the entire boundary. - + Practical implementation ------------------------ .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -491,8 +490,6 @@ Practical implementation frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - The finite element approximation above is only useful if we can actually compute it. To do this, we need to construct an efficient basis for `P1`, which we call the nodal basis. @@ -534,7 +531,7 @@ it must hold for all basis coefficients `v_i`, and we obtain the matrix-vector system .. math:: - + K\mathrm{u} = \mathrm{f}, where @@ -542,9 +539,9 @@ where .. math:: K_{ij} = \int_\Omega \nabla\phi_i\cdot\nabla\phi_j\, d x, - + \mathrm{u} = \left(u_1,u_2,\ldots,u_{\bar{M}}\right)^T, - + \mathrm{f} = \left(f_1,f_2,\ldots,f_{\bar{M}}\right)^T, \quad f_i = \int_\Omega \phi_i f\, d x. Once we have solved for `\mathrm{u}`, we can use these basis @@ -555,7 +552,7 @@ solution `u_h`, which we shall establish in later sections. This motivates why we care that `u_h` exists and is unique. .. dropdown:: A video recording of the following material is available here. - + .. container:: vimeo .. raw:: html @@ -564,8 +561,6 @@ motivates why we care that `u_h` exists and is unique. frameborder="0" allow="autoplay; fullscreen" allowfullscreen> - Imperial students can also `watch this video on Panopto `__ - Putting solvability aside for the moment, the goal of the implementation sections of this course is to explain how to efficiently form `K` and `\mathrm{f}`, and solve this system. For now @@ -575,7 +570,7 @@ as sums over elements, .. math:: K_{ij} = \sum_{K\in\mathcal{T}}\int_K \nabla \phi_i\cdot\nabla \phi_j \, d x, - + \mathrm{where}\,f_i = \sum_{K\in\mathcal{T}}\int_K \phi_i f \, d x. For each entry in the sum for `K_{ij}`, the integrand is composed @@ -601,4 +596,3 @@ algorithms that can exploit this sparsity. Having set out the main challenges of the computational implementation, we now move on to define and discuss a broader range of possible finite element spaces. - diff --git a/doc/source/P1_poisson.rst b/doc/source/P1_poisson.rst new file mode 100644 index 0000000..cb37b49 --- /dev/null +++ b/doc/source/P1_poisson.rst @@ -0,0 +1,66 @@ +.. default-role:: math + +.. _poisson: + +Revisiting the Poisson problem +============================== + +As well as being an independent field of academic study, the finite +element method plays an important supporting role for solving boundary value +problems in the context of scientific enquiry and engineering design. + +It is therefore important to recognise that most users (scientists, +mathematicians, engineers etc.) of finite element methods are not hugely +interested in the underlying mathematics or implementation, but in actually +solving their own problems! + +Since its inception in the 1960s specialists in finite elements have written an +almost uncountable number of software packages for solving finite element +problems. A small number of these have gone to underpin the now multi-billion +dollar engineering design and analysis software sector. Packages such as +ABAQUS, COMSOL Multiphysics and ADINA are now used everyday by hundreds of +thousands of engineers and scientists across the globe. + +These software packages offer an end-to-end finite element analysis, including +computer-aided design tools, advanced mesh creation capabilities, finite +element solution, post-processing and visualisation. Their focus is primarily +on ease-of-use and robustness. They can solve a pre-defined set of PDEs that +the user can select from, for example the heat equation, or linear elasticity. +Customising the PDE and its discretisation usually requires writing a 'user +element' in a low-level language like C or FORTRAN. Users have little control +or insight into the precise solution algorithms used, and cannot easily move +beyond the capabilities that are provided. Most are closed-source, meaning that +users cannot access or modify the underlying source code. Users with highly +specific and uncommon problems usually still need to 'code their own', as we +did in the implementation exercise. + +In the last decade a new kind of finite element software relying on automatic +code generation techniques has emerged. This type of software is aimed at +engineers, academics and scientists who need to go beyond what fixed +functionality software described above can provide. Two examples are the FEniCS +Project and Firedrake that are written and maintained by groups of academics +and engineers worldwide, including the authors of these notes. + +Although these two packages differ in the details, they share the following key +points: + +.. list: + * That the variational formulation of a finite element problem can be + written in a high-level programming language that closely resembles + mathematics as it is on written on the page. + * That this high-level representation of a finite element problem can be + automatically translated into highly performant computer code that can run + on a variety of computer platforms, from laptops to high-performance + computers. + * That this way of implementing finite element solvers is not only flexible, + fast and less error-prone than writing your own from scratch, but can + actually be quite fun! + +To make a link with what you have already learned in the previous part of the +course, we will begin by solving the Poisson problem in either FEniCSx or +Firedrake, depending on the preferences of your instructor. Please click on the +appropriate link below to access the Python Jupyter Notebook in the Google Colab +environment: + +`Poisson in DOLFINx +`__ diff --git a/doc/source/_themes/finite_element/static/banner.png b/doc/source/_themes/finite_element/static/banner.png index 6cc3dee..2f71985 100644 Binary files a/doc/source/_themes/finite_element/static/banner.png and b/doc/source/_themes/finite_element/static/banner.png differ diff --git a/doc/source/_themes/finite_element/static/banner.svg b/doc/source/_themes/finite_element/static/banner.svg index 72da651..9ec2975 100644 --- a/doc/source/_themes/finite_element/static/banner.svg +++ b/doc/source/_themes/finite_element/static/banner.svg @@ -6,9 +6,9 @@ height="185" id="svg2" version="1.1" - inkscape:version="1.1.1 (c3084ef, 2021-09-22)" + inkscape:version="1.1.2 (b8e25be8, 2022-02-05)" sodipodi:docname="banner.svg" - inkscape:export-filename="/home/dham/src/finite_element_course/doc/source/_themes/finite_element/static/banner.png" + inkscape:export-filename="/Users/jack.hale/docs/num-methods-var-problems/finite-element-course/doc/source/_themes/finite_element/static/banner.png" inkscape:export-xdpi="89.758926" inkscape:export-ydpi="89.758926" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" @@ -1224,16 +1224,16 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.4" - inkscape:cx="565.71429" - inkscape:cy="123.92857" + inkscape:cx="754.28571" + inkscape:cy="134.28571" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" - inkscape:window-width="2560" - inkscape:window-height="1387" - inkscape:window-x="0" + inkscape:window-width="1832" + inkscape:window-height="1234" + inkscape:window-x="2240" inkscape:window-y="25" - inkscape:window-maximized="1" + inkscape:window-maximized="0" inkscape:pagecheckerboard="0" /> @@ -1253,26 +1253,26 @@ transform="translate(0,-867.36218)"> Finite elementsNumerical methodsanalysis and implementation + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:64px;line-height:1.25;font-family:'Gill Sans';-inkscape-font-specification:'Gill Sans Bold';fill:#666666;fill-opacity:1">for variational problems   - - - - - - - - - - - - - - - - - - - - - - - + +