meshmode icon indicating copy to clipboard operation
meshmode copied to clipboard

Change tag/face mapping argument of `_compute_facial_adjacency_from_vertices`

Open majosm opened this issue 3 years ago • 1 comments

Now accepts a list of dicts (one per mesh group), where each dict maps a tag to a numpy array of element/face indices that belong to that tag. This removes the need to use Python loops over elements when generating and using the tag/face mappings.

majosm avatar Oct 12 '22 02:10 majosm

Any idea of how much faster this is compared to #350?

On my laptop, for a mesh with 1.2M elements:

main:

53.433 _get_box_mesh  poiseuille-mpi.py:74
└─ 53.420 inner_wrapper  pytools/__init__.py:243
   └─ 53.420 generate_regular_rect_mesh  meshmode/mesh/generation.py:1309
      └─ 53.417 inner_wrapper  pytools/__init__.py:243
            [2 frames hidden]  pytools
               53.393 generate_box_mesh  meshmode/mesh/generation.py:959
               ├─ 32.986 [self]  
               ├─ 5.383 <listcomp>  meshmode/mesh/generation.py:1228
               ├─ 3.608 <genexpr>  meshmode/mesh/generation.py:1262
               ├─ 2.667 __getattribute__  meshmode/mesh/__init__.py:279
               ├─ 1.440 _compute_facial_adjacency_from_vertices  meshmode/mesh/__init__.py:1400
               │  └─ 0.717 _match_faces_by_vertices  meshmode/mesh/__init__.py:1348
               ├─ 1.427 len  <built-in>:0
               │     [2 frames hidden]  <built-in>
               ├─ 1.342 list.index  <built-in>:0
               │     [2 frames hidden]  <built-in>
               ├─ 1.235 wrapper  pytools/__init__.py:752
               │     [4 frames hidden]  pytools, <built-in>
               ├─ 1.171 all  <built-in>:0
               │     [2 frames hidden]  <built-in>
               ├─ 0.995 __init__  meshmode/mesh/__init__.py:961
               │  └─ 0.797 _test_node_vertex_consistency  meshmode/mesh/__init__.py:1256
               │     └─ 0.775 _test_node_vertex_consistency_resampling  meshmode/mesh/__init__.py:1221
               └─ 0.606 inner_wrapper  pytools/__init__.py:243
                     [2 frames hidden]  pytools
                        0.595 make_group_from_vertices  meshmode/mesh/generation.py:340

optimize-tag-face-mapping:

5.350 _get_box_mesh  poiseuille-mpi.py:74
└─ 5.338 inner_wrapper  pytools/__init__.py:243
   └─ 5.338 generate_regular_rect_mesh  meshmode/mesh/generation.py:1308
      └─ 5.335 inner_wrapper  pytools/__init__.py:243
            [2 frames hidden]  pytools
               5.328 generate_box_mesh  meshmode/mesh/generation.py:959
               ├─ 1.793 [self]  
               ├─ 1.308 _compute_facial_adjacency_from_vertices  meshmode/mesh/__init__.py:1418
               │  ├─ 0.650 _match_faces_by_vertices  meshmode/mesh/__init__.py:1371
               │  │  ├─ 0.346 _find_matching_index_pairs_merged  meshmode/mesh/__init__.py:1348
               │  │  │  ├─ 0.160 lexsort  <__array_function__ internals>:177
               │  │  │  │     [3 frames hidden]  <__array_function__ internals>, <buil...
               │  │  │  ├─ 0.096 [self]  
               │  │  │  └─ 0.068 any  <__array_function__ internals>:177
               │  │  │        [5 frames hidden]  <__array_function__ internals>, numpy...
               │  │  ├─ 0.183 [self]  
               │  │  └─ 0.112 sort  <__array_function__ internals>:177
               │  │        [6 frames hidden]  <__array_function__ internals>, numpy...
               │  ├─ 0.259 lexsort  <__array_function__ internals>:177
               │  │     [3 frames hidden]  <__array_function__ internals>, <buil...
               │  ├─ 0.204 [self]  
               │  └─ 0.076 unique  <__array_function__ internals>:177
               │        [9 frames hidden]  <__array_function__ internals>, numpy...
               ├─ 0.902 __init__  meshmode/mesh/__init__.py:961
               │  ├─ 0.716 _test_node_vertex_consistency  meshmode/mesh/__init__.py:1256
               │  │  └─ 0.705 _test_node_vertex_consistency_resampling  meshmode/mesh/__init__.py:1221
               │  │     ├─ 0.339 amax  <__array_function__ internals>:177
               │  │     │     [5 frames hidden]  <__array_function__ internals>, numpy...
               │  │     ├─ 0.263 _mesh_group_node_vertex_error  meshmode/mesh/__init__.py:1202
               │  │     │  ├─ 0.140 [self]  
               │  │     │  └─ 0.122 einsum  <__array_function__ internals>:177
               │  │     │        [4 frames hidden]  <__array_function__ internals>, numpy...
               │  │     └─ 0.103 [self]  
               │  └─ 0.179 test_volume_mesh_element_orientations  meshmode/mesh/processing.py:637
               │     └─ 0.173 find_volume_mesh_element_orientations  meshmode/mesh/processing.py:603
               │        └─ 0.161 find_volume_mesh_element_group_orientation  meshmode/mesh/processing.py:553
               │           └─ 0.100 [self]  
               ├─ 0.611 inner_wrapper  pytools/__init__.py:243
               │     [2 frames hidden]  pytools
               │        0.603 make_group_from_vertices  meshmode/mesh/generation.py:340
               │        ├─ 0.402 einsum  <__array_function__ internals>:177
               │        │     [4 frames hidden]  <__array_function__ internals>, numpy...
               │        └─ 0.178 [self]  
               ├─ 0.303 unravel_index  <__array_function__ internals>:177
               │     [3 frames hidden]  <__array_function__ internals>, <buil...
               ├─ 0.194 stack  <__array_function__ internals>:177
               │     [5 frames hidden]  <__array_function__ internals>, numpy...
               └─ 0.186 all  <__array_function__ internals>:177
                     [5 frames hidden]  <__array_function__ internals>, numpy...

majosm avatar Oct 12 '22 22:10 majosm