1
%---------------------------------------------------------------------------------
2
\section{Non-homogeneous Neumann boundary conditions for the Helmholtz operator}
3
%---------------------------------------------------------------------------------
4
\label{sec-neummann-nh}
7
\cindex{operator!Helmholtz}%
9
\subsection*{Formulation}
10
Let us show how to insert Neumann boundary conditions.
11
Let $f \in H^{-1}(\Omega)$ and
12
$g \in H^{-\frac{1}{2}}(\partial \Omega)$.
15
$(P_3)$: {\it find $u$, defined in $\Omega$ such that:}
17
u -\Delta u &=& f \ {\rm in}\ \Omega \\
18
\Frac{\partial u}{ \partial n} &=& g \ {\rm on}\ \partial \Omega
20
The variational formulation of this problem expresses:
22
$(VF_3)$: {\it find $u \in H^1(\Omega)$ such that:}
24
a(u,v) = l(v), \ \forall v \in H^1(\Omega)
28
a(u,v) &=& \int_\Omega u\,v \, {\rm d}x + \int_\Omega \nabla u . \nabla v \, {\rm d}x \\
29
l(v) &=& \int_\Omega f\, v \, {\rm d}x + \int_{\partial \Omega} g \, v \, {\rm d}s
32
\subsection*{Approximation}
33
\cindex{Lagrange!interpolation}
34
As usual, we introduce a mesh ${\cal T}_h$ of $\Omega$
35
and the finite dimensional space $X_h$:
37
X_h = \{ v \in H^1(\Omega); \
39
\forall K \in {\cal T}_h \}
41
The approximate problem writes:
43
{\it $(VF_3)_h$: find $u_h\in X_h$ such that:}
49
\subsection*{File \file{neumann-nh.cc}}
50
\exindex{neumann-nh.cc}
51
\myexample{neumann-nh.cc}
53
Let us choose $\Omega \subset R^d$, $d=1,2,3$ and
55
f(x) &=& (1+d\pi^2) \prod_{i=0}^{d-1} \sin(\pi x_i) \\
58
-\pi & \mbox{ when } d = 1 \\
59
-\pi\left( {\displaystyle \sum_{i=0}^{d-1} \sin(\pi x_i)}\right)
60
& \mbox{ when } d = 2 \\
61
-\pi\left( {\displaystyle \sum_{i=0}^{d-1} \sin(\pi x_i)} \sin(x_{(i+1){\rm mod}\,d}\right)
66
This example is convenient, since
67
the exact solution is known:
69
u(x) = \prod_{i=0}^{d-1} \sin(\pi x_i)
71
\subsection*{File \file{sinusprod\_helmholtz.icc}}
72
\exindex{sinusprod\_helmholtz.icc}
73
\myexample{sinusprod_helmholtz.icc}
76
\subsection*{Comments}
77
The {\tt neumann-nh.cc}
78
code looks like the previous one {\tt dirichlet-nh.cc}.
79
Let us comments only the changes.
80
\begin{lstlisting}[numbers=none,frame=none]
81
form m (Xh, Xh, "mass");
82
form a (Xh, Xh, "grad_grad");
84
The bilinear forms $m(.,.)$ and $a(.,.)$, also called the {\em mass} and
85
{\em energy} in mechanics, are defined as:
87
m(u,v) = \int_\Omega u\,v \, {\rm d}x
89
a(u,v) = \int_\Omega \nabla u . \nabla v \, {\rm d}x
91
Then, these two forms are added and stored in $a$:
92
\begin{lstlisting}[numbers=none,frame=none]
95
The right-hand side is computed as:
96
\begin{lstlisting}[numbers=none,frame=none]
97
field lh = riesz(Xh, f(d)) + riesz(Xh, "boundary", g(d));
100
\subsection{How to run the program}
102
First, compile the program:
106
Running the program is obtained from the homogeneous Dirichlet case,
107
by replacing \code{dirichlet} by \code{neumann-nh}.