This part explains how to solve the Laplacian equation for homogeneous dirichlet conditions,
where \(u\in\Omega\) is the unknown "trial" function and \(\Omega\) the domain.
We multiply each part of the first equation by a "test" function \(v\in H_0^1(\Omega)\) and we integrate the resulting equation on the domain \(\Omega\),
We can integrate by parts this equation (Green Theorem) to obtain the variationnal formulation,
\[ \begin{aligned} \int_\Omega \nabla u \nabla v -\underbrace{ \int_{\partial\Omega} \frac{\partial u}{\partial n} v }_{= 0} =\int_\Omega f v \; \end{aligned} \]
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)\),
where \(a\) is a bilinear form, continuous, coercive and \(l\) a linear form.
Let's take a look at the Feel++ code (source "doc/manual/tutorial/mylaplacian.cpp"
).
We consider for this example \(f=1\) constant.
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()
.