Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMM for Maxwell with segments #218

Open
pescap opened this issue Oct 13, 2024 · 0 comments
Open

FMM for Maxwell with segments #218

pescap opened this issue Oct 13, 2024 · 0 comments

Comments

@pescap
Copy link
Contributor

pescap commented Oct 13, 2024

Hi, when I switch to fmm assembly for operators defined on segments, I get very different results.

I have attached a very simple script that reproduces the behavior.

import bempp.api
import numpy as np
import scipy
from matplotlib import pyplot as plt

# Define parameters: Even with a coarse resolution,
# where the FMM is expected to be dense, the results vary significantly across the multishape.

k0 = 1
precision = 1
#h = 2 * np.pi/(precision*k0)
h = 1
grid = bempp.api.shapes.multitrace_cube(h=h)

# Set the segments and swapped_normals corresponding to \Omega_1, the first half-cube in the multitrace_cube.
segments = [[1, 2, 3, 4, 5, 6]]
swapped_normals = [[]]

# The same half cube without more triangles.
grid1=bempp.api.shapes.cuboid(length = (1,1,0.5), origin=(0,0,0), h=h)

# Define the function spaces.
rwg = [bempp.api.function_space(grid, "RWG", 0, segments=seg, swapped_normals=normals, include_boundary_dofs=True)
              for seg, normals in zip(segments, swapped_normals)]

snc = [bempp.api.function_space(grid, "SNC", 0, segments=seg, swapped_normals=normals,include_boundary_dofs=True)
              for seg, normals in zip(segments, swapped_normals)]

rwg1 = bempp.api.function_space(grid1, "RWG", 0,include_boundary_dofs=True)
snc1 = bempp.api.function_space(grid1, "SNC", 0,include_boundary_dofs=True)

# Assembly A_1 in dense mode and fmm mode for both grids
efiem_dense = bempp.api.operators.boundary.maxwell.electric_field(rwg[0], rwg[0], snc[0], k0).weak_form()
efiem_fmm = bempp.api.operators.boundary.maxwell.electric_field(rwg[0], rwg[0], snc[0], k0, assembler='fmm').weak_form()
efie1m_dense = bempp.api.operators.boundary.maxwell.electric_field(rwg1, rwg1, snc1, k0).weak_form()
efie1m_fmm = bempp.api.operators.boundary.maxwell.electric_field(rwg1, rwg1, snc1, k0, assembler='fmm').weak_form()

N = efiem_dense.shape[0]
k = min(100,N-2)

# Plot the k first eigenvalues

eigvalsm_dense, eivects = scipy.sparse.linalg.eigs(efiem_dense, k = k)
eigvalsm_fmm, eivects = scipy.sparse.linalg.eigs(efiem_fmm, k = k)

eigvals1m_dense, eivects = scipy.sparse.linalg.eigs(efie1m_dense, k = k)
eigvals1m_fmm, eivects = scipy.sparse.linalg.eigs(efie1m_fmm, k = k)

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True, sharey=True)

ax1.scatter(np.real(eigvalsm_dense), np.imag(eigvalsm_dense), label='efiem_dense')
ax2.scatter(np.real(eigvalsm_fmm), np.imag(eigvalsm_fmm), label='efiem_fmm')

ax3.scatter(np.real(eigvals1m_dense), np.imag(eigvals1m_dense), label='efiem_dense')
ax4.scatter(np.real(eigvals1m_fmm), np.imag(eigvals1m_fmm), label='efiem_fmm')

which results in:
plot-fmm

For the multishape with FMM (top-right), there is a clear problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant