Skip to content

Random “Point source is outside the mesh” error #166

@497e0bdf29873

Description

@497e0bdf29873

The following MWE randomly fails with a “Point source is outside the mesh” error in scifem.PointSource. Sometimes when you run it, it finishes without error, but more frequently, it fails.

import numpy as np
import scifem
from dolfinx import fem, mesh
from mpi4py import MPI

domain = mesh.create_rectangle(
    MPI.COMM_WORLD,
    [
        np.array([-2, -2]),
        np.array([2, 2]),
    ],
    [32, 32],
    mesh.CellType.triangle,
)

V = fem.functionspace(domain, ("Lagrange", 2))

μ = [
    (np.array([0.3, 0.5]), 1.0),
    (np.array([0.7, 0.8]), 1.0),
    (np.array([1.0, 0.3]), 1.0),
]

for point, alpha in μ:
    ps = scifem.PointSource(V, point, magnitude=alpha)

The exact error:

$ python fubar.py
Traceback (most recent call last):
  File "fubar.py", line 25, in <module>
    ps = scifem.PointSource(V, point, magnitude=alpha)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/fenicsx-env/lib/python3.13/site-packages/scifem/point_source.py", line 61, in __init__
    self.recompute_sources()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/fenicsx-env/lib/python3.13/site-packages/scifem/point_source.py", line 96, in recompute_sources
    raise ValueError("Point source is outside the mesh.")
ValueError: Point source is outside the mesh.

This is with scifem 0.13.1 and dolfinx 0.9.0. I tried updating everything to the latest versions available in conda, but it did not fix this error, and I ran into other problems with nanobind+dolfinx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions