Hi all,
I have a mesh file that is created using Hypermesh in the .inp format. I want to import and read it in FEniCS, but I am facing some issues with it. I got the following error.
Here is the .inp file attached.
**
** ABAQUS Input Deck Generated by HyperMesh Version : 13.0.110.31
** Generated using HyperMesh-Abaqus Template Version : 13.0.110
**
** Template: ABAQUS/STANDARD 3D
**
*NODE
1, 0.0 , 0.0 , 0.0
2, 0.05 , 0.0 , 0.0
3, 0.1 , 0.0 , 0.0
4, 0.15 , 0.0 , 0.0
5, 0.2 , 0.0 , 0.0
6, 0.0 , 0.05 , 0.0
7, 0.049999500005 , 0.049999500005 , 0.0
8, 0.09999900001 , 0.049999500005 , 0.0
9, 0.149998500015 , 0.049999500005 , 0.0
10, 0.2 , 0.05 , 0.0
11, 0.0 , 0.1 , 0.0
12, 0.049999500005 , 0.09999900001 , 0.0
13, 0.09999900001 , 0.09999900001 , 0.0
14, 0.149998500015 , 0.09999900001 , 0.0
15, 0.2 , 0.1 , 0.0
16, 0.0 , 0.15 , 0.0
17, 0.049999500005 , 0.149998500015 , 0.0
18, 0.09999900001 , 0.149998500015 , 0.0
19, 0.149998500015 , 0.149998500015 , 0.0
20, 0.2 , 0.15 , 0.0
21, 0.0 , 0.2 , 0.0
22, 0.05 , 0.2 , 0.0
23, 0.1 , 0.2 , 0.0
24, 0.15 , 0.2 , 0.0
25, 0.2 , 0.2 , 0.0
**HWCOLOR COMP 1 11
*ELEMENT,TYPE=S4,ELSET=auto1
1, 1, 2, 7, 6
2, 2, 3, 8, 7
3, 3, 4, 9, 8
4, 4, 5, 10, 9
5, 6, 7, 12, 11
6, 7, 8, 13, 12
7, 8, 9, 14, 13
8, 9, 10, 15, 14
9, 11, 12, 17, 16
10, 12, 13, 18, 17
11, 13, 14, 19, 18
12, 14, 15, 20, 19
13, 16, 17, 22, 21
14, 17, 18, 23, 22
15, 18, 19, 24, 23
16, 19, 20, 25, 24
*****
Here is the code attached.
from fenics import *
import matplotlib.pyplot as plt
pip install --user meshio
pip install --user h5py
import meshio
mesh_from_file = meshio.read("Abaqus-hypermeshsample.inp")
import h5py
import numpy
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
out_mesh = meshio.Mesh(points=mesh.points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
if prune_z:
out_mesh.prune_z_0()
return out_mesh
line_mesh = create_mesh(mesh_from_file, "line", prune_z=True)
meshio.write("facet_mesh.xdmf", line_mesh)
triangle_mesh = create_mesh(mesh_from_file, "triangle", prune_z=True)
meshio.write("mesh.xdmf", triangle_mesh)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-9-5dea5c7603fb> in <module>
----> 1 line_mesh = create_mesh(mesh_from_file, "line", prune_z=True)
2 meshio.write("facet_mesh.xdmf", line_mesh)
3
4 triangle_mesh = create_mesh(mesh_from_file, "triangle", prune_z=True)
5 meshio.write("mesh.xdmf", triangle_mesh)
<ipython-input-8-90f22cb4147e> in create_mesh(mesh, cell_type, prune_z)
2 def create_mesh(mesh, cell_type, prune_z=False):
3 cells = mesh.get_cells_type(cell_type)
----> 4 cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
5 out_mesh = meshio.Mesh(points=mesh.points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
6 if prune_z:
~/.local/lib/python3.6/site-packages/meshio/_mesh.py in get_cell_data(self, name, cell_type)
226 def get_cell_data(self, name: str, cell_type: str):
227 return np.concatenate(
--> 228 [d for c, d in zip(self.cells, self.cell_data[name]) if c.type == cell_type]
229 )
230
KeyError: 'gmsh:physical'
Thanks