# Easy way to import mesh file of complex geometries from Ansys to FEniCS

Meshing is the most crucial part of finite element analysis. When the geometry is complicated, it becomes difficult to handle the mesh efficiently. It is always good to have an easy method through which we can import the mesh. In our lab, we mainly work with the open source finite element analysis software FEniCS. In FEniCS, we usually import the mesh file .xdmf format. The mesh processing pipeline is explained in this blog post. Sometimes it becomes necessary to import the mesh file from any commercial packages like Ansys, Abaqus, etc.

In this post, I will explain the procedure of using a mesh file from Ansys to the FEniCS script.

• Make the model in Ansys. Then click to Mesh — Insert — Method. Then select the whole geometry (ctrl + A). After selecting, you will see a dialogue box in that click on Geometry “No selection” option and apply. Then change the Method to Tetrahedrons. And update the mesh.
• After meshing the model, right-click on the Static structural option and export the Nastran file in BDF file format.
• Once you have saved the mesh file, Then open this file in Gmsh.
• Create a Physical group for volume mesh entity by selecting all the Surfaces using the command : Physical Volume(“domain”, 1) = Volume{:};
• Then do the 1D, 2D, and 3D meshing in Gmsh and save the mesh file in .msh format.
• Once you get this file you can use meshio, a fantastic open-source package that helps to convert the .msh file to .xdmf file format using the simple command.

meshio convert input_file_name.msh output_file_name.xdmf

Then you can import this .xdmf file in FEniCS script and you are good to go.