FMM2D.jl is a Julia interface for computing N-body interactions using the Flatiron Institute's FMM2D library.
Currently, the wrapper wraps the Helmholtz, Laplace and Stokes functionalities.
Let
where
using FMM2D
# Simple example for the FMM2D Library
thresh = 10.0^(-5) # Tolerance
zk = rand(ComplexF64) # Wavenumber
# Source-to-source
n = 200
sources = rand(2,n)
charges = rand(ComplexF64,n)
pg = 3 # Evaluate potential, gradient, and Hessian at the sources
vals = hfmm2d(eps=thresh,zk=zk,sources=sources,charges=charges,pg=pg)
vals.pot
vals.grad
vals.hess
# Source-to-target
m = 200
targets = rand(2,m)
pgt = 3 # Evaluate potential, gradient, and Hessian at the targets
vals = hfmm2d(targets=targets,eps=thresh,zk=zk,sources=sources,charges=charges,pgt=pgt)
vals.pottarg
vals.gradtarg
vals.hesstargThe Laplace problem in 2D have the following form
In the case of complex charges and dipole strengths (lfmm2d has to be used. In the case of real charges and dipole strengths (rfmm2d has to be used.
using FMM2D
# Simple example for the FMM2D Library
thresh = 10.0^(-5) # Tolerance
# Source-to-source
n = 200
sources = rand(2,n)
charges = rand(ComplexF64,n)
dipvecs = randn(2,n)
dipstr = rand(ComplexF64,n)
pg = 3 # Evaluate potential, gradient, and Hessian at the sources
vals = lfmm2d(eps=thresh,sources=sources,charges=charges,dipvecs=dipvecs,dipstr=dipstr,pg=pg)
vals.pot
vals.grad
vals.hess
# Source-to-target
m = 100
targets = rand(2,m)
pgt = 3 # Evaluate potential, gradient, and Hessian at the targets
vals = lfmm2d(targets=targets,eps=thresh,sources=sources,charges=charges,dipvecs=dipvecs,dipstr=dipstr,pgt=pgt)
vals.pottarg
vals.gradtarg
vals.hesstargFor a source
The function stfmm2d computes the velocity
together with the associated pressure and, optionally, the velocity gradient. When
using FMM2D
thresh = 1e-8
n = 200
sources = rand(2,n)
stoklet = rand(2,n) # Stokeslet strengths
strslet = rand(2,n) # stresslet strengths
strsvec = rand(2,n) # stresslet orientations
# Source-to-source (velocity, pressure and gradient)
vals = stfmm2d(eps=thresh, sources=sources, stoklet=stoklet,
strslet=strslet, strsvec=strsvec, ppreg=3)
vals.pot # velocity
vals.pre # pressure
vals.grad # velocity gradient
# Source-to-target
m = 100
targets = rand(2,m)
vals = stfmm2d(eps=thresh, sources=sources, stoklet=stoklet,
targets=targets, ppregt=1)
vals.pottargFMMLIB2D.jl interfaces the FMMLIB2D library which the FMM2D library improves on.