From c3da895a1fbbd0888be464065b4dd79cc366903d Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Tue, 7 Jul 2020 12:31:35 +0200 Subject: [PATCH] FEM: elmer writer, equation elasticity, only write needed material values --- src/Mod/Fem/femexamples/boxanalysis_static.py | 4 ---- .../femexamples/ccx_cantilever_faceload.py | 3 --- src/Mod/Fem/femsolver/elmer/writer.py | 19 +++++++++++-------- src/Mod/Fem/femtest/app/test_solver_elmer.py | 1 - .../Fem/femtest/data/elmer/box_static_mm.sif | 2 -- .../data/elmer/ccxcantilever_faceload_mm.sif | 2 -- .../data/elmer/ccxcantilever_nodeload_mm.sif | 2 -- ...cxcantilever_prescribeddisplacement_mm.sif | 2 -- 8 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/Mod/Fem/femexamples/boxanalysis_static.py b/src/Mod/Fem/femexamples/boxanalysis_static.py index 2fef33ab73..40a28deb9d 100644 --- a/src/Mod/Fem/femexamples/boxanalysis_static.py +++ b/src/Mod/Fem/femexamples/boxanalysis_static.py @@ -82,10 +82,6 @@ def setup_base(doc=None, solvertype="ccxtools"): mat["YoungsModulus"] = "200000 MPa" mat["PoissonRatio"] = "0.30" mat["Density"] = "7900 kg/m^3" - if solvertype == "elmer": - # set ThermalExpansionCoefficient - # FIXME elmer elasticity needs the dictionary key "ThermalExpansionCoefficient" - mat["ThermalExpansionCoefficient"] = "0.012 mm/m/K" material_object.Material = mat # mesh diff --git a/src/Mod/Fem/femexamples/ccx_cantilever_faceload.py b/src/Mod/Fem/femexamples/ccx_cantilever_faceload.py index 634570d477..280763fc67 100644 --- a/src/Mod/Fem/femexamples/ccx_cantilever_faceload.py +++ b/src/Mod/Fem/femexamples/ccx_cantilever_faceload.py @@ -109,9 +109,6 @@ def setup_cantileverbase(doc=None, solvertype="ccxtools"): mat["YoungsModulus"] = "210000 MPa" mat["PoissonRatio"] = "0.30" mat["Density"] = "7900 kg/m^3" - if solvertype == "elmer": - # set ThermalExpansionCoefficient, elmer elasticity needs it FIXME - mat["ThermalExpansionCoefficient"] = "0.012 mm/m/K" material_object.Material = mat # fixed_constraint diff --git a/src/Mod/Fem/femsolver/elmer/writer.py b/src/Mod/Fem/femsolver/elmer/writer.py index 0e3f4f6586..58991d3c4a 100644 --- a/src/Mod/Fem/femsolver/elmer/writer.py +++ b/src/Mod/Fem/femsolver/elmer/writer.py @@ -598,6 +598,7 @@ class Writer(object): return None def _handleElasticityMaterial(self, bodies): + gravObj = self._getSingleMember("Fem::ConstraintSelfWeight") tempObj = self._getSingleMember("Fem::ConstraintInitialTemperature") if tempObj is not None: refTemp = getFromUi(tempObj.initialTemperature, "K", "O") @@ -611,10 +612,11 @@ class Writer(object): else self._getAllBodies() ) for name in (n for n in refs if n in bodies): - self._material( - name, "Density", - self._getDensity(m) - ) + if gravObj: + self._material( + name, "Density", + self._getDensity(m) + ) self._material( name, "Youngs Modulus", self._getYoungsModulus(m) @@ -623,10 +625,11 @@ class Writer(object): name, "Poisson ratio", float(m["PoissonRatio"]) ) - self._material( - name, "Heat expansion Coefficient", - convert(m["ThermalExpansionCoefficient"], "O^-1") - ) + if tempObj: + self._material( + name, "Heat expansion Coefficient", + convert(m["ThermalExpansionCoefficient"], "O^-1") + ) def _getDensity(self, m): density = convert(m["Density"], "M/L^3") diff --git a/src/Mod/Fem/femtest/app/test_solver_elmer.py b/src/Mod/Fem/femtest/app/test_solver_elmer.py index 27c1435717..8437288435 100644 --- a/src/Mod/Fem/femtest/app/test_solver_elmer.py +++ b/src/Mod/Fem/femtest/app/test_solver_elmer.py @@ -105,7 +105,6 @@ class TestSolverElmer(unittest.TestCase): # elmer needs gmsh mesho object # FIXME error message on Python solver run # the examples do use a gmsh mesh object thus ok - # FIXME elmer elasticity needs the dict key "ThermalExpansionCoefficient" in material base_name = get_namefromdef("test_") analysis_dir = testtools.get_fem_test_tmp_dir(self.pre_dir_name + base_name) diff --git a/src/Mod/Fem/femtest/data/elmer/box_static_mm.sif b/src/Mod/Fem/femtest/data/elmer/box_static_mm.sif index d886180ce8..0e4feab9b3 100644 --- a/src/Mod/Fem/femtest/data/elmer/box_static_mm.sif +++ b/src/Mod/Fem/femtest/data/elmer/box_static_mm.sif @@ -53,8 +53,6 @@ Body 1 End Material 1 - Density = Real 7.9e-06 - Heat expansion Coefficient = Real 1.2e-05 Poisson ratio = Real 0.3 Youngs Modulus = Real 200000000.0 End diff --git a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_mm.sif b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_mm.sif index 26a17d558f..a9f28364b4 100644 --- a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_mm.sif +++ b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_faceload_mm.sif @@ -53,8 +53,6 @@ Body 1 End Material 1 - Density = Real 7.9e-06 - Heat expansion Coefficient = Real 1.2e-05 Poisson ratio = Real 0.3 Youngs Modulus = Real 210000000.0 End diff --git a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_mm.sif b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_mm.sif index c8eeb53374..6221ca7fb0 100644 --- a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_mm.sif +++ b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_nodeload_mm.sif @@ -53,8 +53,6 @@ Body 1 End Material 1 - Density = Real 7.9e-06 - Heat expansion Coefficient = Real 1.2e-05 Poisson ratio = Real 0.3 Youngs Modulus = Real 210000000.0 End diff --git a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_mm.sif b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_mm.sif index ee2711437a..fab6d80689 100644 --- a/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_mm.sif +++ b/src/Mod/Fem/femtest/data/elmer/ccxcantilever_prescribeddisplacement_mm.sif @@ -53,8 +53,6 @@ Body 1 End Material 1 - Density = Real 7.9e-06 - Heat expansion Coefficient = Real 1.2e-05 Poisson ratio = Real 0.3 Youngs Modulus = Real 210000000.0 End