@@ -66,10 +66,12 @@ macro_rules! create_mesh {
66
66
) . collect( ) ;
67
67
68
68
let elems = elems. as_slice( ) ?;
69
- let elems = elems. chunks( $etype:: N_VERTS as usize ) . map( |e| $etype:: from_slice( e) ) . collect( ) ;
69
+ let elems = elems. chunks( $etype:: N_VERTS as usize ) . map(
70
+ |e| $etype:: from_slice( e) ) . collect( ) ;
70
71
71
72
let faces = faces. as_slice( ) ?;
72
- let faces = faces. chunks( <$etype as Elem >:: Face :: N_VERTS as usize ) . map( |e| <$etype as Elem >:: Face :: from_slice( e) ) . collect( ) ;
73
+ let faces = faces. chunks( <$etype as Elem >:: Face :: N_VERTS as usize ) . map(
74
+ |e| <$etype as Elem >:: Face :: from_slice( e) ) . collect( ) ;
73
75
74
76
Ok ( Self {
75
77
mesh: SimplexMesh :: <$dim, $etype>:: new(
@@ -99,7 +101,8 @@ macro_rules! create_mesh {
99
101
100
102
/// Write a solution to a .sol(b) file
101
103
pub fn write_solb( & self , fname: & str , arr: PyReadonlyArray2 <f64 >) -> PyResult <( ) > {
102
- self . mesh. write_solb( & arr. to_vec( ) . unwrap( ) , fname) . map_err( |e| PyRuntimeError :: new_err( e. to_string( ) ) )
104
+ self . mesh. write_solb( & arr. to_vec( ) . unwrap( ) , fname) . map_err(
105
+ |e| PyRuntimeError :: new_err( e. to_string( ) ) )
103
106
}
104
107
105
108
@@ -222,9 +225,11 @@ macro_rules! create_mesh {
222
225
}
223
226
}
224
227
225
- /// Add the missing boundary faces and make sure that boundary faces are oriented outwards
228
+ /// Add the missing boundary faces and make sure that boundary faces are oriented
229
+ /// outwards.
226
230
/// If internal faces are present, these are keps
227
- pub fn add_boundary_faces<' py>( & mut self , py: Python <' py>) -> PyResult <( Bound <' py, PyDict >, Bound <' py, PyDict >) > {
231
+ pub fn add_boundary_faces<' py>( & mut self , py: Python <' py>) ->
232
+ PyResult <( Bound <' py, PyDict >, Bound <' py, PyDict >) > {
228
233
let ( bdy, ifc) = self . mesh. add_boundary_faces( ) ;
229
234
let dict_bdy = PyDict :: new_bound( py) ;
230
235
for ( k, v) in bdy. iter( ) {
@@ -277,7 +282,9 @@ macro_rules! create_mesh {
277
282
Ok ( ( ) )
278
283
}
279
284
280
- #[ doc = concat!( "Get a copy of the mesh coordinates as a numpy array of shape (# of vertices, " , stringify!( $dim) , ")" ) ]
285
+ #[ doc = concat!(
286
+ "Get a copy of the mesh coordinates as a numpy array of shape (# of vertices, " ,
287
+ stringify!( $dim) , ")" ) ]
281
288
pub fn get_coords<' py>( & mut self , py: Python <' py>) -> Bound <' py, PyArray2 <f64 >> {
282
289
let mut coords = Vec :: with_capacity( self . mesh. n_verts( ) as usize * $dim) ;
283
290
for v in self . mesh. verts( ) {
@@ -318,8 +325,11 @@ macro_rules! create_mesh {
318
325
}
319
326
320
327
/// Reorder the vertices, element and faces using a Hilbert SFC
321
- pub fn reorder_hilbert<' py>( & mut self , py: Python <' py>) -> PyResult <( Bound <' py, PyArray1 <Idx >>, Bound <' py, PyArray1 <Idx >>, Bound <' py, PyArray1 <Idx >>) >{
322
- let ( new_vertex_indices, new_elem_indices, new_face_indices) = self . mesh. reorder_hilbert( ) ;
328
+ pub fn reorder_hilbert<' py>( & mut self , py: Python <' py>) ->
329
+ PyResult <( Bound <' py, PyArray1 <Idx >>, Bound <' py, PyArray1 <Idx >>,
330
+ Bound <' py, PyArray1 <Idx >>) >{
331
+ let ( new_vertex_indices, new_elem_indices, new_face_indices) =
332
+ self . mesh. reorder_hilbert( ) ;
323
333
Ok (
324
334
(
325
335
to_numpy_1d( py, new_vertex_indices) ,
@@ -330,8 +340,8 @@ macro_rules! create_mesh {
330
340
331
341
}
332
342
333
- /// Convert a (scalar or vector) field defined at the element centers (P0) to a field defined at the vertices (P1)
334
- /// using a weighted average.
343
+ /// Convert a (scalar or vector) field defined at the element centers (P0) to a field
344
+ /// defined at the vertices (P1) using a weighted average.
335
345
pub fn elem_data_to_vertex_data<' py>(
336
346
& mut self ,
337
347
py: Python <' py>,
@@ -349,8 +359,8 @@ macro_rules! create_mesh {
349
359
Ok ( to_numpy_2d( py, res. unwrap( ) , arr. shape( ) [ 1 ] ) )
350
360
}
351
361
352
- /// Convert a field (scalar or vector) defined at the vertices (P1) to a field defined at the
353
- /// element centers (P0)
362
+ /// Convert a field (scalar or vector) defined at the vertices (P1) to a field defined
363
+ /// at the element centers (P0)
354
364
pub fn vertex_data_to_elem_data<' py>(
355
365
& mut self ,
356
366
py: Python <' py>,
@@ -363,7 +373,8 @@ macro_rules! create_mesh {
363
373
Ok ( to_numpy_2d( py, res. unwrap( ) , arr. shape( ) [ 1 ] ) )
364
374
}
365
375
366
- /// Interpolate a field (scalar or vector) defined at the vertices (P1) to a different mesh using linear interpolation
376
+ /// Interpolate a field (scalar or vector) defined at the vertices (P1) to a different
377
+ /// mesh using linear interpolation
367
378
#[ pyo3( signature = ( other, arr, tol=None ) ) ]
368
379
pub fn interpolate_linear<' py>(
369
380
& mut self ,
@@ -376,11 +387,13 @@ macro_rules! create_mesh {
376
387
return Err ( PyValueError :: new_err( "Invalid dimension 0" ) ) ;
377
388
}
378
389
let tree = self . mesh. compute_elem_tree( ) ;
379
- let res = self . mesh. interpolate_linear( & tree, & other. mesh, arr. as_slice( ) . unwrap( ) , tol) ;
390
+ let res = self . mesh. interpolate_linear( & tree, & other. mesh, arr. as_slice( ) . unwrap( ) ,
391
+ tol) ;
380
392
Ok ( to_numpy_2d( py, res. unwrap( ) , arr. shape( ) [ 1 ] ) )
381
393
}
382
394
383
- /// Interpolate a field (scalar or vector) defined at the vertices (P1) to a different mesh using nearest neighbor interpolation
395
+ /// Interpolate a field (scalar or vector) defined at the vertices (P1) to a different
396
+ /// mesh using nearest neighbor interpolation
384
397
pub fn interpolate_nearest<' py>(
385
398
& mut self ,
386
399
py: Python <' py>,
@@ -391,11 +404,13 @@ macro_rules! create_mesh {
391
404
return Err ( PyValueError :: new_err( "Invalid dimension 0" ) ) ;
392
405
}
393
406
let tree = self . mesh. compute_vert_tree( ) ;
394
- let res = self . mesh. interpolate_nearest( & tree, & other. mesh, arr. as_slice( ) . unwrap( ) ) ;
407
+ let res = self . mesh. interpolate_nearest( & tree, & other. mesh,
408
+ arr. as_slice( ) . unwrap( ) ) ;
395
409
Ok ( to_numpy_2d( py, res. unwrap( ) , arr. shape( ) [ 1 ] ) )
396
410
}
397
411
398
- /// Smooth a field defined at the mesh vertices using a 1st order least-square approximation
412
+ /// Smooth a field defined at the mesh vertices using a 1st order least-square
413
+ /// approximation
399
414
#[ pyo3( signature = ( arr, weight_exp=None ) ) ]
400
415
pub fn smooth<' py>(
401
416
& self ,
@@ -419,7 +434,8 @@ macro_rules! create_mesh {
419
434
Ok ( to_numpy_2d( py, res. unwrap( ) , arr. shape( ) [ 1 ] ) )
420
435
}
421
436
422
- /// Compute the gradient of a field defined at the mesh vertices using a 1st order least-square approximation
437
+ /// Compute the gradient of a field defined at the mesh vertices using a 1st order
438
+ /// least-square approximation
423
439
#[ pyo3( signature = ( arr, weight_exp=None ) ) ]
424
440
pub fn compute_gradient<' py>(
425
441
& self ,
@@ -447,9 +463,10 @@ macro_rules! create_mesh {
447
463
) )
448
464
}
449
465
450
- /// Compute the hessian of a field defined at the mesh vertices using a 2nd order least-square approximation
451
- /// if `weight_exp` is `None`, the vertex has a weight 10, its first order neighbors have
452
- /// a weight 1 and the 2nd order neighbors (if used) have a weight of 0.1
466
+ /// Compute the hessian of a field defined at the mesh vertices using a 2nd order
467
+ /// least-square approximation
468
+ /// if `weight_exp` is `None`, the vertex has a weight 10, its first order neighbors
469
+ /// have a weight 1 and the 2nd order neighbors (if used) have a weight of 0.1
453
470
#[ pyo3( signature = ( arr, weight_exp=None , use_second_order_neighbors=None ) ) ]
454
471
pub fn compute_hessian<' py>(
455
472
& self ,
@@ -467,7 +484,8 @@ macro_rules! create_mesh {
467
484
468
485
let res = self
469
486
. mesh
470
- . hessian( arr. as_slice( ) . unwrap( ) , weight_exp, use_second_order_neighbors. unwrap_or( true ) ) ;
487
+ . hessian( arr. as_slice( ) . unwrap( ) , weight_exp,
488
+ use_second_order_neighbors. unwrap_or( true ) ) ;
471
489
if let Err ( res) = res {
472
490
return Err ( PyRuntimeError :: new_err( res. to_string( ) ) ) ;
473
491
}
@@ -530,7 +548,8 @@ macro_rules! create_mesh {
530
548
}
531
549
532
550
/// Automatically tag the elements based on a feature angle
533
- pub fn autotag<' py>( & mut self , py: Python <' py>, angle_deg: f64 ) -> PyResult <Bound <' py, PyDict >> {
551
+ pub fn autotag<' py>( & mut self , py: Python <' py>, angle_deg: f64 )
552
+ -> PyResult <Bound <' py, PyDict >> {
534
553
let res = self . mesh. autotag( angle_deg) ;
535
554
if let Err ( res) = res {
536
555
Err ( PyRuntimeError :: new_err( res. to_string( ) ) )
@@ -544,7 +563,8 @@ macro_rules! create_mesh {
544
563
}
545
564
546
565
/// Automatically tag the faces based on a feature angle
547
- pub fn autotag_bdy<' py>( & mut self , py: Python <' py>, angle_deg: f64 ) -> PyResult <Bound <' py, PyDict >> {
566
+ pub fn autotag_bdy<' py>( & mut self , py: Python <' py>, angle_deg: f64 )
567
+ -> PyResult <Bound <' py, PyDict >> {
548
568
let res = self . mesh. autotag_bdy( angle_deg) ;
549
569
if let Err ( res) = res {
550
570
Err ( PyRuntimeError :: new_err( res. to_string( ) ) )
@@ -572,7 +592,9 @@ impl Mesh33 {
572
592
#[ allow( clippy:: too_many_arguments) ]
573
593
#[ allow( clippy:: too_many_lines) ]
574
594
#[ classmethod]
575
- #[ 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 ) ) ]
595
+ #[ pyo3( signature = ( coords, hexs=None , hex_tags=None , pris=None , pri_tags=None , pyrs=None ,
596
+ pyr_tags=None , tets=None , tet_tags=None , quas=None , qua_tags=None , tris=None ,
597
+ tri_tags=None ) ) ]
576
598
pub fn from_basic_elems (
577
599
_cls : & Bound < ' _ , PyType > ,
578
600
coords : PyReadonlyArray2 < f64 > ,
@@ -734,10 +756,11 @@ impl Mesh33 {
734
756
}
735
757
736
758
/// Get a metric defined on all the mesh vertices such that
737
- /// - for boundary vertices, the principal directions are aligned with the principal curvature directions
738
- /// and the sizes to curvature radius ratio is r_h
759
+ /// - for boundary vertices, the principal directions are aligned with the principal curvature
760
+ /// directions and the sizes to curvature radius ratio is r_h
739
761
/// - the metric is entended into the volume with gradation beta
740
- /// - if an implied metric is provided, the result is limited to (1/step,step) times the implied metric
762
+ /// - if an implied metric is provided, the result is limited to (1/step,step) times the
763
+ /// implied metric
741
764
/// - if a normal size array is not provided, the minimum of the tangential sizes is used.
742
765
#[ allow( clippy:: too_many_arguments) ]
743
766
#[ pyo3( signature = ( geom, r_h, beta, h_min=None , h_n=None , h_n_tags=None ) ) ]
@@ -786,7 +809,8 @@ impl Mesh32 {
786
809
/// Create a Mesh32 from basic elements
787
810
#[ classmethod]
788
811
#[ allow( clippy:: too_many_arguments) ]
789
- #[ pyo3( signature = ( coords, quas=None , qua_tags=None , tris=None , tri_tags=None , edgs=None , edg_tags=None ) ) ]
812
+ #[ pyo3( signature = ( coords, quas=None , qua_tags=None , tris=None , tri_tags=None , edgs=None ,
813
+ edg_tags=None ) ) ]
790
814
pub fn from_basic_elems (
791
815
_cls : & Bound < ' _ , PyType > ,
792
816
coords : PyReadonlyArray2 < f64 > ,
@@ -895,7 +919,8 @@ impl Mesh22 {
895
919
/// Create a Mesh22 from basic elements
896
920
#[ allow( clippy:: too_many_arguments) ]
897
921
#[ classmethod]
898
- #[ pyo3( signature = ( coords, quas=None , qua_tags=None , tris=None , tri_tags=None , edgs=None , edg_tags=None ) ) ]
922
+ #[ pyo3( signature = ( coords, quas=None , qua_tags=None , tris=None , tri_tags=None , edgs=None ,
923
+ edg_tags=None ) ) ]
899
924
pub fn from_basic_elems (
900
925
_cls : & Bound < ' _ , PyType > ,
901
926
coords : PyReadonlyArray2 < f64 > ,
@@ -993,8 +1018,8 @@ impl Mesh22 {
993
1018
}
994
1019
995
1020
/// Get a metric defined on all the mesh vertices such that
996
- /// - for boundary vertices, the principal directions are aligned with the principal curvature directions
997
- /// and the sizes to curvature radius ratio is r_h
1021
+ /// - for boundary vertices, the principal directions are aligned with the principal curvature
1022
+ /// directions and the sizes to curvature radius ratio is r_h
998
1023
/// - the metric is entended into the volume with gradation beta
999
1024
/// - if a normal size array is not provided, the minimum of the tangential sizes is used.
1000
1025
#[ allow( clippy:: too_many_arguments) ]
0 commit comments