View Revisions: Issue #2873

Summary 0002873: FEM, mesh, unv writer, do not renumbering on file writing
Revision 2019-01-16 20:07 by berndhahnebach
Description If an unv consists FEM elements with element numbering not starting with 1 the unv reader reads them and renumbers the starting with one. Since FreeCAD FEM uses unv to read and write FEM meshes inside the fcstd format the FEM mesh will be changed during save and load of a FreeCAD FEM mesh. The bug seams in smesh. See forum post http://forum.freecadweb.org/viewtopic.php?f=18&t=18982&start=10#p148711

to reproduce use the following python code to create one tetra4 element with element number 88 and reload it. After reading it has element number 1. If the unv is opened in GMSH the element has number 88.

# 4 node tetrahedron --> tetra4
import Fem
tetra4 = Fem.FemMesh()
tetra4.addNode( 6, 12, 18, 1)
tetra4.addNode( 0, 0, 18, 2)
tetra4.addNode(12, 0, 18, 3)
tetra4.addNode( 6, 6, 0, 4)

tetra4.addVolume([1, 2, 3, 4], 88)
tetra4.Volumes

mesh_file = u"/tmp/femmesh.unv"
tetra4.write(mesh_file)
mesh = Fem.read(mesh_file)
mesh.Volumes


EDIT: Python code to reproduse ths node gap problem on a 2D analysis, tested on FreeCAD 0.18.15644:

# load 2D example file and set 3D output in solver
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever2D.FCStd')

doc.FEMMeshGmsh.ViewObject.Visibility = False
doc.CalculiXccxTools.BeamShellResultOutput3D = True
doc.recompute()
# run the analysis
import FemGui
FemGui.setActiveAnalysis(doc.Analysis)
from femtools import ccxtools
fea = ccxtools.FemToolsCcx()
fea.update_objects()
fea.purge_results()
fea.run()

# node keys
doc.Result_mesh.FemMesh.Nodes.keys()  # starts with 178

# save and reload the file
save_name = u"/home/hugo/Desktop/nodegapstest.FCStd"
doc.saveAs(save_name)
FreeCAD.closeDocument(doc.Name)
doc2 = FreeCAD.open(save_name)

# node keys
doc2.Result_mesh.FemMesh.Nodes.keys()  # starts with 1


Revision 2019-01-16 20:05 by berndhahnebach
Description If an unv consists FEM elements with element numbering not starting with 1 the unv reader reads them and renumbers the starting with one. Since FreeCAD FEM uses unv to read and write FEM meshes inside the fcstd format the FEM mesh will be changed during save and load of a FreeCAD FEM mesh. The bug seams in smesh. See forum post http://forum.freecadweb.org/viewtopic.php?f=18&t=18982&start=10#p148711

to reproduce use the following python code to create one tetra4 element with element number 88 and reload it. After reading it has element number 1. If the unv is opened in GMSH the element has number 88.

# 4 node tetrahedron --> tetra4
import Fem
tetra4 = Fem.FemMesh()
tetra4.addNode( 6, 12, 18, 1)
tetra4.addNode( 0, 0, 18, 2)
tetra4.addNode(12, 0, 18, 3)
tetra4.addNode( 6, 6, 0, 4)

tetra4.addVolume([1, 2, 3, 4], 88)
tetra4.Volumes

mesh_file = u"/tmp/femmesh.unv"
tetra4.write(mesh_file)
mesh = Fem.read(mesh_file)
mesh.Volumes


EDIT: Python code to reproduse ths node gap problem on a 2D analysis ...

# load 2D example file and set 3D output in solver
doc = FreeCAD.open(FreeCAD.ConfigGet("AppHomePath") + 'data/examples/FemCalculixCantilever2D.FCStd')

doc.FEMMeshGmsh.ViewObject.Visibility = False
doc.CalculiXccxTools.BeamShellResultOutput3D = True
doc.recompute()
# run the analysis
import FemGui
FemGui.setActiveAnalysis(doc.Analysis)
from femtools import ccxtools
fea = ccxtools.FemToolsCcx()
fea.update_objects()
fea.purge_results()
fea.run()

# node keys
doc.Result_mesh.FemMesh.Nodes.keys()  # starts with 178

# save and reload the file
save_name = u"/home/hugo/Desktop/nodegapstest.FCStd"
doc.saveAs(save_name)
FreeCAD.closeDocument(doc.Name)
doc2 = FreeCAD.open(save_name)

# node keys
doc2.Result_mesh.FemMesh.Nodes.keys()  # starts with 1


Revision 2017-01-24 16:54 by berndhahnebach
Description If an unv consists FEM elements with element numbering not starting with 1 the unv reader reads them and renumbers the starting with one. Since FreeCAD FEM uses unv to read and write FEM meshes inside the fcstd format the FEM mesh will be changed during save and load of a FreeCAD FEM mesh. The bug seams in smesh. See forum post http://forum.freecadweb.org/viewtopic.php?f=18&t=18982&start=10#p148711

to reproduce use the following python code to create one tetra4 element with element number 88 and reload it. After reading it has element number 1. If the unv is opened in GMSH the element has number 88.

# 4 node tetrahedron --> tetra4
import Fem
tetra4 = Fem.FemMesh()
tetra4.addNode( 6, 12, 18, 1)
tetra4.addNode( 0, 0, 18, 2)
tetra4.addNode(12, 0, 18, 3)
tetra4.addNode( 6, 6, 0, 4)

tetra4.addVolume([1, 2, 3, 4], 88)
tetra4.Volumes

mesh_file = u"/tmp/femmesh.unv"
tetra4.write(mesh_file)
mesh = Fem.read(mesh_file)
mesh.Volumes