Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section.calculate_stress() fixes - suppress numba performance warning, fix time info stuck at 0% #341

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/sectionproperties/analysis/fea.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/sectionproperties/analysis/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
Loading