Skip to content

Commit fa9d527

Browse files
committed
Fem: Add partial support for hexahedral elements - fixes FreeCAD#5698
1 parent 6c8ee59 commit fa9d527

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/Mod/Fem/femmesh/gmshtools.py

+20
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ def __init__(self, gmsh_mesh_obj, analysis=None):
151151
else:
152152
self.HighOrderOptimize = "0"
153153

154+
# SubdivisionAlgorithm
155+
algoSubdiv = self.mesh_obj.SubdivisionAlgorithm
156+
if algoSubdiv == "All Quadrangles":
157+
self.SubdivisionAlgorithm = "1"
158+
elif algoSubdiv == "All Hexahedra":
159+
self.SubdivisionAlgorithm = "2"
160+
elif algoSubdiv == "Barycentric":
161+
self.SubdivisionAlgorithm = "3"
162+
else:
163+
self.SubdivisionAlgorithm = "0"
164+
154165
# mesh groups
155166
if self.mesh_obj.GroupsOfNodes is True:
156167
self.group_nodes_export = True
@@ -858,6 +869,15 @@ def write_geo(self):
858869
geo.write("Mesh.Algorithm3D = " + self.algorithm3D + ";\n")
859870
geo.write("\n")
860871

872+
geo.write("// subdivision algorithm\n")
873+
geo.write("Mesh.SubdivisionAlgorithm = " + self.SubdivisionAlgorithm + ";\n")
874+
geo.write("\n")
875+
876+
geo.write("// incomplete second order elements\n")
877+
sec_order_inc = "1" if self.mesh_obj.SecondOrderIncomplete else "0"
878+
geo.write("Mesh.SecondOrderIncomplete = " + sec_order_inc + ";\n")
879+
geo.write("\n")
880+
861881
geo.write("// meshing\n")
862882
# remove duplicate vertices
863883
# see https://forum.freecad.org/viewtopic.php?f=18&t=21571&start=20#p179443

src/Mod/Fem/femobjects/mesh_gmsh.py

+25
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject):
7373
"Elastic",
7474
"Fast curving"
7575
]
76+
known_mesh_SubdivisionAlgorithms = [
77+
"None",
78+
"All Quadrangles",
79+
"All Hexahedra",
80+
"Barycentric"
81+
]
7682

7783
def __init__(self, obj):
7884
super(MeshGmsh, self).__init__(obj)
@@ -305,3 +311,22 @@ def add_properties(self, obj):
305311
"For each group create not only the elements but the nodes too."
306312
)
307313
obj.GroupsOfNodes = False
314+
315+
if not hasattr(obj, "SubdivisionAlgorithm"):
316+
obj.addProperty(
317+
"App::PropertyEnumeration",
318+
"SubdivisionAlgorithm",
319+
"FEM Gmsh Mesh Params",
320+
"Mesh subdivision algorithm"
321+
)
322+
obj.SubdivisionAlgorithm = MeshGmsh.known_mesh_SubdivisionAlgorithms
323+
obj.SubdivisionAlgorithm = "None"
324+
325+
if not hasattr(obj, "SecondOrderIncomplete"):
326+
obj.addProperty(
327+
"App::PropertyBool",
328+
"SecondOrderIncomplete",
329+
"FEM Gmsh Mesh Params",
330+
"Create incomplete second order elements"
331+
)
332+
obj.SecondOrderIncomplete = False

0 commit comments

Comments
 (0)