Skip to content

Commit 5c45b70

Browse files
Modify CruciformSection formulation to account for zero radius
1 parent 578eb69 commit 5c45b70

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

sectionproperties/pre/sections.py

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,64 +2155,76 @@ def __init__(self, d, b, t, r, n_r, shift=[0, 0]):
21552155
self.points.append([t * 0.5, -d * 0.5])
21562156

21572157
# construct the bottom right radius
2158-
for i in range(n_r):
2159-
# determine polar angle
2160-
theta = np.pi - i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
2158+
if r == 0:
2159+
self.points.append([0.5 * t, -0.5 * t])
2160+
else:
2161+
for i in range(n_r):
2162+
# determine polar angle
2163+
theta = np.pi - i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
21612164

2162-
# calculate the locations of the radius points
2163-
x = 0.5 * t + r + r * np.cos(theta)
2164-
y = -0.5 * t - r + r * np.sin(theta)
2165+
# calculate the locations of the radius points
2166+
x = 0.5 * t + r + r * np.cos(theta)
2167+
y = -0.5 * t - r + r * np.sin(theta)
21652168

2166-
# append the current points to the points list
2167-
self.points.append([x, y])
2169+
# append the current points to the points list
2170+
self.points.append([x, y])
21682171

21692172
# add the next two points
21702173
self.points.append([0.5 * b, -t * 0.5])
21712174
self.points.append([0.5 * b, t * 0.5])
21722175

21732176
# construct the top right radius
2174-
for i in range(n_r):
2175-
# determine polar angle
2176-
theta = 1.5 * np.pi - i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
2177+
if r == 0:
2178+
self.points.append([0.5 * t, 0.5 * t])
2179+
else:
2180+
for i in range(n_r):
2181+
# determine polar angle
2182+
theta = 1.5 * np.pi - i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
21772183

2178-
# calculate the locations of the radius points
2179-
x = 0.5 * t + r + r * np.cos(theta)
2180-
y = 0.5 * t + r + r * np.sin(theta)
2184+
# calculate the locations of the radius points
2185+
x = 0.5 * t + r + r * np.cos(theta)
2186+
y = 0.5 * t + r + r * np.sin(theta)
21812187

2182-
# append the current points to the points list
2183-
self.points.append([x, y])
2188+
# append the current points to the points list
2189+
self.points.append([x, y])
21842190

21852191
# add the next two points
21862192
self.points.append([t * 0.5, 0.5 * d])
21872193
self.points.append([-t * 0.5, 0.5 * d])
21882194

21892195
# construct the top left radius
2190-
for i in range(n_r):
2191-
# determine polar angle
2192-
theta = -i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
2196+
if r == 0:
2197+
self.points.append([-0.5 * t, 0.5 * t])
2198+
else:
2199+
for i in range(n_r):
2200+
# determine polar angle
2201+
theta = -i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
21932202

2194-
# calculate the locations of the radius points
2195-
x = -0.5 * t - r + r * np.cos(theta)
2196-
y = 0.5 * t + r + r * np.sin(theta)
2203+
# calculate the locations of the radius points
2204+
x = -0.5 * t - r + r * np.cos(theta)
2205+
y = 0.5 * t + r + r * np.sin(theta)
21972206

2198-
# append the current points to the points list
2199-
self.points.append([x, y])
2207+
# append the current points to the points list
2208+
self.points.append([x, y])
22002209

22012210
# add the next two points
22022211
self.points.append([-0.5 * b, t * 0.5])
22032212
self.points.append([-0.5 * b, -t * 0.5])
22042213

22052214
# construct the bottom left radius
2206-
for i in range(n_r):
2207-
# determine polar angle
2208-
theta = np.pi * 0.5 - i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
2215+
if r == 0:
2216+
self.points.append([-0.5 * t, -0.5 * t])
2217+
else:
2218+
for i in range(n_r):
2219+
# determine polar angle
2220+
theta = np.pi * 0.5 - i * 1.0 / max(1, n_r - 1) * np.pi * 0.5
22092221

2210-
# calculate the locations of the radius points
2211-
x = -0.5 * t - r + r * np.cos(theta)
2212-
y = -0.5 * t - r + r * np.sin(theta)
2222+
# calculate the locations of the radius points
2223+
x = -0.5 * t - r + r * np.cos(theta)
2224+
y = -0.5 * t - r + r * np.sin(theta)
22132225

2214-
# append the current points to the points list
2215-
self.points.append([x, y])
2226+
# append the current points to the points list
2227+
self.points.append([x, y])
22162228

22172229
# build the facet list
22182230
for i in range(len(self.points)):

0 commit comments

Comments
 (0)