Skip to content

Commit 2f4f5b6

Browse files
committed
Added mesh plotting
1 parent d77f744 commit 2f4f5b6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

examples/01-advanced/05_trapz_approximation.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@
4141
# is straightforward enough. `geom` is the Section Property Gemoetry object;
4242
# `ms` is the mesh size. The "cgs" solver helps avoid singular matrices due
4343
# to small angles.
44-
def get_section_j(geom, ms):
44+
def get_section_j(geom, ms, plot_geom=False):
4545
geom.create_mesh(mesh_sizes=[ms])
4646
section = Section(geom)
47+
if plot_geom:
48+
section.plot_mesh()
4749
section.calculate_geometric_properties()
4850
section.calculate_warping_properties(solver_type="cgs")
4951
return section.get_j()
@@ -54,7 +56,7 @@ def get_section_j(geom, ms):
5456
# =======================
5557
# The number of elements per unit area is an important input to the calculations
5658
# even though we are only examining ratios of the results. A nominal value of 100
57-
# is reasonable.
59+
# is reasonable; but sovler errors occur sometimes, so use 110.
5860
n = 110 # mesh density
5961

6062
#%%
@@ -65,7 +67,7 @@ def get_section_j(geom, ms):
6567
# immaterial. There are a few ways to parametrize the problem, but it has been
6668
# found that setting the middle height of trapezoid (i.e. the average height)
6769
# to a unit value works fine.
68-
def do_section(b, S, d_mid=1):
70+
def do_section(b, S, d_mid=1, plot_geom=False):
6971
delta = S * d_mid
7072
d1 = d_mid - delta
7173
d2 = d_mid + delta
@@ -82,10 +84,10 @@ def do_section(b, S, d_mid=1):
8284
trap_geom = geometry.Geometry(Polygon(points))
8385
else:
8486
trap_geom = sections.triangular_section(h=d2, b=b)
85-
jt = get_section_j(trap_geom, ms)
87+
jt = get_section_j(trap_geom, ms, plot_geom)
8688

8789
rect_geom = sections.rectangular_section(d=(d1 + d2) / 2, b=b)
88-
jr = get_section_j(rect_geom, ms)
90+
jr = get_section_j(rect_geom, ms, plot_geom)
8991
return jt, jr, d1, d2
9092

9193

0 commit comments

Comments
 (0)