Document 11442559

advertisement
Multigrid methods in Diffpack
Multigrid methods in Diffpack
1/68
Outline
Describe Diffpack tools
Show multigrid behaviour
Kickstart! (theory later)
Multigrid methods in Diffpack
2/68
Motivation: Moore’s law
The speed of the CPU and the amount of memory
doubles at least every other year.
In two years we will want to solve a linear system
twice as large as today.
Banded Gaussian elimination is an
algorithm, where is the bandwidth of the matrix. In
and therefore 4
2D we typically have that
times as many aritmetic operations are needed.
We need to wait 2 times longer to calculate the
solution!
This is not acceptable!
We need faster algorithms that take advantage of special
structures of the matrix.
Multigrid methods in Diffpack
3/68
Goal
We assume that a Diffpack simulator for a given
problem has been developed. The simulator should
have been tested extensively.
The multigrid solver should be put on top of the
simulator, with minimal coding effort.
The efficiency of multigrid may be unknown!
We hope it will speed up the simulation time
significantly.
Multigrid is a general strategy, but its efficiency is
only known in few and simple cases.
The toolbox should be general and include the
possibility to be extended to complex applications,
beyond the simple and well-understood problems.
Multigrid methods in Diffpack
4/68
Diffpack
etc,
,
,
,
linear solvers,
example simulators,
Diffpack has a varity of
grid generation tools.
for the finite element method,
It has general tools:
to read problem dependent parameters
from file,
for the handling of boundary conditions
and numbering.
plug them together! Don’t reinvent the wheel.
Multigrid methods in Diffpack
5/68
is a simulator that solves
. It is one of
the standard test examples that comes with the Diffpack
distribution.
This simulator does:
make a grid,
,
solves the problem,
in
set up a linear system,
read various problem dependent parameters from
,
the
,
post-prosessing.
Multigrid methods in Diffpack
6/68
The multigrid simulator
should,
make a grid hierarchy,
read additional multigrid parameters from the
,
use already made solver like
the simulator should be used to set up a sequence of
linear systems,
on each grid level,
glue the components into a multigrid algorithm.
Multigrid methods in Diffpack
7/68
Diffpack has the multigrid toolbox
Multigrid toolbox
.
It has has a
various parameters
It is a container for the extra datastructures. It
contains the matrices on the coarse levels,
smoothers, transfer operators, etc.
interface for easy testing of
It has functionality to set up the system, transfer
vectors between grids, solve (sub) systems, etc.
Multigrid methods in Diffpack
8/68
is used as usual in Diffpack.
The
Modifications
defines the
in
These parameters are read from the
.
menu interface.
Multigrid methods in Diffpack
9/68
Modifications II
is used
!
The matrices and vectors attached to
on the finest grid.
with
provides
.
pointer
and
The
is made:
"
Read multigrid parameters and make the grid
hierarchy.
Multigrid methods in Diffpack
10/68
in the
A
object
the grid hierarchy.
Modifications III
contain
"
"
A serie of
objects on each grid level is
. These
’s
made from the grids in
determine the structure of the matrices, vectors and
transfer operators. Additionally, the smoothers and
the coarse grids solver is made according to the
. All this happens in:
parameters in
Multigrid methods in Diffpack
11/68
We need to fill the matrices and right hand sides.
In a standard Diffpack simulator the matrix and
call,
righthandside is filled by the
(and possibly
according to
and
).
has its own variant of
which is
call on each grid level:
essensially a
Multigrid methods in Diffpack
12/68
II
Because of the Object-Oriented structuring of Diffpack
, the
will call up
and
and
if they are supplied by the simulator.
Multigrid methods in Diffpack
13/68
is
It has its own
The class
hierarchy of grids.
GridCollector
’s interface to the
interface.
Using this interface will ensure that the grid hierarchy
is nested.
It can also be filled manually (see the report).
Multigrid methods in Diffpack
14/68
Nested Grid Hierarchy
Each coarse grid element can be represented as a
superposition of fine grid elements.
For standard elements this means that the grid lines
in the coarse grid are also in the fine grid.
Most theory of multigrid methods conserns nested
grids. However, this property is not critical.
Multigrid methods in Diffpack
15/68
Motivation behind Diffpack
The simulation should be possible to customize at run
time!
A simulator should be capable of handling any grid,
number of space dimentions, linear solver etc.
As much as possible is spesified in an input file or at
the command line
No code editing and recompilation are required to
test different problems
Debugging should be possible in 1D
Multigrid methods in Diffpack
16/68
Making Grids
The coarse grid will then be a
disk with a hole.
results in the following grid hierarchy:
partition of a
refinement of the grid on
The grid on level is a
.
level
Multigrid methods in Diffpack
The grid hierarchy will be 3 nested refinements of the
coarse grid and the coarse grid itself.
17/68
"
An input file like,
Multigrid methods in Diffpack
"
"
"
!
"
!
Input file
A standard part of Diffpack’s input files.
18/68
Multigrid methods in Diffpack
"
!
"
"
"
"
"
"
"
parameters
19/68
Optimal Method
Multigrid is commonly called an "optimal method". We will
no go detailes through
What does it mean?
What is needed to achieve this?
What are the parameters ?
How to test it?
How general is it?
Multigrid methods in Diffpack
20/68
Discretization Error
Given a model problem, e.g.,
by solving the
We find an approximate solution
matrix system
Multigrid methods in Diffpack
The error is typically dependent of
21/68
Solution of the Matrix
How accurately should we solve the matrix system ?
We already have an error inherited by the method
Hence it is not neccessary to solve the the matrix
system more accurately than
This is much cheaper than computing the solution
with computer precision!
Multigrid methods in Diffpack
22/68
Optimal Method II
An optimal method should reach an error tolerance
operations,
propotional to the discretization error in
where is the number of unknowns
Each iterations is
Multigrid is an iterative method
Hence multigrid should converge in a fixed number of
iterations independent of the number of unknowns.
Multigrid methods in Diffpack
23/68
Multigrid Requirement
Multigrid requires that the smoother removes all the
errors that can not be represented on the coarser
mesh
In practice it might be neccessary to adjust the
coarse grid to the smoother
We will now describe smoothers
Multigrid methods in Diffpack
24/68
Multigrid methods in Diffpack
"
!
Smoother
25/68
Smoother II
, but other methods
to distingvish it
It has the command prefix
’s.
from other
Usually, it is
,
or
can be tested.
like
The smoother is a standard Diffpack linear solver,
.
that is a subclass of
The command
Multigrid methods in Diffpack
is overridden by
26/68
The best smoother
It is easy to numerically determine the best smoother for a
given problem.
The experiments reviels that SSOR with relaxation
parameter 1.0 (symmetric Gauss-Seidel) is the
fastest.
SOR is slightly slower than SSOR and best with the
same relaxation parameter.
The Jacobi method is best with a relaxation
parameter 0.8.
Multigrid even diverge for Jacobi with relaxation
parameter 1.6.
Multigrid methods in Diffpack
27/68
Number of sweeps
What is the optimal number of sweeps?
Each sweep improve the solution.
But does it contribute with a significant improvment
that is necessary for the overall performance of the
algorithm?
Multigrid methods in Diffpack
28/68
Number of sweeps II
"
It is easy to test:
The V(1,1) cycle is fastest in terms of CPU time.
The number of iterations decrease as we increase
the number of sweeps.
Multigrid methods in Diffpack
29/68
Pre- or Post-smoothing
Should the number of pre- and post-smoothing steps be
equal and which is the most important ?
We can test
Multigrid methods in Diffpack
The slowest is
It turns out that with a Gauss-Seidel smoother the
and
fastest convergence is obtained with either
using 0.14s.
using 0.22s.
30/68
Aliasing
The results on the previous slide was a bit surprising.
In general, pre smoothing is needed to achieve
convergence of multigrid, at least in theory.
The reason is that a high frequency phenomena
represented on a coarse scale simply will be a low
frequency phenomena. It will generally not wanish.
Multigrid methods in Diffpack
31/68
Aliasing II
The restriction operators are constructed simply by
reproducing the coarse element (Figure 1) by fine
elements (Figure 2).
Figure 1: Coarse function
Figure 2: 3 Functions on the fine mesh
Multigrid methods in Diffpack
32/68
Aliasing III
This gives an interpolation operator
Figure 3: Another example that reproduce the
coarse function.
Multigrid methods in Diffpack
33/68
Aliasing IV
Hence, there is now way we can distingvish these
low frequency and high frequency phenomena on a
coarser grid.
We have to remove the high frequency error before
the residual is trasfered to the coarser grid, to make
sure that the residual actually represent the low
frequence errors.
Multigrid methods in Diffpack
34/68
that can be
"
!
"
The coarse solver is also a
chosen by editing the input file.
Coarse grid Solver
Multigrid methods in Diffpack
"
The
used if this variable is
There is also a variable
which
indicates whether the coarse grid solver should be
menu- or the
based on the
menu-items.
menu items are
.
35/68
Coarse Grid Solver II
Should be accurate.
Should be small.
In fact, it can be as small as 1 node (+ bc nodes).
Multigrid methods in Diffpack
36/68
What should we expect?
Multigrid reduce the error with a constant factor,
Multigrid methods in Diffpack
It is very usefull to have a test example where the actual
error can be computed!
In a real application where the solution is unknown, it is
common to check the residual.
37/68
Relative or absolut criterion?
The error reduction in one iteration is,
.
A relative criterion could be used to chech this.
This is independent of the grid parameter .
On the other hand an absolute criterion is easiest to
check against the discretization error.
Multigrid methods in Diffpack
38/68
Nested Multigrid
operations.
is very small compared with .
Multigrid methods in Diffpack
Standard multigrid uses
Full or nested multigrid reach the discretization error
operations.
in
39/68
Multigrid methods in Diffpack
"
3,2
2,1
1,2
"
2,3
"
Nested Multigrid
3
2,3
2
1,2
1
40/68
W-cycle
The W-cycle is often used to increase the efficiency
and roboustness if the V-cycle gives poor results.
It has proven to be more roboust on grids with
geometrical singularities.
Multigrid methods in Diffpack
41/68
Multigrid methods in Diffpack
"
2,1
"
3,2
"
W-cycle
3
2,3
2
1,2
1
42/68
A proper test example
Finding a proper test example is crusial! Multigrid
methods might work well even though they are not
implemented correctly.
In fact these software tools had a boundary bug for
5++ years.
The error was first revield in a much harder
application, where the behaviour of multigrid was
unknown.
Multigrid now seems to work also in this application,
originally it did not!
Always use plain multigrid during debugging and
implementation.
Multigrid methods in Diffpack
43/68
A proper test example II
Construct a difficult test case!
The initial error should contain all possible errors.
Do not use a zero or smooth start vector, the initial
error will then probably be smooth.
Use a random start vector.
Multigrid methods in Diffpack
44/68
Debugging
Check boundary conditions on coarse grids.
Check residual behaviour also on coarse grids.
Use
Plot solution before and after smoothing.
Multigrid methods in Diffpack
45/68
One V(1,1)-cycle I
Figure 4: The picture shows the initial vector. It is a random vector that should contain "all possible" errors.
Multigrid methods in Diffpack
46/68
One V(1,1)-cycle II
Figure 5: In the picture the solution after one symmetric
Gauss-Seiden sweep is displayed. It is clear that the high
frequency random behaviour has been effectively removed.
Multigrid methods in Diffpack
47/68
One V(1,1)-cycle III
Figure 6: The picture shows the solution after the coarse
grid correction. The smooth components of the solution
have improved dramatically.
Multigrid methods in Diffpack
48/68
One V(1,1)-cycle IV
Figure 7: In this last picture the solution after the post
smoothing is displayed. The solution is now very close to
the actual solution.
Multigrid methods in Diffpack
49/68
Generality
One of the main focuses in the design of
have been that it should be applicable in general.
We will now see that extending a much more
advanced simulator consists of mainly the steps
simulator.
described for the
Multigrid methods in Diffpack
50/68
on
on
on
on
on
in
Variation on the theme:Poisson2
We will investigate how multigrid behave with respect to
different boundary conditions, grids and -functions.
Multigrid methods in Diffpack
51/68
Multigrid methods in Diffpack
"
"
Modifications
All the grids should be modified!
52/68
Boundary conditions
Multigrid handles all kinds of boundary conditions
.
and so does
The same boundary conditions should be applied on
all grid levels.
The same modification are done on all grid levels.
Multigrid methods in Diffpack
,
and
are applied on all grid levels.
The same
53/68
Anisotropy
An anisotropic diffusion equation reads,
Standard multigrid techniques does not apply to this
problem.
Methods to improve the behaviour are
line-smoothing
semi-coarsening
(R)ILU smoothing
Multigrid methods in Diffpack
54/68
Multigrid methods in Diffpack
"
We start with
as the smoother and test different
, the input file is
.
Anisotropy II
We have
The test:
55/68
Multigrid methods in Diffpack
"
We redo the simulation using
Anisotropy III
as smoother.
The (R)ILU smoother seems stable with respect to
the parameter .
56/68
Preconditioning vs. Solver I
Convergence estimate for multigrid,
where is the condition number of
. Multigrid is
represented as B and A is the coefficients matrix.
More on this estimate later, assume that it is true.
Multigrid methods in Diffpack
57/68
Preconditioning vs. Solver II
Convergence estimate for the Conjugate Gradient
method,
More on this estimate later, assume that it is true.
, if
We have:
,
.
Hence, the Conjugate Gradient will always converge
faster than multigrid in terms of the number of iterations.
However, each iteration is more expensive. Which one is
the fastest ?
Multigrid methods in Diffpack
58/68
Preconditioning vs. Solver II
MG
#it. CPU time #it. CPU time
6
0.01
5
0
6
0.02
5
0
6
0.05
5
0.05
6
0.23
5
0.27
6
1.13
5
1.25
6
4.78
5
5.27
6
20.13
5
22.16
n
CG/MG
Table 1: Comparison of Multigrid as a solver and as a
preconditioner
Multigrid methods in Diffpack
59/68
Preconditioning vs. Solver III
In the table on the previous slide we compared
multigrid as a solver with multigrid as a
preconditioner for the Conjugate Gradient method.
The results are striking, there seems to be no point in
using Krylov subspace acceleration for a highly
efficient multigrid method.
Multigrid methods in Diffpack
60/68
Jumping coefficients
.
,
,
where
The problem reads,
Such problems occur in, e.g., groundwater flow and
reservoir simulation, where is the permeability of
the media, consisting of rock and sand.
Multigrid methods in Diffpack
61/68
The jump
f1
k1
k0
f0
f1 is a source, where, e.g., the water is pumped in,
f2 is a drain, where oil is supposed to come out,
k1 is sand,
k0 is rock.
Multigrid methods in Diffpack
62/68
Multigrid methods in Diffpack
"
"
"
"
Preconditioning vs. Solver IV
Multigrid as solver:
Multigrid as preconditioner:
63/68
Preconditioning vs. Solver V
Using the Conjugate Gradient method did pay of!
Multigrid did not even converge.
Multigrid manages to reduce most of the error
components.
Some remain essensially unchanged.
These are picked up efficiently by the Conjugate
Gradient method.
Multigrid methods in Diffpack
64/68
Preconditioning vs. Solver VI
Using the Conjugate Gradient method will not speed
up a highly efficient multigrid solver.
It increase the roboustness.
Multigrid methods in Diffpack
65/68
Grid
Diffpack has simple mesh generation tools.
E.g. a L-shaped domain can be made with:
Multigrid works will also for such geometries
Multigrid methods in Diffpack
66/68
Grid with Geometric singularities
Domains with stronge geometric singularities can be
made with
D
Figure 8: Geometric singularity dependent on the angle
Multigrid methods in Diffpack
Multigrid deteriorates slightly with decreasing
D.
.
67/68
Multigrid methods in Diffpack
"
"
"
Manually made grid hierarchy
also supports manually made grids.
68/68
Download