Skip to content

Commit

Permalink
Bump pyo3 and numpy versions to 0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromerobert committed Nov 29, 2024
1 parent db86f08 commit 13c58b5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ crate-type = ["cdylib"]
[dependencies]
log = "0.4.22"
tucanos = { git = "https://github.com/tucanos/tucanos.git", rev = "252380e" }
numpy = "0.21"
pyo3 = { version = "0.21", features = ["extension-module", "multiple-pymethods"] }
numpy = "0.22"
pyo3 = { version = "0.22", features = ["extension-module", "multiple-pymethods"] }
pyo3-log = "0.11"

[features]
Expand Down
1 change: 1 addition & 0 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ macro_rules! create_geometry {
/// Create a new geometry
#[new]
#[must_use]
#[pyo3(signature = (mesh, geom=None))]
pub fn new(
mesh: &$mesh,
geom: Option<&$geom>,
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ mod mesh;
mod parallel;
mod remesher;
use numpy::{PyArray, PyArray1, PyArray2, PyArrayMethods};
use pyo3::{pymodule, types::PyModule, Bound, PyResult, Python};
use pyo3::{
pymodule,
types::{PyModule, PyModuleMethods},
Bound, PyResult, Python,
};

fn to_numpy_1d<T: numpy::Element>(py: Python<'_>, vec: Vec<T>) -> Bound<'_, PyArray1<T>> {
PyArray::from_vec_bound(py, vec)
Expand Down
10 changes: 10 additions & 0 deletions src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ macro_rules! create_mesh {
}

/// Write a vtk file containing the mesh
#[pyo3(signature = (file_name, vert_data=None, elem_data=None))]
pub fn write_vtk(&self,
file_name: &str,
vert_data : Option<HashMap<String, PyReadonlyArray2<f64>>>,
Expand Down Expand Up @@ -363,6 +364,7 @@ macro_rules! create_mesh {
}

/// Interpolate a field (scalar or vector) defined at the vertices (P1) to a different mesh using linear interpolation
#[pyo3(signature = (other, arr, tol=None))]
pub fn interpolate_linear<'py>(
&mut self,
py: Python<'py>,
Expand Down Expand Up @@ -394,6 +396,7 @@ macro_rules! create_mesh {
}

/// Smooth a field defined at the mesh vertices using a 1st order least-square approximation
#[pyo3(signature = (arr, weight_exp=None))]
pub fn smooth<'py>(
&self,
py: Python<'py>,
Expand All @@ -417,6 +420,7 @@ macro_rules! create_mesh {
}

/// Compute the gradient of a field defined at the mesh vertices using a 1st order least-square approximation
#[pyo3(signature = (arr, weight_exp=None))]
pub fn compute_gradient<'py>(
&self,
py: Python<'py>,
Expand Down Expand Up @@ -446,6 +450,7 @@ macro_rules! create_mesh {
/// Compute the hessian of a field defined at the mesh vertices using a 2nd order least-square approximation
/// if `weight_exp` is `None`, the vertex has a weight 10, its first order neighbors have
/// a weight 1 and the 2nd order neighbors (if used) have a weight of 0.1
#[pyo3(signature = (arr, weight_exp=None, use_second_order_neighbors=None))]
pub fn compute_hessian<'py>(
&self,
py: Python<'py>,
Expand Down Expand Up @@ -567,6 +572,7 @@ impl Mesh33 {
#[allow(clippy::too_many_arguments)]
#[allow(clippy::too_many_lines)]
#[classmethod]
#[pyo3(signature = (coords, hexs=None, hex_tags=None, pris=None, pri_tags=None, pyrs=None, pyr_tags=None, tets=None, tet_tags=None, quas=None, qua_tags=None, tris=None, tri_tags=None))]
pub fn from_basic_elems(
_cls: &Bound<'_, PyType>,
coords: PyReadonlyArray2<f64>,
Expand Down Expand Up @@ -734,6 +740,7 @@ impl Mesh33 {
/// - if an implied metric is provided, the result is limited to (1/step,step) times the implied metric
/// - if a normal size array is not provided, the minimum of the tangential sizes is used.
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (geom, r_h, beta, h_min=None, h_n=None, h_n_tags=None))]
pub fn curvature_metric<'py>(
&self,
py: Python<'py>,
Expand Down Expand Up @@ -779,6 +786,7 @@ impl Mesh32 {
/// Create a Mesh32 from basic elements
#[classmethod]
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (coords, quas=None, qua_tags=None, tris=None, tri_tags=None, edgs=None, edg_tags=None))]
pub fn from_basic_elems(
_cls: &Bound<'_, PyType>,
coords: PyReadonlyArray2<f64>,
Expand Down Expand Up @@ -887,6 +895,7 @@ impl Mesh22 {
/// Create a Mesh22 from basic elements
#[allow(clippy::too_many_arguments)]
#[classmethod]
#[pyo3(signature = (coords, quas=None, qua_tags=None, tris=None, tri_tags=None, edgs=None, edg_tags=None))]
pub fn from_basic_elems(
_cls: &Bound<'_, PyType>,
coords: PyReadonlyArray2<f64>,
Expand Down Expand Up @@ -989,6 +998,7 @@ impl Mesh22 {
/// - the metric is entended into the volume with gradation beta
/// - if a normal size array is not provided, the minimum of the tangential sizes is used.
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (geom, r_h, beta, h_min=None, h_n=None, h_n_tags=None))]
pub fn curvature_metric<'py>(
&self,
py: Python<'py>,
Expand Down
1 change: 1 addition & 0 deletions src/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ macro_rules! create_parallel_remesher {
}

#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (geometry, m, num_iter=None, two_steps=None, split_max_iter=None, split_min_l_rel=None, split_min_l_abs=None, split_min_q_rel=None, split_min_q_abs=None, collapse_max_iter=None, collapse_max_l_rel=None, collapse_max_l_abs=None, collapse_min_q_rel=None, collapse_min_q_abs=None, swap_max_iter=None, swap_max_l_rel=None, swap_max_l_abs=None, swap_min_l_rel=None, swap_min_l_abs=None, smooth_iter=None, smooth_type=None, smooth_relax=None, smooth_keep_local_minima=None, max_angle=None, debug=None, n_layers=None, n_levels=None, min_verts=None))]
pub fn remesh<'py>(&mut self,
py: Python<'py>,
geometry: &$geom,
Expand Down
4 changes: 4 additions & 0 deletions src/remesher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ macro_rules! create_remesher {
/// Convert a Hessian $H$ to the optimal metric for a Lp norm, i.e.
/// $$ m = det(|H|)^{-1/(2p+dim)}|H| $$
#[classmethod]
#[pyo3(signature = (mesh, m, p=None))]
pub fn hessian_to_metric<'py>(
_cls: &Bound<'_, PyType>,
py: Python<'py>,
Expand Down Expand Up @@ -97,6 +98,7 @@ macro_rules! create_remesher {
/// Scale a metric field to reach the desired (ideal) number of elements using min / max bounds on the cell size
#[classmethod]
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (mesh, m, h_min, h_max, n_elems, fixed_m=None, implied_m=None, step=None, max_iter=None))]
pub fn scale_metric<'py>(
_cls: &Bound<'_, PyType>,
py: Python<'py>,
Expand Down Expand Up @@ -340,6 +342,7 @@ macro_rules! create_remesher {

#[doc = concat!("Get the mesh as a ", stringify!($mesh))]
#[must_use]
#[pyo3(signature = (only_bdy_faces=None))]
pub fn to_mesh(&self, only_bdy_faces: Option<bool>) -> $mesh {
$mesh {
mesh: self.remesher.to_mesh(only_bdy_faces.unwrap_or(false)),
Expand Down Expand Up @@ -402,6 +405,7 @@ macro_rules! create_remesher {

/// Perform a remeshing iteration
#[allow(clippy::too_many_arguments)]
#[pyo3(signature = (geometry, num_iter=None, two_steps=None, split_max_iter=None, split_min_l_rel=None, split_min_l_abs=None, split_min_q_rel=None, split_min_q_abs=None, collapse_max_iter=None, collapse_max_l_rel=None, collapse_max_l_abs=None, collapse_min_q_rel=None, collapse_min_q_abs=None, swap_max_iter=None, swap_max_l_rel=None, swap_max_l_abs=None, swap_min_l_rel=None, swap_min_l_abs=None, smooth_iter=None, smooth_type=None, smooth_relax=None, smooth_keep_local_minima=None, max_angle=None, debug=None))]
pub fn remesh(
&mut self,
geometry: &$geom,
Expand Down

0 comments on commit 13c58b5

Please sign in to comment.