1
\section{Non-homogeneous Dirichlet conditions}
2
\cindex{Poisson problem}
4
\cindex{Dirichlet boundary condition}
6
\cindex{Lagrange interpolation}
11
\subsection*{Formulation}
12
We turn now to the case of a non-homogeneous
13
Dirichlet boundary conditions.
14
Let $f \in H^{-1}(\Omega)$ and
15
$g \in H^{\frac{1}{2}}(\partial \Omega)$.
18
$(P_2)_h$ {\it find $u$, defined in $\Omega$ such that:}
20
-\Delta u &=& f \ {\rm in}\ \Omega \\
21
u &=& g \ {\rm on}\ \partial \Omega
23
The variationnal formulation of this problem expresses:
25
$(VF_2)$ {\it find $u \in V$ such that:}
27
a(u,v) = m(f,v), \ \forall v \in V_0
31
a(u,v) &=& \int_\Omega \nabla u . \nabla v \, dx \\
32
m(u,v) &=& \int_\Omega u v \, dx \\
33
V &=& \{ v \in H^1(\Omega); \ v_{|\partial \Omega} = g \} \\
36
The computation of the right-hand side may be considered with
37
attention since $f$ is not {\em a priori} piecewise polynomial.
39
\subsection*{Approximation}
40
\cindex{approximation}
41
As usual, we introduce a mesh ${\cal T}_h$ of $\Omega$
42
and the finite dimensional space $X_h$:
44
X_h = \{ v \in H^1(\Omega); \
46
\forall K \in {\cal T}_h \}
50
V_h &=& \{ v \in X_h; \ v_{|\partial\Omega} = \pi_h(g) \} \\
51
V_{0,h} &=& \{ v \in X_h; \ v_{|\partial\Omega} = 0 \} \\
54
The approximate problem writes:
56
{\it $(VF_2)_h$: find $u_h\in V_h$ such that:}
58
a(u_h,v_h) = m(\Pi_h(f),v_h)
59
\ \forall v_h \in V_{0,h}
61
Notices that the evaluation of the right-hand side is performed by
62
remplacing $f$ by its Lagrange interpolation $\Pi_h(h)$ on $\Omega$,
63
while the boundary condition $g$ is remplaced by its Lagrange
64
interpolation $\pi_h(h)$ on $\partial \Omega$.
66
Let us choose $\Omega \subset R^N$, $N=1,2,3$ and
68
f(x) &=& N \sin(\sum_{i=1}^N x_i) \\
69
g(x) &=& \sin(\sum_{i=1}^N x_i)
71
This choice is convenient, since
72
the exact solution is known:
73
$$u(x) = \sin(\sum_{i=1}^N x_i)$$.
74
The following C++ code
75
implement this problem in the \code{rheolef} environment.
77
\subsection*{File \file{dirichlet-nh.cc}}
78
\exindex{dirichlet-nh.cc}
79
\verbatiminput{dirichlet-nh.cc}
81
\subsection*{Comments}
82
The code looks like the previous one, related to
83
homogeneous boundary conditions.
84
Let us comments the changes.
85
The class \code{point} describes the coordinates
86
of a point $(x_1, \ldots, x_N) \in R^N$ as a $N$-uplet
88
The \code{Float} type is usually a \code{double}.
89
This type depends upon the \code{rheolef}
90
configuration \pxref{Installing,,Configure options},
91
and could represent some high precision floating point
92
class such as \code{doubledouble} (quadruple)
93
or \code{bigfloat} (arbitrary).
95
field fh = interpolate(Vh,f);
98
Lagrange interpolation operator $\Pi_h (f)$.
100
space Wh (omega, omega["boundary"], argv[2]);
102
The space of picewise $P_k$ functions is builded.
103
This space is suitable for the interpolation of $g$
106
uh[boundary] = interpolate(Wh, g);
108
The values of the degrees of freedom
109
related to the boundary are stored into the field \code{u}, where
110
non-homogeneous Dirichlet conditions applies.
111
The rest of the code is similar to the homogeneous Dirichlet case.
113
\subsection{How to run the program}
115
First, compile the program:
119
Running the program is obtained from the homogeneous Dirichlet case,
120
by remplacing \code{dirichlet} by \code{dirichlet-nh}:
122
mkgeo_grid -e 10 -boundary > line.geo
123
./dirichlet-nh line.geo P1 | field -
125
for the bidimensional case:
127
mkgeo_grid -t 10 -boundary > square.geo
128
./dirichlet-nh square.geo P1 | field -
130
and for the tridimensional case:
132
mkgeo_grid -T 10 -boundary > box.geo
133
./dirichlet-nh box.geo P1 | field -mayavi -
135
Here, the \code{P1} approximation can be remplaced by
136
the \code{P2} one, by modifying the command-line argument.