We solve for the laplacian with homogeneous Dirichlet conditions in a domain with a hole
\[ \left\{ \begin{aligned} -\Delta u & = f & \text{on}\;\Omega \;, \\ u & = 0 & \text{on}\;\partial\Omega \;,\\ \end{aligned} \right. \]
where \(u\in\Omega\) is the unknown "trial" function and \(\Omega\) the domain.
The variational formulation reads, find \(u \in H^1_0(\Omega)\) such that \(\forall v \in H^1_0(\Omega)\)
\[ \int_\Omega \nabla u \cdot \nabla v -\underbrace{ \int_{\partial\Omega} \frac{\partial u}{\partial n} v }_{= 0}\ =\ \int_\Omega f v \; \]
where \(n\) denotes a unit outward normal vector to the boundary. We can rewrite the problem as find \(u\in H_0^1(\Omega)\) such that for all \(v\in H_0^1(\Omega)\),
\[ a(u,v)&=l(v) \;, \]
where \(a\) is a bilinear form, continuous, coercive and \(l\) a linear form.
We defined \(\Omega\) as the unit square with a circle inside of radius \(0.25\)
We consider for this example \(f=1\) constant.
The complete example is here
As you can see, the program looks very close to the mathematical formulation.
We use the form2()
function to define the bilinear form and form1()
for the linear one (see Forms and Solver ).
The gradient for the trial functions is declared with the gradt()
expression where as grad()
is used for the test functions (see Keywords). Note that we need to transpose the second vector to perform the scalar product.
To introduce the homogeneous dirichlet conditions on the boundary, we use the function on()
. Once the variationnal formulation and the boundary conditions are set, we call the solver with solve()
.
The program is named `feelpp_doc_laplacian_with_holes`.