From 73e2a1ba8b4ececd02b926be2fe42469b100ca70 Mon Sep 17 00:00:00 2001
From: Romain Boman <r.boman@uliege.be>
Date: Wed, 8 Nov 2023 14:21:34 +0100
Subject: [PATCH] add mean stress calculation script

---
 mean_stress.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 mean_stress.py

diff --git a/mean_stress.py b/mean_stress.py
new file mode 100644
index 0000000..516ec54
--- /dev/null
+++ b/mean_stress.py
@@ -0,0 +1,29 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# extract min, max mean stress from results
+# (run this script in the workspace folder)
+
+import gmsh
+import numpy as np
+
+gmsh.initialize()
+gmsh.merge('mesh.msh')
+gmsh.merge('smooth_stress_tensor.msh')
+
+dataType, tags, data, time, numComp = gmsh.view.getModelData(1, 0)
+
+
+# compute sigma Von Mises from nodal sig tensor
+# https://help.autodesk.com/view/fusion360/FRA/?guid=VON-MISES-STRESS-EQ-CONCEPT
+svms = []
+for sig in data:
+    [xx, xy, xz, yx, yy, yz, zx, zy, zz] = sig
+    svm = np.sqrt( ((xx-yy)**2 + (yy-zz)**2 + (zz-xx)**2 )/2 + 3*(xy*xy+yz*yz+zx*zx) )
+    svms.append(svm)
+
+svms = np.array(svms)
+
+print(f'svm_min = {np.min(svms)}')
+print(f'svm_max = {np.max(svms)}')
+print(f'svm_mean = {np.mean(svms)}')
-- 
GitLab