an implementation of the fast multipole method …...an implementation of the fast multipole method...

36
An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast Multipole Method – Theory and Applications Spring 2002

Upload: others

Post on 24-May-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

An implementation of the Fast Multipole Method

without multipoles

Robin Schoemaker

Scientific Computing Group Seminar

The Fast Multipole Method – Theory and ApplicationsSpring 2002

Page 2: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Overview

• Fast Multipole Algorithm

• Anderson’s method– Poisson’s formula instead of multipole

expansions

• Application

Page 3: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

N-body interactions (1)

• Particle simulations in physical systems require the evaluation of a potential function

, (yielding a force field);• These pair wise interactions are

Coulombic/gravitational in nature:

for a system of N charged particles in 2dimensions with strengths qi .

( )φ r

( )1

log 1, ,N

j i j ii

q j Nφ=

= − =∑r r r …,

Page 4: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

N-body interactions (2)

If N is the total number of particles involved,

the temporal complexity of such a system is

.( )2O N

Page 5: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Multipole expansion

{ }{ }

1 1 1

, 1, ,

, 1

( ) log( )

, ,

( )

kpm mk i

i

i i

iki k

i k i

m q i m

z i m

a q zz z q a

z

z r

k

φ= = =

=

=

+

<

−=∑ ∑ ∑

"

For charges of strengths located

at points , with , the potential

is approximated by the

w

multipole expansion

ith ,

for z z r∈ >#any with .

Page 6: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Error bound

1

1 ,m

ii

A q p=

= ≥∑For and any

1 1

/ 2.

1( ) log( )/ 1 /

12

ppm

kki

i k

p

a Az z qz z r z

z r

r

A

φ= =

− − ≤ −

≤ ≥

∑ ∑

, for

Page 7: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Example of speed-up (1)

Two sets of charges are well-separated :

0

0

0 0

1, ,

1, ,

3

i

j

x x r i m

y y r j n

x y r

− < =

− < =

− >

for

for

,

,

.

y0

y1

yn

r

x0

x1

xmr

r

Page 8: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Example of speed-up (2)

The potential at the points {yi} due to charges

at {xj} is computed directly via

( )( )

1

1, ,i

m

x ji

O nm

n

y n

m

jφ=

=∑ …for all and requires

computations (evaluating fields at

p

oint

s).

y0x0

x1

xm

y1

yn

r

r

r

Page 9: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Example of speed-up (3)

• A p-term multipole expansion due to charges q1 ,…, qm about x0 requires O(mp) operations;

• Evaluating this expansion at all {yi} : O(np) operations; total : O(mp + np)

The O(p) operations can be neglected

for large m and n, resulting in

O(m) + O(n) << O(mn) .

Page 10: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Translation operators

• Shifting the centre of a multipole expansion: M2M;

• Convert a shifted expansion into a local (Taylor) expansion: M2L;

• Shifting the centre of a local (Taylor) expansion: L2L.

Page 11: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

M2M

0 0

01

0 00

1

1 0

log( )( )

( ) lo

(

1

1

)

g( )p

ll

l

ll

pk

kk

l kl k

k

az

bz a z

zl a z

b a zk

zz z

l

a zφ

φ=

=

=

+

− = − −

− +

∑"

"

into

w ith

R

R+|z0|

z0

D1

D

( )zφ

Page 12: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

M2L

( ) ( )

( )

0

0 0 01 0

0

10 0 0

( )

1 log

11 1 11

pl

ll

pkk

kk

pkk

l k llk

z b z

ab a z

z

l ka ab l

kz z l z

φ=

=

=

− + −

+ − − − ≥ − ⋅

"

"

"

with

for

RR z0

D1

D2 ( )zφ

cR

( )0 1 1z c R c> + > h wit

Page 13: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

L2L

Shifting a Taylor expansion via an exact translation operation with a finite number of terms:

{ }

( ) ( )0 00 0

0, , , 0, , ,k

n n nk k l lk k

k l k l

ka z z a z

z a

l

k n

z

z

= = =

− = −

=

∑ ∑ ∑

…For any complex nd

a

.

Page 14: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Hierarchy: FMA (1)

well separated cells

parent cell Bparent cell AM2L

M2M L2L

children of A children of B

Page 15: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Hierarchy: FMA (2)

Levels of refinement

Page 16: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Anderson’s method

• FMM: due to large numbers of particles;

• Not forced to use a multipole expansion as the ‘computational element’.

Instead use Poisson’s formula

( )zφ

Page 17: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Poisson’s formula (1)

Solving Laplace’s equation for the potential outside a disk with radius a containing ‘sources’ :

( ) ( )

( ) ( )( ) ( )( ) ( )

2 2

2 20

, log

1 1, log2 1 2 co )

.

s(

ar

a ar r

r r

a s a dss

r a

π

φ θ κ

φ κπ θ

= +

− − − − +

>

for

Page 18: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Poisson’s formula (2)

… and for the potential inside a hole with radius a from ‘sources’ outside:

( ) ( )( ) ( )

2 2

2 20

1 1, ( , )2 1 2 cos( )

.

ra

r ra a

r

r a dss

a

φ θ φπ θ

− = − − +

<

for

Page 19: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Outer ring approximation (1)

Numerical representation :

( ) ( )( )

( ) ( )

( ) ( )( ) ( )( ) ( )

2

2 21

, log

1 1, log2 1 2 cos( )

2 1,

2 / cos , sin , 1, ,

K ar

i a ar ri i

i

r r

a s a hs

M K M

h K s a ih a ih i K

φ θ κ

φ κπ θ

π

=

+

− − − − +

= +

= = =

"

With an integer and we set

and :

Page 20: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Outer ring approximation (2)

K

( ),rφ θ

Page 21: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Parent outer rings

Construction via Poisson’s formula:

Page 22: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Inner ring approximation

Similar as the outer ring construction:

( ) ( )( )

( )

( ) ( )( ) ( )

2

2 21

,

1 1,2 1 2 cos(

.

)

2 1,

2 / cos , sin , 1, ,

K ar

i a ar ri i

i

r

a

r

ss

a

h

M K M

h K s a ih a ih i K

φ θ

φπ θ

π

=

− −

<

− +

= +

= = =

"

f

or

With an integer and we set

and :

( ),rφ θ

K

Page 23: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Children inner rings

K

K

Page 24: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Hierarchical tree

Levels of refinement

Page 25: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Hierarchy in action

Page 26: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Temporal complexity (1)

Seven steps in the hierarchy :1. Finest level direct interactions ∝ N2 ;

2. Finest level outer ring construction ∝ KN;

3. Finest level contribution by outer rings in well-separated area ∝ KN;

4. Outer ring approximations ∝ K2;

5. Inner ring approx. by outer rings ∝K2;

6. Inner ring approx. by inner ring parent ∝ K2;

7. Finest level contribution by inner ring parent ∝ KN.

Page 27: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Temporal complexity (2)

• Total operation count depends on lf , N, and K ; with K << N and lf = f (N);

• For large lf this leads to :

2 244 f fl lN N KKα β γ− + +∼Complexity

, , , (10)K Oα β γwith and of order

uniform distributi

for a

of particles,

resulting

on

in

Page 28: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Temporal complexity (3)

an operation count linear in NUniform distribution Non-uniform distribution

Page 29: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Contour dynamics (1)

Numerical method for simulating :

• 2D, inviscid, incompressible vortex flows;

• Patches of uniform vorticity;

• Velocity field determined by the evolution of the contour bounding the patch:

( )

( , ) ln | | .C t

t d′ ′= −∫u r r r r%

Page 30: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Contour dynamics (2)

Page 31: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Contour dynamics (3)

An O(N2) method

Page 32: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Contour dynamics (4)

• Simple case : N = O(102) :

• Hard case : N = O(104) :

Page 33: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Apply Anderson’s method

Instead of point sources, use

source distributions like vorticity :

Page 34: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Accuracy of Poisson kernel (1)

( ) ( ) ( )( ) ( )

2

2 21

1 1, ,2 1 2 cos( )

K ar

i a ar ri i

r a s hs

φ θ φπ θ=

− − − +

∑"

Kernel is very inaccurate for r Ø a :

• Anderson solves for this: C.R. Anderson, SIAM J.Sci.Stat.Comput. Vol 13, No. 4, 1992;

• Vosbeek solves for this HEM(Hierarchical-Element Method): P.W.C. Vosbeek et al., J.Comput.Phys., Vol. 161, 2000.

Page 35: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Accuracy of Poisson kernel (2)

From: P.W.C. Vosbeek et al., J.Comput.Phys., Vol.161, 2000.

Page 36: An implementation of the Fast Multipole Method …...An implementation of the Fast Multipole Method without multipoles Robin Schoemaker Scientific Computing Group Seminar The Fast

Advantages of AM/HEM

• Not only point sources!

• Operations for constructing and combining elements are easy to formulate: only function evaluation;

• These operations are almost identical in 2 and 3 dimensions (not discussed);

• HEM more accurate than AM;

• O(N).