Problem during AMSH export with cfdmsh 1.0.0
Hello everybody,
I had feedback about a problem that can happen when exporting meshes in Edge format using the ExportAmshFile function of the cfdmsh library v1.0.0. When the mesh is generated manually (eg. extruded from 1D to 2D or from 2D to 3D), or is a copy/fusion of other mesh(es), the export can stop with such error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/tougeron/Desktop/file711/cfdmsh.py", line 1683, in ExportAmshFile
meshDimension=mesh.MeshDimension()
File "/opt/salome/salome_6.6.0/SMESH_6.6.0/bin/salome/smeshDC.py", line 1102, in MeshDimension
shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
File "/opt/salome/salome_6.6.0/GEOM_6.6.0/bin/salome/geompyDC.py", line 4218, in SubShapeAllIDs
RaiseIfFailed("SubShapeAllIDs", self.ShapesOp)
File "/opt/salome/salome_6.6.0/GEOM_6.6.0/bin/salome/geompyDC.py", line 102, in RaiseIfFailed
raise RuntimeError, Method_name + " : " + Operation.GetErrorCode()
RuntimeError: SubShapeAllIDs :
Or:
Writing node coordinates... (176 nodes)
Writing definition of group elements...
Writing definition of domain elements...
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/tougeron/Desktop/file711/cfdmsh.py", line 2079, in ExportAmshFile
for elementIDInDomain in elementIDsInDomain:
UnboundLocalError: local variable 'elementIDsInDomain' referenced before assignment
This is because cfdmsh uses the function MeshDimension() of Salome to get the dimension of the mesh, but this function seems to return the dimension of used algorithms/hypotheses only.
One solution is to detect the presence of 3D elements in the mesh to get its dimension.
Here is a way to proceed:
- 1 - In the cfdmsh.py file, delete the following code starting at the line 1681 (underscore caracters represent tabulation):
_ # Get mesh dimension
_ meshDimension=mesh.MeshDimension()
_ #-
- 2 - Just before the "# Get groups" line, which is few lines after in the file, add the following code:
_ # Get mesh dimension
_ if nbVolumesInMesh != 0:
_ _ meshDimension=3
_ else:
_ _ meshDimension=2
_ #-
Best regards,
William
