Skip to content

Commit d1e412b

Browse files
authored
Merge pull request #167 from scientificcomputing/dokken/expose-pcloud-tol
Add tolerance to point source
2 parents 982d361 + 4685c0e commit d1e412b

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-backend = "scikit_build_core.build"
1010

1111
[project]
1212
name = "scifem"
13-
version = "0.14.0"
13+
version = "0.15.0"
1414
description = "Scientific tools for finite element methods"
1515
readme = "README.md"
1616
requires-python = ">=3.10"
@@ -138,7 +138,7 @@ tag = true
138138
sign_tags = false
139139
tag_name = "v{new_version}"
140140
tag_message = "Bump version: {current_version} → {new_version}"
141-
current_version = "0.14.0"
141+
current_version = "0.15.0"
142142

143143

144144
[[tool.bumpversion.files]]

src/scifem/point_source.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)