~ubuntu-branches/ubuntu/trusty/rheolef/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/usrman/dirichlet-nh.tex

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2010-06-12 09:08:59 UTC
  • Revision ID: james.westby@ubuntu.com-20100612090859-8gpm2gc7j3ab43et
Tags: upstream-5.89
ImportĀ upstreamĀ versionĀ 5.89

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\section{Non-homogeneous Dirichlet conditions}
 
2
\cindex{Poisson problem}
 
3
\pbindex{Poisson}
 
4
\cindex{Dirichlet boundary condition}
 
5
\bcindex{Dirichlet}
 
6
\cindex{Lagrange interpolation}
 
7
\clindex{point}
 
8
\clindex{Float}
 
9
\clindex{doubledouble}
 
10
 
 
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)$.
 
16
  The problem writes:
 
17
 
 
18
  $(P_2)_h$ {\it find $u$, defined in $\Omega$ such that:}
 
19
  \begin{eqnarray*}
 
20
      -\Delta u &=& f \ {\rm in}\ \Omega \\
 
21
      u &=& g \ {\rm on}\ \partial \Omega
 
22
  \end{eqnarray*}
 
23
  The variationnal formulation of this problem expresses:
 
24
 
 
25
  $(VF_2)$ {\it find $u \in V$ such that:}
 
26
  $$
 
27
    a(u,v) = m(f,v), \ \forall v \in V_0
 
28
  $$
 
29
  where 
 
30
  \begin{eqnarray*}
 
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 \} \\
 
34
    V_0 &=& H^1_0(\Omega)
 
35
  \end{eqnarray*}
 
36
  The computation of the right-hand side may be considered with
 
37
  attention since $f$ is not {\em a priori} piecewise polynomial.
 
38
 
 
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$:
 
43
  $$
 
44
      X_h = \{ v \in H^1(\Omega); \
 
45
          v_{/K} \in P_k, \
 
46
          \forall K \in {\cal T}_h \}
 
47
  $$
 
48
  Then, we introduce:
 
49
  \begin{eqnarray*}
 
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 \} \\ 
 
52
  \end{eqnarray*}
 
53
 
 
54
  The approximate problem writes:
 
55
 
 
56
  {\it $(VF_2)_h$: find $u_h\in V_h$ such that:}
 
57
  $$
 
58
      a(u_h,v_h) = m(\Pi_h(f),v_h)
 
59
      \ \forall v_h \in V_{0,h}
 
60
  $$
 
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$.
 
65
 
 
66
  Let us choose $\Omega \subset R^N$, $N=1,2,3$ and
 
67
  \begin{eqnarray*}
 
68
      f(x) &=& N \sin(\sum_{i=1}^N x_i) \\
 
69
      g(x) &=& \sin(\sum_{i=1}^N x_i)
 
70
  \end{eqnarray*}
 
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.
 
76
 
 
77
\subsection*{File \file{dirichlet-nh.cc}}
 
78
  \exindex{dirichlet-nh.cc}
 
79
  \verbatiminput{dirichlet-nh.cc}
 
80
 
 
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 
 
87
  of \code{Float}.
 
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).
 
94
  \begin{verbatim}
 
95
    field fh = interpolate(Vh,f);
 
96
  \end{verbatim}
 
97
  This implements the 
 
98
  Lagrange interpolation operator $\Pi_h (f)$.
 
99
  \begin{verbatim}
 
100
    space Wh (omega, omega["boundary"], argv[2]);
 
101
  \end{verbatim}
 
102
  The space of picewise $P_k$ functions is builded.
 
103
  This space is suitable for the interpolation of $g$
 
104
  on the boundary: 
 
105
  \begin{verbatim}
 
106
    uh[boundary] = interpolate(Wh, g);
 
107
  \end{verbatim}
 
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.
 
112
 
 
113
\subsection{How to run the program}
 
114
 
 
115
  First, compile the program:
 
116
  \begin{verbatim}
 
117
      make dirichlet-nh
 
118
  \end{verbatim}
 
119
  Running the program is obtained from the homogeneous Dirichlet case,
 
120
  by remplacing \code{dirichlet} by \code{dirichlet-nh}:
 
121
  \begin{verbatim}
 
122
      mkgeo_grid -e 10 -boundary > line.geo
 
123
      ./dirichlet-nh line.geo P1 | field -
 
124
  \end{verbatim}
 
125
  for the bidimensional case:
 
126
  \begin{verbatim}
 
127
      mkgeo_grid -t 10 -boundary > square.geo
 
128
      ./dirichlet-nh square.geo P1 | field -
 
129
  \end{verbatim}
 
130
  and for the tridimensional case:
 
131
  \begin{verbatim}
 
132
      mkgeo_grid -T 10 -boundary > box.geo
 
133
      ./dirichlet-nh box.geo P1 | field -mayavi -
 
134
  \end{verbatim}
 
135
  Here, the \code{P1} approximation can be remplaced by 
 
136
  the \code{P2} one, by modifying the command-line argument.
 
137