Skip to content

Commit c0bf074

Browse files
blackify
1 parent 175a869 commit c0bf074

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

sectionproperties/analysis/section.py

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from shapely.geometry import asPoint, Polygon
3131
from shapely.strtree import STRtree
3232

33+
3334
class Section:
3435
"""Class for structural cross-sections.
3536
@@ -188,7 +189,10 @@ def __init__(
188189
self.mesh_attributes = attributes
189190

190191
# create the search tree
191-
p_mesh = [Polygon(self.geometry.mesh["vertices"][tri][0:3]) for tri in self.geometry.mesh["triangles"]]
192+
p_mesh = [
193+
Polygon(self.geometry.mesh["vertices"][tri][0:3])
194+
for tri in self.geometry.mesh["triangles"]
195+
]
192196
self.poly_mesh_idx = dict((id(poly), i) for i, poly in enumerate(p_mesh))
193197
self.mesh_search_tree = STRtree(p_mesh)
194198

@@ -2134,7 +2138,17 @@ def get_sf_p(self):
21342138
)
21352139

21362140
def get_stress_at_point(
2137-
self, pt: List[float], N=0, Mxx=0, Myy=0, M11=0, M22=0, Mzz=0, Vx=0, Vy=0, agg_func=np.average
2141+
self,
2142+
pt: List[float],
2143+
N=0,
2144+
Mxx=0,
2145+
Myy=0,
2146+
M11=0,
2147+
M22=0,
2148+
Mzz=0,
2149+
Vx=0,
2150+
Vy=0,
2151+
agg_func=np.average,
21382152
) -> Tuple[float]:
21392153
"""Calaculates the stress at a point within an element for given design actions
21402154
and returns *(sigma_zz, tau_xz, tau_yz)*
@@ -2157,12 +2171,23 @@ def get_stress_at_point(
21572171
:return: Resultant normal and shear stresses (sigma_zz, tau_xz, tau_yz)
21582172
:rtype: tuple(float, float, float)
21592173
"""
2160-
sigs = self.get_stress_at_points([pt], N, Mxx, Myy, M11, M22, Mzz, Vx, Vy, agg_func)
2174+
sigs = self.get_stress_at_points(
2175+
[pt], N, Mxx, Myy, M11, M22, Mzz, Vx, Vy, agg_func
2176+
)
21612177
return next(sigs)
21622178

2163-
21642179
def get_stress_at_points(
2165-
self, pts: List[List[float]], N=0, Mxx=0, Myy=0, M11=0, M22=0, Mzz=0, Vx=0, Vy=0, agg_func=np.average
2180+
self,
2181+
pts: List[List[float]],
2182+
N=0,
2183+
Mxx=0,
2184+
Myy=0,
2185+
M11=0,
2186+
M22=0,
2187+
Mzz=0,
2188+
Vx=0,
2189+
Vy=0,
2190+
agg_func=np.average,
21662191
) -> List[Tuple]:
21672192
"""Calaculates the stress at a set of points within an element for given design actions
21682193
and returns *(sigma_zz, tau_xz, tau_yz)*
@@ -2214,10 +2239,14 @@ def get_stress_at_points(
22142239

22152240
for pt in pts:
22162241
query_geom = asPoint(pt)
2217-
tri_ids = [self.poly_mesh_idx[id(poly)] for poly in self.mesh_search_tree.query(query_geom) if poly.intersects(query_geom)]
2218-
if len(tri_ids) ==0:
2242+
tri_ids = [
2243+
self.poly_mesh_idx[id(poly)]
2244+
for poly in self.mesh_search_tree.query(query_geom)
2245+
if poly.intersects(query_geom)
2246+
]
2247+
if len(tri_ids) == 0:
22192248
sig = None
2220-
elif len(tri_ids)==1:
2249+
elif len(tri_ids) == 1:
22212250
tri = self.elements[tri_ids[0]]
22222251
sig = tri.local_element_stress(
22232252
p=pt,
@@ -2231,7 +2260,8 @@ def get_stress_at_points(
22312260
sigs = []
22322261
for idx in tri_ids:
22332262
tri = self.elements[idx]
2234-
sigs.append(tri.local_element_stress(
2263+
sigs.append(
2264+
tri.local_element_stress(
22352265
p=pt,
22362266
**action,
22372267
**sect_prop,
@@ -2247,6 +2277,7 @@ def get_stress_at_points(
22472277
)
22482278
yield sig
22492279

2280+
22502281
class PlasticSection:
22512282
"""Class for the plastic analysis of cross-sections.
22522283

0 commit comments

Comments
 (0)