Skip to content

Commit

Permalink
[FEM] add support for 3D recombinations (#4706)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
donovaly committed Apr 13, 2021
1 parent d4e0160 commit 1e5c0fc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/Mod/Fem/femmesh/gmshtools.py
Expand Up @@ -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":
Expand Down Expand Up @@ -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")
Expand Down
27 changes: 26 additions & 1 deletion src/Mod/Fem/femobjects/mesh_gmsh.py
Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 1e5c0fc

Please sign in to comment.