File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
sectionproperties/analysis Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,11 @@ def __init__(
187187 self .mesh_elements = elements
188188 self .mesh_attributes = attributes
189189
190+ # create the search tree
191+ p_mesh = [Polygon (self .geometry .mesh ["vertices" ][tri ][0 :3 ]) for tri in self .geometry .mesh ["triangles" ]]
192+ self .poly_mesh_idx = dict ((id (poly ), i ) for i , poly in enumerate (p_mesh ))
193+ self .mesh_search_tree = STRtree (p_mesh )
194+
190195 # initialise class storing section properties
191196 self .section_props = SectionProperties ()
192197
@@ -2207,14 +2212,9 @@ def get_stress_at_points(
22072212 "nu" : self .section_props .nu_eff ,
22082213 }
22092214
2210- #create the search tree
2211- p_mesh = [Polygon (self .geometry .mesh ["vertices" ][tri ][0 :3 ]) for tri in self .geometry .mesh ["triangles" ]]
2212- s_tree = STRtree (p_mesh )
2213- index_by_id = dict ((id (poly ), i ) for i , poly in enumerate (p_mesh ))
2214-
22152215 for pt in pts :
22162216 query_geom = asPoint (pt )
2217- tri_ids = [index_by_id [id (poly )] for poly in s_tree .query (query_geom ) if poly .intersects (query_geom )]
2217+ tri_ids = [self . poly_mesh_idx [id (poly )] for poly in self . mesh_search_tree .query (query_geom ) if poly .intersects (query_geom )]
22182218 if len (tri_ids ) == 0 :
22192219 sig = None
22202220 elif len (tri_ids )== 1 :
You can’t perform that action at this time.
0 commit comments