Skip to content

Commit 900b3f4

Browse files
Merge pull request #341 from robbievanleeuwen/stress-minor-fix
`Section.calculate_stress()` fixes - suppress numba performance warning, fix time info stuck at 0%
2 parents 2ff1580 + e9924d9 commit 900b3f4

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/sectionproperties/analysis/fea.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
from __future__ import annotations
99

10+
import warnings
1011
from dataclasses import dataclass, field
1112
from functools import lru_cache
1213
from typing import TYPE_CHECKING
1314

1415
import numpy as np
1516
from numba import njit
17+
from numba.core.errors import NumbaPerformanceWarning
1618

1719

1820
if TYPE_CHECKING:
@@ -632,17 +634,19 @@ def element_stress(
632634
* (b.dot(phi_shear) - nu / 2 * np.array([h1, h2]))
633635
)
634636

635-
# extrapolate results to nodes
636-
sig_zz_mxx = extrapolate_to_nodes(w=sig_zz_mxx_gp)
637-
sig_zz_myy = extrapolate_to_nodes(w=sig_zz_myy_gp)
638-
sig_zz_m11 = extrapolate_to_nodes(w=sig_zz_m11_gp)
639-
sig_zz_m22 = extrapolate_to_nodes(w=sig_zz_m22_gp)
640-
sig_zx_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 0])
641-
sig_zy_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 1])
642-
sig_zx_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 0])
643-
sig_zy_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 1])
644-
sig_zx_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 0])
645-
sig_zy_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 1])
637+
# extrapolate results to nodes, ignore numba warnings about performance
638+
with warnings.catch_warnings():
639+
warnings.simplefilter("ignore", category=NumbaPerformanceWarning)
640+
sig_zz_mxx = extrapolate_to_nodes(w=sig_zz_mxx_gp)
641+
sig_zz_myy = extrapolate_to_nodes(w=sig_zz_myy_gp)
642+
sig_zz_m11 = extrapolate_to_nodes(w=sig_zz_m11_gp)
643+
sig_zz_m22 = extrapolate_to_nodes(w=sig_zz_m22_gp)
644+
sig_zx_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 0])
645+
sig_zy_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 1])
646+
sig_zx_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 0])
647+
sig_zy_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 1])
648+
sig_zx_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 0])
649+
sig_zy_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 1])
646650

647651
return (
648652
sig_zz_n,

src/sectionproperties/analysis/section.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ def calc_stress(progress: Progress | None = None) -> sp_stress_post.StressPost:
13341334
# add nodal weights
13351335
nodal_weights[el.node_ids] += weights
13361336

1337-
if progress and task:
1337+
if progress and task is not None:
13381338
progress.update(task_id=task, advance=1)
13391339

13401340
# nodal averaging
@@ -1355,7 +1355,7 @@ def calc_stress(progress: Progress | None = None) -> sp_stress_post.StressPost:
13551355
# calculate combined stresses
13561356
sr.calculate_combined_stresses()
13571357

1358-
if progress and task:
1358+
if progress and task is not None:
13591359
msg = "[bold green]:white_check_mark: Stress analysis complete"
13601360
progress.update(task_id=task, description=msg)
13611361

0 commit comments

Comments
 (0)