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

« back to all changes in this revision

Viewing changes to doc/pusrman/dirichlet.tex

  • Committer: Package Import Robot
  • Author(s): Pierre Saramito
  • Date: 2012-04-06 09:12:21 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120406091221-m58me99p1nxqui49
Tags: 6.0-1
* New upstream release 6.0 (major changes):
  - massively distributed and parallel support
  - full FEM characteristic method (Lagrange-Gakerkin method) support
  - enhanced users documentation 
  - source code supports g++-4.7 (closes: #667356)
* debian/control: dependencies for MPI distributed solvers added
* debian/rules: build commands simplified
* debian/librheolef-dev.install: man1/* to man9/* added
* debian/changelog: package description rewritted (closes: #661689)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
\chapter{Getting started with \Rheolef}
 
2
 
 
3
  For obtaining and installing \Rheolef, see the installation instructions on the \Rheolef\  home page:
 
4
  \begin{quote}
 
5
        \url{http://www-ljk.imag.fr/membres/Pierre.Saramito/rheolef/}
 
6
  \end{quote}
 
7
  All examples presented along the present book
 
8
  are available in the \code{example/} directory 
 
9
  of the \Rheolef\  distribution.
 
10
  This directory is given by the following unix command:
 
11
\cindex{directory of example files}%
 
12
\pindex{rheolef-config}%
 
13
\pindex{rheolef-config!--example-dir}%
 
14
  \begin{verbatim}
 
15
    rheolef-config --exampledir
 
16
  \end{verbatim}
 
17
  This command returns you a path, something like \code{/usr/share/doc/rheolef-doc/examples/}
 
18
  and you should make a copy of these files:
 
19
  \begin{verbatim}
 
20
   cp -a /usr/share/doc/rheolef-doc/examples/ .
 
21
   cd examples
 
22
  \end{verbatim}
 
23
  Before to run examples, please check your \Rheolef\  installation with:
 
24
\pindex{rheolef-config!--check}%
 
25
  \begin{verbatim}
 
26
    rheolef-config --check
 
27
  \end{verbatim}
 
28
 
 
29
% --------------------------------------
 
30
\section{The model problem}
 
31
% --------------------------------------
 
32
\label{sec-dirichlet}%
 
33
\pbindex{Poisson}%
 
34
\bcindex{Dirichlet}%
 
35
  Let us consider the classical Poisson problem
 
36
  with homogeneous Dirichlet boundary conditions
 
37
  in a domain bounded $\Omega \subset R^d$,
 
38
  $d=1,2,3$:
 
39
 
 
40
\cindex{operator!Laplace}%
 
41
  {\em (P): find $u$, defined in $\Omega$, such that:}
 
42
  \begin{eqnarray}
 
43
      -\Delta u &=& 1 \ {\rm in}\ \Omega        
 
44
        \label{eq-dirichlet-1}
 
45
        \\
 
46
      u &=& 0 \ {\rm on}\ \partial \Omega
 
47
        \label{eq-dirichlet-2}
 
48
  \end{eqnarray}
 
49
  where $\Delta$ denotes the Laplace operator.
 
50
  The variational formulation of this problem expresses
 
51
  (see appendix~\ref{sec-green-scalar} for details):
 
52
  
 
53
  {\em (VF): find $u\in H^1_0(\Omega)$ such that:}
 
54
  \begin{eqnarray}
 
55
      a(u,v) = l(v),
 
56
      \ \forall v \in H^1_0(\Omega)
 
57
                \label{eq-dirichlet-fv}
 
58
  \end{eqnarray}
 
59
  where the bilinear form $a(.,.)$ and the linear form $l(.)$ are defined by
 
60
  \begin{eqnarray*}
 
61
          a(u,v) &=& \int_\Omega \nabla u . \nabla v \, {\rm d}x,
 
62
          \ \ \forall u,v \in H^1_0(\Omega)
 
63
          \\
 
64
          l(v) &=& \int_\Omega v \, {\rm d}x,
 
65
          \ \ \forall v \in L^2(\Omega)
 
66
  \end{eqnarray*}
 
67
  The bilinear form $a(.,.)$ defines a scalar product
 
68
\cindex{form!energy}%
 
69
  in $H^1_0(\Omega)$ and is related to the {\em energy} form.
 
70
  This form is associated to the $-\Delta$ operator.
 
71
% The $m(.,.)$ is here the classical scalar product on $L^2(\Omega)$,
 
72
% and is related to the {\em mass} form.
 
73
  
 
74
% --------------------------------------
 
75
\section{Approximation}
 
76
% --------------------------------------
 
77
\cindex{approximation} %
 
78
  Let us introduce a mesh ${\cal T}_h$ of $\Omega$
 
79
  and the finite dimensional space $X_h$ of continuous
 
80
  piecewise polynomial functions.
 
81
  $$
 
82
      X_h = \{ v \in H^1(\Omega); \ 
 
83
          v_{/K} \in P_k, \ 
 
84
          \forall K \in {\cal T}_h \}
 
85
  $$
 
86
  where $k=1$ or $2$.
 
87
  Let $V_h=X_h \cap H^1_0(\Omega)$ be the functions of $X_h$ that
 
88
  vanishes on the boundary of $\Omega$.
 
89
  The approximate problem expresses:
 
90
 
 
91
  {\em $(VF)_h$: find $u_h\in V_h$ such that:}
 
92
  $$
 
93
      a(u_h,v_h) = l(v_h),
 
94
      \ \forall v_h \in V_h
 
95
  $$
 
96
  By developing $u_h$ on a basis of $V_h$, this 
 
97
  problem reduces to a linear system.
 
98
  The following C++ code
 
99
  implement this problem in the \Rheolef\  environment.
 
100
 
 
101
 
 
102
% --------------------------------------
 
103
\section{File \file{dirichlet.cc}}
 
104
% --------------------------------------
 
105
   \label{dirichlet}%
 
106
   \exindex{dirichlet.cc}
 
107
   \myexample{dirichlet.cc}
 
108
 
 
109
% --------------------------------------
 
110
\section{Comments}
 
111
% --------------------------------------
 
112
\cindex{mesh}%
 
113
\clindex{geo}%
 
114
\clindex{space}%
 
115
\clindex{form}%
 
116
\clindex{field}%
 
117
  This code applies for both one, two or three
 
118
  dimensional meshes and
 
119
  for both piecewise linear or quadratic
 
120
  finite element approximations.
 
121
  Four major classes are involved, namely: 
 
122
  {\color{rheoleftypcolor} \code{geo}},
 
123
  {\color{rheoleftypcolor} \code{space}},
 
124
  {\color{rheoleftypcolor} \code{form}} and 
 
125
  {\color{rheoleftypcolor} \code{field}}.
 
126
 
 
127
  Let us now comment the code, line by line.
 
128
  \begin{lstlisting}[numbers=none,frame=none]
 
129
    #include "rheolef.h"
 
130
  \end{lstlisting}
 
131
  The first line includes the \Rheolef\  header file \file{rheolef.h}.
 
132
\cindex{namespace!std}%
 
133
\cindex{namespace!rheolef}%
 
134
  \begin{lstlisting}[numbers=none,frame=none]
 
135
    using namespace rheolef;
 
136
    using namespace std;
 
137
  \end{lstlisting}
 
138
  By default, in order to avoid possible name conflicts when using another library,
 
139
  all classe and function names are prefixed by \code{rheolef::}, as in~\code{rheolef::space}.
 
140
  This feature is called the name space.
 
141
  Here, since there is no possible conflict, and in order to simplify the syntax, we drop all the
 
142
  \code{rheolef::} prefixes, and do the same with the standard \code{c++} library classes and
 
143
  variables, that are also prefixed by \code{std::}.
 
144
\cindex{argc, argv, command line arguments}%
 
145
  \begin{lstlisting}[numbers=none,frame=none]
 
146
    int main(int argc, char**argv) {
 
147
  \end{lstlisting}
 
148
  The entry function of the program is always called \code{main} and accepts arguments
 
149
  from the unix command line: \code{argc} is the counter of command line arguments
 
150
  and \code{argv} is the table of values. The character string \code{argv[0]}
 
151
  is the program name and \code{argv[i]}, for $i=1$ to \code{argc-1}, are the
 
152
  additional command line arguments.
 
153
  \begin{lstlisting}[numbers=none,frame=none]
 
154
    environment rheolef (argc, argv);
 
155
  \end{lstlisting}
 
156
\toindex{MPI, message passing interface}%
 
157
\cindex{distributed computation}%
 
158
\cindex{parallel computation}%
 
159
\toindex{library!boost}%
 
160
  These two command line parameters are immediatly furnished to the 
 
161
  distributed environment initializer of the \code{boost::mpi} library, that is
 
162
  a \code{c++} library based on the usual message passing interface ({\sc mpi}) library.
 
163
  Notice that this initialization is requiered, even when you run with only one processor.
 
164
  \begin{lstlisting}[numbers=none,frame=none]
 
165
    geo omega (argv[1]);
 
166
  \end{lstlisting}
 
167
  This command get the first unix command-line argument {\tt argv[1]}
 
168
  as a mesh file name and store the corresponding mesh in the variable {\tt omega}.
 
169
  \begin{lstlisting}[numbers=none,frame=none]
 
170
    space Xh (omega, argv[2]);
 
171
  \end{lstlisting}
 
172
  Build the finite element space {\tt Xh} contains all the piecewise polynomial
 
173
  continuous functions. The polynomial type
 
174
  is the second command-line arguments
 
175
\apindex{P1}%
 
176
\apindex{P2}%
 
177
\apindex{Pk}%
 
178
\apindex{high-order}%
 
179
  {\tt argv[2]}, and could be either \code{P1}, \code{P2} or any \code{P}$k$, where $k\geq 1$.
 
180
 
 
181
  \begin{lstlisting}[numbers=none,frame=none]
 
182
    Xh.block ("boundary");
 
183
  \end{lstlisting}
 
184
  The homogeneous Dirichlet conditions are declared on the boundary.
 
185
  \begin{lstlisting}[numbers=none,frame=none]
 
186
    form a (Xh, Xh, "grad_grad");
 
187
  \end{lstlisting}
 
188
\foindex{mass}%
 
189
\foindex{grad\_grad}%
 
190
  The form $a(.,.)$ is the energy form.
 
191
  \begin{lstlisting}[numbers=none,frame=none]
 
192
    field lh = riesz (Xh, 1);
 
193
  \end{lstlisting}
 
194
\cindex{Riesz representer}
 
195
  Here $lh(.)$ is the Riesz representer of the constant right-hand side $f=1$ of the problem.
 
196
  \begin{lstlisting}[numbers=none,frame=none]
 
197
    field uh (Xh);
 
198
  \end{lstlisting}
 
199
  The field {\tt uh} contains the the degrees of freedom.
 
200
  \begin{lstlisting}[numbers=none,frame=none]
 
201
    uh ["boundary"] = 0;
 
202
  \end{lstlisting}
 
203
  Some degrees of freedom are prescribed as zero on the boundary.
 
204
 
 
205
\cindex{Lagrange!node}%
 
206
  Let $(\varphi_i)_{0\leq i< {\rm dim}(X_h)}$ be the basis 
 
207
  of $X_h$ associated to the Lagrange nodes, e.g. the vertices
 
208
  of the mesh for the $P_1$ approximation and the vertices and the
 
209
  middle of the edges for the $P_2$ approximation.
 
210
  The approximate solution $u_h$ expresses as a linear combination
 
211
  of the continuous piecewise polynomial functions $(\varphi_i)$:
 
212
  $$
 
213
        u_h = \sum_{i} u_i \varphi_i
 
214
  $$
 
215
  Thus, the field $u_h$ is completely represented by its coefficients $(u_i)$.
 
216
  The coefficients $(u_i)$ of this combination are grouped into
 
217
  to sets: some have zero values, from the boundary condition
 
218
  and are related to {\em blocked} coefficients,
 
219
  and some others are {\em unknown}.
 
220
  Blocked coefficients are stored into the \code{uh.b} array
 
221
  while unknown one are stored into \code{uh.u}.
 
222
  Thus, the restriction of the bilinear form $a(.,.)$ to $X_h\times X_h$ 
 
223
  can be conveniently represented by a block-matrix structure:
 
224
\cindex{matrix!block structure}%
 
225
  $$
 
226
        a(u_h, v_h) = 
 
227
        \left ( \begin{array}{cc}
 
228
            {\tt vh.u} & {\tt vh.b}
 
229
        \end{array} \right)
 
230
        \left ( \begin{array}{cc}
 
231
            {\tt a.uu} & {\tt a.ub} \\
 
232
            {\tt a.bu} & {\tt a.bb}
 
233
        \end{array} \right)
 
234
        \left ( \begin{array}{c}
 
235
            {\tt uh.u} \\
 
236
            {\tt uh.b}
 
237
        \end{array} \right)
 
238
  $$
 
239
  This representation also applies for the
 
240
  linear form $l(.)$:
 
241
  $$
 
242
        l(v_h) = 
 
243
        \left ( \begin{array}{cc}
 
244
            {\tt vh.u} & {\tt vh.b}
 
245
        \end{array} \right)
 
246
        \left ( \begin{array}{c}
 
247
            {\tt lh.u} \\
 
248
            {\tt lh.b}
 
249
        \end{array} \right)
 
250
  $$
 
251
  Thus, the problem $(VF)_h$ writes now:
 
252
  $$
 
253
        \left ( \begin{array}{cc}
 
254
            {\tt vh.u} & {\tt vh.b}
 
255
        \end{array} \right)
 
256
        \left ( \begin{array}{cc}
 
257
            {\tt a.uu} & {\tt a.ub} \\
 
258
            {\tt a.bu} & {\tt a.bb}
 
259
        \end{array} \right)
 
260
        \left ( \begin{array}{c}
 
261
            {\tt uh.u} \\
 
262
            {\tt uh.b}
 
263
        \end{array} \right)
 
264
     =
 
265
        \left ( \begin{array}{cc}
 
266
            {\tt vh.u} & {\tt vh.b}
 
267
        \end{array} \right)
 
268
        \left ( \begin{array}{c}
 
269
            {\tt lh.u} \\
 
270
            {\tt lh.b}
 
271
        \end{array} \right)
 
272
  $$
 
273
  for any {\tt vh.u} and where {\tt vh.b} = 0.
 
274
  After expansion, the problem reduces to 
 
275
  {\em find} {\tt uh.u} {\em such that}:
 
276
  $$
 
277
    {\tt a.uu*uh.u} = {\tt l.u - a.ub*uh.b}
 
278
  $$
 
279
\cindex{matrix!factorization!Choleski}%
 
280
\clindex{solver}%
 
281
\clindex{solver}%
 
282
  The resolution of this linear system for the {\tt a.uu} matrix is
 
283
  then performed. A preliminary step build the $LDL^T$ factorization:
 
284
  \begin{lstlisting}[numbers=none,frame=none]
 
285
    solver sa (a.uu());
 
286
  \end{lstlisting}
 
287
  Then, the second step solves the {\em unknown part}:
 
288
  \begin{lstlisting}[numbers=none,frame=none]
 
289
    uh.set_u() = sa.solve (lh.u() - a.ub()*uh.b());
 
290
  \end{lstlisting}
 
291
\cindex{algorithm!conjugate gradient}%
 
292
\cindex{preconditioner!Choleski incomplete factorization}%
 
293
  When $d>3$, a faster iterative strategy is automatically preferred
 
294
  by the {\tt solver} class for solving
 
295
  the linear system: in that case, the preliminary step build 
 
296
  an incomplete Choleski factorization preconditioner,
 
297
  while the second step runs an iterative method:
 
298
  the preconditioned conjugate gradient algorithm.
 
299
  Finally, the field is printed to standard output:
 
300
  \begin{lstlisting}[numbers=none,frame=none]
 
301
    dout << uh;
 
302
  \end{lstlisting}
 
303
  The {\color{rheolefvarcolor}\tt dout} stream is a specific variable defined in the \Rheolef\  library:
 
304
  it is a distributed and parallel extension
 
305
  of the usual {\tt cout} stream in {\tt C++}
 
306
% --------------------------------------
 
307
\section{How to compile the code}
 
308
% --------------------------------------
 
309
\cindex{compilation}%
 
310
\cindex{Makefile}%
 
311
\toindex{make}%
 
312
\label{makefile}%
 
313
  First, create a \code{Makefile} as follow:
 
314
  \exindex{Makefile.demo}%
 
315
  \begin{quote}
 
316
    \verbatiminput{Makefile.demo}
 
317
  \end{quote}
 
318
  Then, enter:
 
319
  \begin{verbatim}
 
320
        make dirichlet
 
321
  \end{verbatim}
 
322
  Now, your program, linked with \Rheolef,
 
323
  is ready to run on a mesh.
 
324
 
 
325
% --------------------------------------
 
326
\section{How to run the program}
 
327
% --------------------------------------
 
328
  \begin{figure}[H]
 
329
     \begin{center}
 
330
       \begin{tabular}{cc}
 
331
          \includegraphics[height=6.5cm]{dirichlet-2d-P1-gnuplot.png} &
 
332
          \includegraphics[height=6.5cm]{dirichlet-2d-P2-gnuplot.png}
 
333
       \end{tabular}
 
334
     \end{center}
 
335
     \caption{Solution of the model problem for $d=2$:
 
336
       (left) $P_1$ element;
 
337
       (right) $P_2$ element.}
 
338
     \label{fig-dirichlet-2d}
 
339
  \end{figure}
 
340
\cindex{geometry!square}%
 
341
\pindex{geo}%
 
342
\pindex{mkgeo\_grid}%
 
343
\pindex{mkgeo\_grid!-t}%
 
344
\fiindex{\file{.geo} mesh}%
 
345
\toindex{visualization!mesh}%
 
346
  Enter the commands:
 
347
  \begin{verbatim}
 
348
      mkgeo_grid -t 10 > square.geo
 
349
      geo square.geo
 
350
  \end{verbatim}
 
351
  The first command generates a simple 10x10 bidimensional mesh
 
352
  of $\Omega=]0,1[^2$
 
353
  and stores it in the file \code{square.geo}. 
 
354
  The second command shows the mesh.
 
355
\toindex{gnuplot}%
 
356
  It uses \code{gnuplot} visualization program by default.
 
357
 
 
358
\pindex{field}%
 
359
\fiindex{\file{.field} field}%
 
360
  The next command performs the computation:
 
361
  \begin{verbatim}
 
362
      ./dirichlet square.geo P1 > square.field
 
363
       field square.field
 
364
  \end{verbatim}
 
365
% --------------------------------------
 
366
\section{Distributed and parallel runs}
 
367
% --------------------------------------
 
368
\toindex{mpirun}%
 
369
\cindex{distributed computation}%
 
370
\cindex{parallel computation}%
 
371
Alternatively, a computation in a distributed and parallel environment writes:
 
372
  \begin{verbatim}
 
373
      mpirun -np 4 ./dirichlet square.geo P1 > square.field
 
374
  \end{verbatim}
 
375
 
 
376
  \begin{figure}[H]
 
377
%    \begin{center}
 
378
     \mbox{}\hspace{-1cm}
 
379
       \begin{tabular}{cc}
 
380
          \includegraphics[height=6.5cm]{dirichlet-2d-bw-gnuplot.pdf} &
 
381
         %\includegraphics[height=6.5cm]{dirichlet-2d-elevation-gnuplot.png}
 
382
          \includegraphics[height=6.5cm]{dirichlet-2d-elevation.png}
 
383
       \end{tabular}
 
384
%    \end{center}
 
385
     \caption{Alternative representations
 
386
        of the solution of the model problem ($d=2$ and the
 
387
        $P_1$ element):
 
388
       (left) in black-and-white;
 
389
       (right) in elevation and stereoscopic anaglyph mode.}
 
390
     \label{fig-dirichlet-2d-alt}
 
391
  \end{figure}
 
392
% ----------------------------------------------------------------
 
393
\section{Stereo visualization}
 
394
% ----------------------------------------------------------------
 
395
  Also explore some graphic rendering modes
 
396
  (see Fig.~\ref{fig-dirichlet-2d-alt}):
 
397
\pindex{field!-bw}%
 
398
\pindex{field!-gray}%
 
399
\pindex{field!-stereo}%
 
400
\pindex{field!-nofill}%
 
401
\pindex{field!-elevation}%
 
402
\pindex{field!-mayavi}%
 
403
\toindex{mayavi}%
 
404
\cindex{visualization!elevation view}%
 
405
  \begin{verbatim}
 
406
      field square.field -bw
 
407
      field square.field -gray
 
408
      field square.field -mayavi
 
409
      field square.field -elevation -nofill -stereo
 
410
  \end{verbatim}
 
411
\cindex{visualization!stereoscopic anaglyph}%
 
412
  The last command shows the solution in elevation
 
413
  and in stereoscopic anaglyph
 
414
  mode (see Fig.~\ref{fig-dirichlet-3d}, left).
 
415
  The anaglyph mode requires red-cyan glasses:
 
416
  red for the left eye and cyan for the right one,
 
417
  as shown on Fig.~\ref{fig-anaglyph-glasses}.
 
418
  \begin{figure}[H]
 
419
     \begin{center}
 
420
          \includegraphics{red-cyan-glasses.png}
 
421
     \end{center}
 
422
     \caption{Red-cyan anaglyph glasses for the stereoscopic visualization.}
 
423
     \label{fig-anaglyph-glasses}
 
424
  \end{figure}
 
425
  See~\code{http://en.wikipedia.org/wiki/Anaglyph\_image}
 
426
  for more and
 
427
  \code{http://www.alpes-stereo.com/lunettes.html} 
 
428
  for how to find anaglyph red-cyan glasses.
 
429
  Please, consults the corresponding unix manual page for more 
 
430
  on \code{field}, \code{geo} and \code{mkgeo\_grid}:
 
431
\pindex{man}
 
432
  \begin{verbatim}
 
433
      man mkgeo_grid
 
434
      man geo
 
435
      man field
 
436
  \end{verbatim}
 
437
% ----------------------------------------------------------------
 
438
\section{High-order finite element methods}
 
439
% ----------------------------------------------------------------
 
440
\apindex{P2}%
 
441
\apindex{Pk}%
 
442
\apindex{high-order}%
 
443
  Turning to the \code{P2} or \code{P3} approximations simply writes:
 
444
  \begin{verbatim}
 
445
      ./dirichlet square.geo P2 > square-P2.field
 
446
      field square-P2.field
 
447
  \end{verbatim}
 
448
  Fig.~\ref{fig-dirichlet-2d}.right shows the result.
 
449
  You can replace the \code{P2} command-line argument by any \code{P}$k$, where $k\geq 1$.
 
450
 
 
451
\cindex{geometry!line}%
 
452
  Now, let us consider a mono-dimensional problem
 
453
  $\Omega=]0,1[$: 
 
454
\pindex{field!-}
 
455
\pindex{mkgeo\_grid!-e}%
 
456
  \begin{verbatim}
 
457
      mkgeo_grid -e 10 > line.geo
 
458
      geo line.geo
 
459
      ./dirichlet line.geo P1 | field -
 
460
  \end{verbatim}
 
461
  The first command generates a subdivision containing ten edge elements.
 
462
\toindex{gnuplot}%
 
463
  The last two lines show the mesh and the solution
 
464
  via \code{gnuplot} visualization, respectively.
 
465
 
 
466
  Conversely, the \code{P2} case writes:
 
467
  \begin{verbatim}
 
468
      ./dirichlet line.geo P2 | field -
 
469
  \end{verbatim}
 
470
% ----------------------------------------------------------------
 
471
\section{Tridimensional computations}
 
472
% ----------------------------------------------------------------
 
473
Let us consider a three-dimensional problem $\Omega=]0,1[^3$.
 
474
First, let us generate a mesh:
 
475
\cindex{geometry!cube}%
 
476
\pindex{geo!-stereo}%
 
477
\pindex{geo!-full}%
 
478
\pindex{geo!-cut}%
 
479
\pindex{mkgeo\_grid!-T}%
 
480
  \begin{verbatim}
 
481
      mkgeo_grid -T 10 > cube.geo
 
482
      geo cube.geo
 
483
      geo cube.geo -stereo -full
 
484
      geo cube.geo -stereo -cut
 
485
  \end{verbatim}
 
486
  The previous commands draw the mesh with all internal edges (\code{-full}),
 
487
  stereoscopic anaglyph (\code{-stereo})and then with a cut (\code{-cut}
 
488
  inside the internal structure:
 
489
  a simple click on the central arrow draws the cut plane normal vector
 
490
  or its origin, while the red square allows a translation.
 
491
  
 
492
  \begin{figure}[H]
 
493
     \begin{tabular}{cc}
 
494
         \includegraphics[scale=0.30]{cube-3d-stereo-fig.png} &
 
495
         \includegraphics[scale=0.35]{dirichlet-3d-mayavi-mix-fig.png} 
 
496
     \end{tabular}
 
497
     \caption{Solution of the model problem for $d=3$ and the $P_1$ element~:
 
498
        (left) mesh;
 
499
        (right) isovalue, cut planes and stereo anaglyph renderings.}
 
500
     \label{fig-dirichlet-3d}
 
501
  \end{figure}
 
502
 
 
503
  Then, we perform the computation and the visualization:
 
504
  \begin{verbatim}
 
505
      ./dirichlet cube.geo P1 > cube.field
 
506
      field cube.field
 
507
  \end{verbatim}
 
508
\toindex{mayavi}%
 
509
  The visualization presents an isosurface.
 
510
  Also here, you can interact with the cutting plane.
 
511
  Click on \code{IsoSurface} in the left menu and
 
512
  change the value of the isosurface.
 
513
  Finally exit from the visualization and explore the
 
514
  stereoscopic anaglyph mode
 
515
  (see Fig.~\ref{fig-dirichlet-3d}, right):
 
516
\pindex{field!-stereo}%
 
517
  \begin{verbatim}
 
518
      field cube.field -stereo
 
519
  \end{verbatim}
 
520
  It is also possible to add a second \code{IsoSurface}
 
521
  or \code{ScalarCutPlane} module to this scene
 
522
  by using the \code{Visualize} menu.
 
523
%%
 
524
%TODO 3d volume rendering ?
 
525
% Exit from the visualization and enter the command:
 
526
% \begin{verbatim}
 
527
%     field -volume cube.field
 
528
% \end{verbatim}
 
529
%   Click on the \fbox{configure} button of the "Modules" menu at the bottom of the control
 
530
%   panel. Then, select "Use TextureMapper" and inscreases the luminosity of the scene
 
531
%   by editing the color table
 
532
%   You can drag the mouse with different buttons to change the colors.
 
533
%   The following are the mouse buttons and key combinations that can be used to drag
 
534
%   and edit the color table and the luminosity:
 
535
%   \begin{itemize}
 
536
%      \item luminosity~: \fbox{Shift-Button-1}
 
537
%      \item red~: \fbox{Button-1}
 
538
%      \item green~: \fbox{Button-1}
 
539
%      \item blue~: \fbox{Button-3} or \fbox{Ctrl-Button-1}
 
540
%   \end{itemize}
 
541
% \fiindex{\file{.vtk} mesh and field data}
 
542
  After this exploration of the 3D visualisation capacities of our environment,
 
543
  let us go back to the Dirichlet problem and
 
544
  perform the \code{P2} approximation:
 
545
  \begin{verbatim}
 
546
      ./dirichlet cube.geo P2 | field -
 
547
  \end{verbatim}
 
548
% ----------------------------------------------------------------
 
549
\section{Quandrangles, prisms and hexahedra}
 
550
% ----------------------------------------------------------------
 
551
Quadrangles and hexahedra are also supported in meshes:
 
552
\pindex{mkgeo\_grid!-q}%
 
553
\pindex{mkgeo\_grid!-H}%
 
554
  \begin{verbatim}
 
555
      mkgeo_grid -q 10 > square.geo
 
556
      geo square.geo
 
557
      mkgeo_grid -H 10 > cube.geo
 
558
      geo cube.geo
 
559
  \end{verbatim}
 
560
  Notices also that the one-dimensional exact solution writes:
 
561
  $$
 
562
        u(x) = \Frac{x(1-x)}{2}
 
563
  $$
 
564
  while the two-and three dimensional ones 
 
565
  support a Fourier expansion (see e.g. \cite{saramito-roquet-00}, annex).
 
566