From 1e5c0fcef791efb7f1a5685c4c5d306e052271cb Mon Sep 17 00:00:00 2001 From: Uwe Date: Tue, 13 Apr 2021 07:32:44 +0200 Subject: [PATCH] [FEM] add support for 3D recombinations (#4706) * [FEM] add support for 3D recombinations currently we only support surface recombinations but for some applications 3D recombinations are useful as well * add support for the recombination algorithms using a sensible algorithm is important to get useful results, see https://wiki.freecadweb.org/FEM_MeshGmshFromShape#Properties where I described examples --- src/Mod/Fem/femmesh/gmshtools.py | 22 +++++++++++++++++++++- src/Mod/Fem/femobjects/mesh_gmsh.py | 27 ++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/Mod/Fem/femmesh/gmshtools.py b/src/Mod/Fem/femmesh/gmshtools.py index 801104de94fe..d77260b4cfa8 100644 --- a/src/Mod/Fem/femmesh/gmshtools.py +++ b/src/Mod/Fem/femmesh/gmshtools.py @@ -125,6 +125,19 @@ def __init__(self, gmsh_mesh_obj, analysis=None): else: self.algorithm3D = "1" + # RecombinationAlgorithm + algoRecombo = self.mesh_obj.RecombinationAlgorithm + if algoRecombo == "Simple": + self.RecombinationAlgorithm = "0" + elif algoRecombo == "Blossom": + self.RecombinationAlgorithm = "1" + elif algoRecombo == "Simple full-quad": + self.RecombinationAlgorithm = "2" + elif algoRecombo == "Blossom full-quad": + self.RecombinationAlgorithm = "3" + else: + self.algoRecombo = "0" + # HighOrderOptimize optimizers = self.mesh_obj.HighOrderOptimize if optimizers == "None": @@ -766,8 +779,15 @@ def write_geo(self): ) geo.write("\n") if hasattr(self.mesh_obj, "RecombineAll") and self.mesh_obj.RecombineAll is True: - geo.write("// other mesh options\n") + geo.write("// recombination for surfaces\n") geo.write("Mesh.RecombineAll = 1;\n") + if hasattr(self.mesh_obj, "Recombine3DAll") and self.mesh_obj.Recombine3DAll is True: + geo.write("// recombination for volumes\n") + geo.write("Mesh.Recombine3DAll = 1;\n") + if ( (hasattr(self.mesh_obj, "RecombineAll") and self.mesh_obj.RecombineAll is True) + or (hasattr(self.mesh_obj, "Recombine3DAll") and self.mesh_obj.Recombine3DAll is True)): + geo.write("// recombination algorithm\n") + geo.write("Mesh.RecombinationAlgorithm = " + self.RecombinationAlgorithm + ";\n") geo.write("\n") geo.write("// optimize the mesh\n") diff --git a/src/Mod/Fem/femobjects/mesh_gmsh.py b/src/Mod/Fem/femobjects/mesh_gmsh.py index cc1167a0b89d..9feeef7737a3 100644 --- a/src/Mod/Fem/femobjects/mesh_gmsh.py +++ b/src/Mod/Fem/femobjects/mesh_gmsh.py @@ -60,6 +60,12 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): "R-tree", "HXT" ] + known_mesh_RecombinationAlgorithms = [ + "Simple", + "Blossom", + "Simple full-quad", + "Blossom full-quad" + ] known_mesh_HighOrderOptimizers = [ "None", "Optimization", @@ -169,7 +175,7 @@ def add_properties(self, obj): "App::PropertyBool", "OptimizeStd", "FEM Gmsh Mesh Params", - "Optimize tetra elements" + "Optimize tetrahedral elements" ) obj.OptimizeStd = True @@ -201,6 +207,25 @@ def add_properties(self, obj): ) obj.RecombineAll = False + if not hasattr(obj, "Recombine3DAll"): + obj.addProperty( + "App::PropertyBool", + "Recombine3DAll", + "FEM Gmsh Mesh Params", + "Apply recombination algorithm to all volumes" + ) + obj.Recombine3DAll = False + + if not hasattr(obj, "RecombinationAlgorithm"): + obj.addProperty( + "App::PropertyEnumeration", + "RecombinationAlgorithm", + "FEM Gmsh Mesh Params", + "Recombination algorithm" + ) + obj.RecombinationAlgorithm = MeshGmsh.known_mesh_RecombinationAlgorithms + obj.RecombinationAlgorithm = "Simple" + if not hasattr(obj, "CoherenceMesh"): obj.addProperty( "App::PropertyBool",