meshio icon indicating copy to clipboard operation
meshio copied to clipboard

Convert Gmsh Physical Groups to Abaqus sets

Open PhilippMetsch opened this issue 4 years ago • 1 comments

Hi,

I am currently trying to convert a mesh generated with Gmsh (4.5.6, MeshFileVersion 2 or 4.1) to Abaqus and I am experiencing some issues. When I try to load the ".inp" file in Abaqus, a data type error occurs. I think this error might be related to the fact, that the physical groups from Gmsh are translated to Abaqus Element Sets and the corresponding elements are not indicated with integers but with floats.

Do you know what I am doing wrong or is there maybe an issue in meshio conversion from Gmsh to Abaqus?

I attached to msh-file and the corresponding inp-file to show you the problem. randomInclusions3DCylinder.zip

PhilippMetsch avatar Jun 23 '20 11:06 PhilippMetsch

@PhilippMetsch

I had a similar issue when I wasn't saving the mesh properly from Gmsh. I went ahead with a brute-force solution (conversion to int) in the interest of time. If you try and take a look at mesh.cell_sets it should point to what is wrong with your mesh. Anyways for this problem, I think this is what you want:

import numpy as np
import meshio
msh = meshio.gmsh.read("randomInclusions3DCylinder.msh")
cellSets = {
    "boundary": msh.cell_sets_dict["boundary"]["triangle"].astype(int),
    "domain": msh.cell_sets_dict["domain"]["tetra"].astype(int),
    "inclusions": msh.cell_sets_dict["inclusions"]["tetra"].astype(int)
}
meshio.abaqus.write("modified.inp", meshio.Mesh(
    msh.points, cells={"tetra": np.vstack((
        cell.data for cell in msh.cells if cell.type=="tetra"
    ))}, cell_sets = {k: [v] for k,v in cellSets.items()}
))

I am not sure if the cell sets are marked properly. Unless you want to save all of your lower dimensional elements (for more complex surface bcs) you must save only the ones needed.

bhaveshshrimali avatar Jul 24 '20 07:07 bhaveshshrimali