flatironinstitute / FMM3D

Flatiron Institute Fast Multipole Libraries --- This codebase is a set of libraries to compute N-body interactions governed by the Laplace and Helmholtz equations, to a specified precision, in three dimensions, on a multi-core shared-memory machine.
https://fmm3d.readthedocs.io
Other
91 stars 36 forks source link

Should zkfmm be used for h3dterms? #24

Closed isuruf closed 2 years ago

isuruf commented 2 years ago

In https://github.com/flatironinstitute/FMM3D/blob/6e3add2a8fb7cfc2b6b723975ff36f2adea48e28/src/Helmholtz/hfmm3d.f#L430 zkfmm = zk * b0 is passed for the h3dterms routine which I believe expects zk instead of zkfmm. I believe so because in the h3dterms routine, the parameter is named zk and that value is multiplied by the boxsize of the level, i.e. z1 at https://github.com/flatironinstitute/FMM3D/blob/df2114e23474469cb8b6f2937f037d7f387b0b0b/src/Helmholtz/h3dterms.f#L35 is equivalent to zk * boxsize(0) * boxsize(ilev) * 1.5 which I found rather odd.

cc @inducer

mrachh commented 2 years ago

Dear Isuru, Thanks for looking into this. I believe that the choice of zkfmm is correct, and this is because after the tree generation, all the sources, targets and boxsizes are also rescaled using b0inv in lines 390:411 in src/Helmholtz/hfmm3d.f

The reason for the factor of 1.5, is that it represents the distance to the closest target. Hope this clarifies the matter.

isuruf commented 2 years ago

Thanks @mrachh. It makes sense to me now.