I've been using FreeCAD (freecad-daily) since a couple of weeks, so I'm pretty new to everything. My OS: Ubuntu 18.04. My machine: Dual 18 core Xeon Gold 6254 proc, 96 GB RAM.
I actually have an issue with a fairly I would say standard task. I have a solid body which is created via the Part workbench and now should be meshed by GMSH within FreeCAD. Let's call the body "Heart". My meshing code looks like this and works fine:
Code: Select all
# meshing
femmesh_obj_gmsh = ObjectsFem.makeMeshGmsh(doc, 'MyGMSHMeshObj')
femmesh_obj_gmsh.Part = doc.Heart
doc.recompute()
# mesh settings
#femmesh_obj_gmsh.Algorithm3D = 7 # not working... TODO: how to change element type?
femmesh_obj_gmsh.ElementOrder = 0
femmesh_obj_gmsh.CharacteristicLengthMax = max_edge_length
femmesh_obj_gmsh.CharacteristicLengthMin = min_edge_length
gmsh_mesh = femmesh.gmshtools.GmshTools(femmesh_obj_gmsh)
error = gmsh_mesh.create_mesh()
print(error)
doc.recompute()
# get FEM mesh
femmesh = doc.MyGMSHMeshObj.FemMesh
# some mesh info...
num_nodes = femmesh.NodeCount
nodedict = femmesh.Nodes
num_elements = femmesh.VolumeCount
elements = femmesh.Volumes
faceelements = femmesh.Faces
edgeelements = femmesh.Edges
# mesh info for output
nodes_per_el_vol = len(femmesh.getElementNodes(elements[0]))
nodes_per_el_surf = len(femmesh.getElementNodes(faceelements[0]))
nodes_per_el_line = len(femmesh.getElementNodes(edgeelements[0]))
Code: Select all
ff = doc.Heart.Shape.Faces[0]
To get the face elements of ff, I use
Code: Select all
fele = femmesh.getFacesByFace(ff)
It perfectly works for a coarse mesh, but a very fine one - no way. :-/
Does anyone know an alternative command to this? One which can be called via script (without the GUI, so with freecadcmd-daily)? I want to hold my own Python array with a collection of these surface faces since I have my own writing routines for a FEM program.
Would be great if someone had some experience here!
Thanks!
Best,
Marc