6. Exercises#
6.1. Get started with Netgen-Opencascade geometric modeling#
Consult the documentation, Section 4.4: https://docu.ngsolve.org/latest/i-tutorials/index.html#Geometric-modeling-and-mesh-generation
Create some geometric models of your choice in 2D and 3D
Generate meshes
Give names to material and boundary regions. Execute
mesh.Materials()andmesh.Boundaries()for verification.
6.2. Experiment with CoefficientFunctions#
Consult documentation https://docu.ngsolve.org/latest/i-tutorials/unit-1.2-coefficient/coefficientfunction.html
Compute the volume and center of gravity of your geometries using the NGSolve -
Integrate(func, mesh)functionality
6.3. Work with GridFunctions#
Define an \(H^1\) finite element space of some order on \(\Omega = (0,1)^2\)
Define a
GridFunctionin this space, and interpolate \(u(x,y) = \exp(-x^2 - y^2)\)Compute the \(L_2\)-norm of the interpolation error \(u - I_h u\).
Study convergence of the interpolation error depending on the mesh-size and the polynomial order of the space (generate plots).
Study convergence in the \(H^1\)-norm
Find a way to compute \(\int_{\partial \Omega} | \partial_n u- \partial_n I_h u) |^2\).
6.4. Linear Algebra#
Compute the Euklidean norm of the coefficient vector of the gridfunction set to the function above. Once use NGSolve functions, the other time use numpy
6.5. Experiments with BilienarForms and LinearForms#
Create a
GridFunctiongfu and interpolate \(xy\) to itDefine
LinearForm\(f : V \rightarrow {\mathbb R} : v \mapsto \int_\Omega 1 v \, dx\)Compute \(f(gfu)\) using
InnerProductof the vectors. Explain what you observe.Define a
BilinearForm\(A : V \times V \rightarrow {\mathbb R} : (u,v) \mapsto \int_\Omega u v + \nabla u \nabla v \, dx\)Compute \(\|u \|_{H^1}^2 = \| u \|_{L_2}^2 + \| \nabla u \|_{L_2}^2\) in two kinds: Once using
Integrate, and then using the bilinear-form.
6.6. Computing dual norms#
Define the
LinearForm\(f : V \rightarrow {\mathbb R} : v \mapsto \int_{\partial \Omega} v \, ds\)The canonical norm for the linear-form is the dual norm
\[ \| f \|_{V^\ast} := \sup_{v \in V} \frac{f(v)}{\|v \|_V}. \]Proof that the supremum is attained for \(w\) satisfying \((w,v)_V = f(v) \; \forall \, v \in V\), i.e. the solution of a variational problem.
Compute the dual norm by replacing the space \(V\) by a sequence of finite element spaces (refinement in \(h\) and/or \(p\)). Try with norms \(\| \cdot \|_{L_2}\) and \(\| \cdot \|_{H^1}\).