Skip to content

Commit fe9f6b5

Browse files
authored
2.3.0 rc Rebase 1 (#276)
* Update package versions (#270) * Update to use the new tessellation API (#272) * update versions
1 parent 166747e commit fe9f6b5

File tree

6 files changed

+57
-39
lines changed

6 files changed

+57
-39
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ body:
3131
attributes:
3232
label: Version
3333
description: What version of PhysicsNeMo and PhysicsNeMo Symbolic are you running?
34-
placeholder: "example: 2.2.0"
34+
placeholder: "example: 2.3.0"
3535
validations:
3636
required: true
3737

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ All notable changes to this project will be documented in this file.
66
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9-
## [2.3.0a0] - 2025-XX-YY
9+
## [2.4.0a0] - 2026-XX-YY
1010

1111
### Added
1212

13-
- Added Blackwell support
14-
1513
### Changed
1614

1715
### Deprecated
@@ -24,6 +22,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2422

2523
### Dependencies
2624

25+
## [2.3.0] - 2025-11-17
26+
27+
### Added
28+
29+
- Added Blackwell support
2730

2831
## [2.2.0] - 2025-08-26
2932

physicsnemo/sym/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
__version__ = "2.3.0a0"
17+
__version__ = "2.4.0a0"
1818

1919
from pint import UnitRegistry
2020

physicsnemo/sym/geometry/tessellation.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
"""
2020

2121
import numpy as np
22-
import warp as wp
2322
from stl import mesh as np_mesh
2423

2524
from .geometry import Geometry
2625
from .parameterization import Parameterization, Bounds, Parameter
2726
from .curve import Curve
2827
from physicsnemo.sym.constants import diff_str
29-
from physicsnemo.utils.sdf import signed_distance_field
3028

3129

3230
class Tessellation(Geometry):
@@ -118,47 +116,57 @@ def _sdf(triangles, airtight):
118116
def sdf(invar, params, compute_sdf_derivatives=False):
119117
# gather points
120118
points = np.stack([invar["x"], invar["y"], invar["z"]], axis=1)
119+
points = np.squeeze(points)
120+
if points.ndim == 1:
121+
points = points.reshape(1, -1)
121122

122123
# normalize triangles and points
123124
minx, maxx, miny, maxy, minz, maxz = _find_mins_maxs(points)
124125
max_dis = max(max((maxx - minx), (maxy - miny)), (maxz - minz))
125-
store_triangles = np.array(triangles, dtype=np.float64)
126+
store_triangles = np.array(triangles, dtype=np.float32)
126127
store_triangles[:, :, 0] -= minx
127128
store_triangles[:, :, 1] -= miny
128129
store_triangles[:, :, 2] -= minz
129130
store_triangles *= 1 / max_dis
130-
store_triangles = store_triangles.reshape(-1, 3)
131+
store_triangles = store_triangles.reshape(-1, 3) # (n_vertices, 3)
131132
points[:, 0] -= minx
132133
points[:, 1] -= miny
133134
points[:, 2] -= minz
134135
points *= 1 / max_dis
135-
points = points.astype(np.float64).flatten()
136+
points = points.astype(np.float32) # Keep as (n_points, 3)
136137

137138
# compute sdf values
138139
outputs = {}
139140
if airtight:
141+
# Import locally to avoid pickling issues with multiprocessing
142+
import torch
143+
from physicsnemo.utils.sdf import signed_distance_field
144+
145+
torch_vertices = torch.from_numpy(store_triangles)
146+
torch_indices = torch.arange(
147+
store_triangles.shape[0], dtype=torch.int32
148+
)
149+
torch_points = torch.from_numpy(points)
150+
140151
sdf_field, sdf_derivative = signed_distance_field(
141-
store_triangles,
142-
np.arange((store_triangles.shape[0])),
143-
points,
144-
include_hit_points=True,
152+
torch_vertices,
153+
torch_indices,
154+
torch_points,
155+
max_dist=1e8,
156+
use_sign_winding_number=False,
145157
)
146-
if isinstance(sdf_field, wp.types.array):
147-
sdf_field = sdf_field.numpy()
148-
if isinstance(sdf_derivative, wp.types.array):
149-
sdf_derivative = sdf_derivative.numpy()
158+
159+
sdf_field = sdf_field.numpy()
160+
sdf_derivative = sdf_derivative.numpy() # Shape: (n_points, 3)
161+
150162
sdf_field = -np.expand_dims(max_dis * sdf_field, axis=1)
151-
sdf_derivative = sdf_derivative.reshape(-1)
152163
else:
153164
sdf_field = np.zeros_like(invar["x"])
154165
outputs["sdf"] = sdf_field
155166

156167
# get sdf derivatives
157168
if compute_sdf_derivatives:
158169
sdf_derivative = -(sdf_derivative - points)
159-
sdf_derivative = np.reshape(
160-
sdf_derivative, (sdf_derivative.shape[0] // 3, 3)
161-
)
162170
sdf_derivative = sdf_derivative / np.linalg.norm(
163171
sdf_derivative, axis=1, keepdims=True
164172
)

physicsnemo/sym/geometry/tessellation_warp.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from .parameterization import Parameterization, Bounds, Parameter
2525
from .curve import Curve
2626
from physicsnemo.sym.constants import diff_str
27-
from physicsnemo.utils.sdf import signed_distance_field
2827

2928

3029
@wp.kernel
@@ -364,44 +363,52 @@ def from_stl(
364363
def sdf(triangles, airtight, invar, params, compute_sdf_derivatives=False):
365364
"""Simple copy of the sdf function in tessellation.py."""
366365
points = np.stack([invar["x"], invar["y"], invar["z"]], axis=1)
366+
points = np.squeeze(points)
367+
if points.ndim == 1:
368+
points = points.reshape(1, -1)
367369

368370
minx, maxx, miny, maxy, minz, maxz = Tessellation.find_mins_maxs(points)
369371
max_dis = max(max((maxx - minx), (maxy - miny)), (maxz - minz))
370-
store_triangles = np.array(triangles, dtype=np.float64)
372+
store_triangles = np.array(triangles, dtype=np.float32)
371373
store_triangles[:, :, 0] -= minx
372374
store_triangles[:, :, 1] -= miny
373375
store_triangles[:, :, 2] -= minz
374376
store_triangles *= 1 / max_dis
375-
store_triangles = store_triangles.reshape(-1, 3)
377+
store_triangles = store_triangles.reshape(-1, 3) # (n_vertices, 3)
376378
points[:, 0] -= minx
377379
points[:, 1] -= miny
378380
points[:, 2] -= minz
379381
points *= 1 / max_dis
380-
points = points.astype(np.float64).flatten()
382+
points = points.astype(np.float32) # Keep as (n_points, 3)
381383

382384
outputs = {}
383385
if airtight:
386+
# Import locally to avoid pickling issues with multiprocessing
387+
import torch
388+
from physicsnemo.utils.sdf import signed_distance_field
389+
390+
torch_vertices = torch.from_numpy(store_triangles)
391+
torch_indices = torch.arange(store_triangles.shape[0], dtype=torch.int32)
392+
torch_points = torch.from_numpy(points)
393+
384394
sdf_field, sdf_derivative = signed_distance_field(
385-
store_triangles,
386-
np.arange((store_triangles.shape[0])),
387-
points,
388-
include_hit_points=True,
395+
torch_vertices,
396+
torch_indices,
397+
torch_points,
398+
max_dist=1e8,
399+
use_sign_winding_number=False,
389400
)
390-
if isinstance(sdf_field, wp.types.array):
391-
sdf_field = sdf_field.numpy()
392-
if isinstance(sdf_derivative, wp.types.array):
393-
sdf_derivative = sdf_derivative.numpy()
401+
402+
sdf_field = sdf_field.numpy()
403+
sdf_derivative = sdf_derivative.numpy() # Shape: (n_points, 3)
404+
394405
sdf_field = -np.expand_dims(max_dis * sdf_field, axis=1)
395-
sdf_derivative = sdf_derivative.reshape(-1)
396406
else:
397407
sdf_field = np.zeros_like(invar["x"])
398408
outputs["sdf"] = sdf_field
399409

400410
if compute_sdf_derivatives:
401411
sdf_derivative = -(sdf_derivative - points)
402-
sdf_derivative = np.reshape(
403-
sdf_derivative, (sdf_derivative.shape[0] // 3, 3)
404-
)
405412
sdf_derivative = sdf_derivative / np.linalg.norm(
406413
sdf_derivative, axis=1, keepdims=True
407414
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-scm<9.0.0"]
2+
requires = ["setuptools", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

55
[project]

0 commit comments

Comments
 (0)