2121
2222big_sq = rectangular_section (d = 300 , b = 250 )
2323small_sq = rectangular_section (d = 100 , b = 75 )
24- small_hole = rectangular_section (d = 40 , b = 30 )
24+ small_hole = rectangular_section (d = 40 , b = 30 ). align_center ( small_sq )
2525i_sec = i_section (d = 200 , b = 100 , t_f = 20 , t_w = 10 , r = 12 , n_r = 12 )
26-
27- small_sq = small_sq - small_hole .align_center (small_sq )
26+ small_sq_w_hole = small_sq - small_hole
2827composite = (
2928 big_sq
30- + small_sq .align_to (big_sq , on = "top" , inner = True ).align_to (big_sq , on = "top" )
29+ + small_sq_w_hole .align_to (big_sq , on = "top" , inner = True ).align_to (big_sq , on = "top" )
3130 + i_sec .align_to (big_sq , on = "bottom" , inner = True ).align_to (big_sq , on = "right" )
3231)
33- composite .compile_geometry ()
3432composite .create_mesh ([200 ])
3533comp_sec = Section (composite )
3634comp_sec .calculate_geometric_properties ()
3735comp_sec .calculate_plastic_properties ()
3836
37+ # Subtractive modelling
38+ nested_geom = (small_sq - small_hole ) + small_hole
39+ nested_geom .create_mesh ([50 ])
40+ nested_sec = Section (nested_geom )
41+
42+ # Overlapped modelling
43+ overlay_geom = small_sq + small_hole
44+ overlay_geom .create_mesh ([50 ])
45+ overlay_sec = Section (overlay_geom )
46+
3947
4048def test_material_persistence ():
4149 # Test ensures that the material attribute gets transformed
@@ -61,6 +69,7 @@ def test_for_incidental_holes():
6169 # a I Section up against a rectangle.
6270 # There should be two holes created after .compile_geometry()
6371 assert len (composite .holes ) == 2
72+ assert len (nested_geom .holes ) == 0
6473
6574
6675def test_geometry_from_points ():
@@ -138,10 +147,13 @@ def test_compound_geometry_from_points():
138147 assert (new_geom .geom - wkt_test_geom ) == Polygon ()
139148
140149
141- def test_nested_compound_geometry_from_points ():
150+ def test_multinested_compound_geometry_from_points ():
142151 """
143- Tests a nested compound geometry can be built .from_points, that the control_points
144- and hole nodes persist in the right locations, and that ...
152+ Testing a multi-nested section. This section contains three nested materials in concentric
153+ square rings with a hole going through the center of the whole section. This test confirms
154+ that the section can be successfully built using .from_points, that the control_points
155+ and hole nodes persist in the right locations, and that the plastic section calculation
156+ raises a warning because the nested regions overlap.
145157 """
146158 points = [
147159 [- 50.0 , 50.0 ],
@@ -196,6 +208,15 @@ def test_nested_compound_geometry_from_points():
196208 ]
197209 assert nested_compound .holes == [(0 , 0 ), (0 , 0 ), (0 , 0 )]
198210
211+ # Section contains overlapping geometries which will result in potentially incorrect
212+ # plastic properties calculation (depends on user intent and geometry).
213+ # Test to ensure a warning is raised about this to notify the user.
214+ nested_compound .create_mesh ([25 , 30 , 35 ])
215+ nested_compound_sec = Section (nested_compound )
216+ nested_compound_sec .calculate_geometric_properties ()
217+ with pytest .warns (UserWarning ):
218+ nested_compound_sec .calculate_plastic_properties ()
219+
199220
200221def test_geometry_from_dxf ():
201222 section_holes_dxf = (
@@ -251,10 +272,25 @@ def test_plastic_centroid():
251272 section .calculate_geometric_properties ()
252273 section .calculate_plastic_properties ()
253274
275+ # Checking sections that were defined above
276+ #
277+ nested_sec .calculate_geometric_properties ()
278+ nested_sec .calculate_plastic_properties ()
279+ overlay_sec .calculate_geometric_properties ()
280+
281+ with pytest .warns (UserWarning ):
282+ overlay_sec .calculate_plastic_properties ()
283+
284+ # section
254285 x_pc , y_pc = section .get_pc ()
255286 assert x_pc == pytest .approx (82.5 )
256287 assert y_pc == pytest .approx (250.360654576 )
257288
289+ # nested_sec
290+ x_pc , y_pc = nested_sec .get_pc ()
291+ assert x_pc == pytest .approx (37.5 )
292+ assert y_pc == pytest .approx (50 )
293+
258294
259295def test_geometry_from_3dm_file_simple ():
260296 section = pathlib .Path .cwd () / "sectionproperties" / "tests" / "3in x 2in.3dm"
0 commit comments