writeMesh (write mesh to inp, bdf, and msh files)

Version 1.11 (2.27 MB) by Jiexian Ma
Write MATLAB 2D or 3D finite element mesh to popular mesh file formats (for software Abaqus, Nastran, COMSOL, Gmsh)
23 Downloads
Updated 6 Sep 2025
writeMesh is a MATLAB project for writing MATLAB finite element mesh to inp, bdf, and msh files. writeMesh is a part of Im2mesh package. Tested in MATLAB R2017b.
writeMesh supports mesh with single or multiple phases. Note that phase is also known as part, domain, or physical surface. In finite element modeling of composite materials, each phase in the mesh represents a distinct material component.
writeMesh woks for 2D mesh (triangular and quadrilateral); also works for 3D mesh (tetrahedral and hexahedral).
Mesh file formats
  • inp file (Abaqus)
  • bdf file (Nastran bulk data, compatible with COMSOL)
  • msh file (Gmsh mesh file format)
  • For other formats, you can import the generated msh file into software Gmsh and then export.
How to start
You could go through the README file and the examples.
Examples are live script mlx files (demo01.mlx ~ demo09.mlx). If you find some text in the mlx file is missing, read the html file instead. Examples are also available as html files in the folder "demo_html".
Examples:
  • demo01 - Triangular mesh with single phase
  • demo02 - Triangular mesh with multiple phases
  • demo03 - Quadrilateral mesh
  • demo04 - 2D Mesh with quadratic elements
  • demo05 - Node sets at the boundary and interface when writing inp files
  • demo06 - Select formats when writing inp files
  • demo07 - Tetrahedral mesh
  • demo08 - Hexahedral mesh
  • demo09 - Set tolerance when searching boundary node set
  • inp_example1 - Format #1 of inp file
  • inp_example2 - Format #2 of inp file
  • inp_example3 - Format #3 of inp file
Acknowledgments
Great thanks Dr. Yang Lu for providing valuable suggestions.

Cite As

The development of writeMesh is nontrivial. If you use writeMesh for your project, please cite Im2mesh package as follows.

Ma, Jiexian, and Yuanyuan Li. Im2mesh: A MATLAB/Octave Package for Generating Finite Element Mesh Based on 2D Multi-Phase Image. Zenodo, 2025, https://doi.org/10.5281/ZENODO.14847059.

View more styles
MATLAB Release Compatibility
Created with R2021b
Compatible with R2017b and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.11

See release notes for this release on GitHub: https://github.com/mjx888/writeMesh/releases/tag/v1.11

1.02

See release notes for this release on GitHub: https://github.com/mjx888/writeMesh/releases/tag/v1.02

1.00

See release notes for this release on GitHub: https://github.com/mjx888/writeMesh/releases/tag/v1.00

0.9.1

See release notes for this release on GitHub: https://github.com/mjx888/writeMesh/releases/tag/v0.9.1

0.9.0

See release notes for this release on GitHub: https://github.com/mjx888/writeMesh/releases/tag/v0.9.0

0.8.2

See release notes for this release on GitHub: https://github.com/mjx888/writeMesh/releases/tag/v0.8.2

0.8

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.