@@ -27,6 +27,7 @@ def __init__(
2727 V : dolfinx .fem .FunctionSpace ,
2828 points : npt .NDArray [np .float32 ] | npt .NDArray [np .float64 ],
2929 magnitude : np .floating | np .complexfloating = dolfinx .default_scalar_type (1 ),
30+ tol : np .floating | None = None ,
3031 ) -> None :
3132 """Initialize a point source.
3233
@@ -35,6 +36,7 @@ def __init__(
3536 points: The points where the point source is located.
3637 Input shape: ``(num_points, 3)``
3738 magnitude: The magnitudes of the point sources.
39+ tol: Tolerance for point location. If `None` 100 times machine epsilon is used.
3840
3941 Note:
4042 Points should only be defined on one process. If they are sent in
@@ -57,19 +59,24 @@ def __init__(
5759 self ._basis_values = np .empty (
5860 (0 , num_dofs ), dtype = self ._function_space .mesh .geometry .x .dtype
5961 )
60-
62+ self ._tol = (
63+ float (1e2 * np .finfo (self ._input_points .dtype ).eps ) if tol is None else float (tol )
64+ )
6165 self .recompute_sources ()
6266 self .compute_cell_contributions ()
6367
64- def recompute_sources (self ):
68+ def recompute_sources (self , tol : float | None = None ):
6569 """Recompute the what cells the point sources collide with.
6670
6771 This function should be called if the mesh geometry has been modified.
72+
73+ Args:
74+ tol: Tolerance for point location. If `None`, the tolerance from initialization is used.
6875 """
6976
7077 # Determine what process owns a point and what cells it lies within
7178 mesh = self ._function_space .mesh
72- tol = float ( 1e2 * np . finfo ( self ._input_points . dtype ). eps )
79+ tol = self ._tol if tol is None else tol
7380 if dolfinx .__version__ == "0.8.0" :
7481 src_ranks , _ , self ._points , self ._cells = (
7582 dolfinx .cpp .geometry .determine_point_ownership (
0 commit comments