From e9924d9726991f222b4fdae3c22a75e256718fbb Mon Sep 17 00:00:00 2001 From: robbievanleeuwen Date: Thu, 12 Oct 2023 21:55:54 +1100 Subject: [PATCH] Suppress numba performance warning, fix calculate_stress time info --- src/sectionproperties/analysis/fea.py | 26 +++++++++++++---------- src/sectionproperties/analysis/section.py | 4 ++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/sectionproperties/analysis/fea.py b/src/sectionproperties/analysis/fea.py index 6ed15f63..996bce25 100644 --- a/src/sectionproperties/analysis/fea.py +++ b/src/sectionproperties/analysis/fea.py @@ -7,12 +7,14 @@ from __future__ import annotations +import warnings from dataclasses import dataclass, field from functools import lru_cache from typing import TYPE_CHECKING import numpy as np from numba import njit +from numba.core.errors import NumbaPerformanceWarning if TYPE_CHECKING: @@ -632,17 +634,19 @@ def element_stress( * (b.dot(phi_shear) - nu / 2 * np.array([h1, h2])) ) - # extrapolate results to nodes - sig_zz_mxx = extrapolate_to_nodes(w=sig_zz_mxx_gp) - sig_zz_myy = extrapolate_to_nodes(w=sig_zz_myy_gp) - sig_zz_m11 = extrapolate_to_nodes(w=sig_zz_m11_gp) - sig_zz_m22 = extrapolate_to_nodes(w=sig_zz_m22_gp) - sig_zx_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 0]) - sig_zy_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 1]) - sig_zx_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 0]) - sig_zy_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 1]) - sig_zx_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 0]) - sig_zy_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 1]) + # extrapolate results to nodes, ignore numba warnings about performance + with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=NumbaPerformanceWarning) + sig_zz_mxx = extrapolate_to_nodes(w=sig_zz_mxx_gp) + sig_zz_myy = extrapolate_to_nodes(w=sig_zz_myy_gp) + sig_zz_m11 = extrapolate_to_nodes(w=sig_zz_m11_gp) + sig_zz_m22 = extrapolate_to_nodes(w=sig_zz_m22_gp) + sig_zx_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 0]) + sig_zy_mzz = extrapolate_to_nodes(w=sig_zxy_mzz_gp[:, 1]) + sig_zx_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 0]) + sig_zy_vx = extrapolate_to_nodes(w=sig_zxy_vx_gp[:, 1]) + sig_zx_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 0]) + sig_zy_vy = extrapolate_to_nodes(w=sig_zxy_vy_gp[:, 1]) return ( sig_zz_n, diff --git a/src/sectionproperties/analysis/section.py b/src/sectionproperties/analysis/section.py index 80d75959..3df24d75 100644 --- a/src/sectionproperties/analysis/section.py +++ b/src/sectionproperties/analysis/section.py @@ -1334,7 +1334,7 @@ def calc_stress(progress: Progress | None = None) -> sp_stress_post.StressPost: # add nodal weights nodal_weights[el.node_ids] += weights - if progress and task: + if progress and task is not None: progress.update(task_id=task, advance=1) # nodal averaging @@ -1355,7 +1355,7 @@ def calc_stress(progress: Progress | None = None) -> sp_stress_post.StressPost: # calculate combined stresses sr.calculate_combined_stresses() - if progress and task: + if progress and task is not None: msg = "[bold green]:white_check_mark: Stress analysis complete" progress.update(task_id=task, description=msg)