Metadata-Version: 2.4
Name: mesh2cdb
Version: 0.1.0
Summary: Write MAPDL .cdb archives from any mesh meshio reads.
Author: Chenshuo Wang
License-Expression: MIT
Project-URL: Homepage, https://github.com/Alto-Auto/mesh2cdb
Project-URL: Issues, https://github.com/Alto-Auto/mesh2cdb/issues
Keywords: mapdl,ansys,gmsh,meshio,cdb,fea,mesh
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: meshio>=5.3
Requires-Dist: numpy>=1.24
Provides-Extra: test
Requires-Dist: ansys-mapdl-core>=0.73.2; extra == "test"
Requires-Dist: gmsh>=4.11; extra == "test"
Requires-Dist: pyvista>=0.44; extra == "test"
Dynamic: license-file

# mesh2cdb

Write MAPDL `.cdb` archives from any mesh [meshio](https://github.com/nschloe/meshio) reads.

meshio reads about forty mesh formats and writes thirty. `.cdb` is not one of them, so a mesh built in gmsh, Abaqus or Nastran has no path into MAPDL. That is the gap this fills.

## Installation

```
pip install mesh2cdb
```

## Usage

```
mesh2cdb part.msh -o part.cdb
mesh2cdb part.inp                 # .bdf, .vtu, .vtk, ...
```

```
part.msh -> part.cdb
  1364 nodes, 650 tetra10
  node component FIXED: 205
  elem component BODY: 650
```

From Python:

```python
import meshio
from mesh2cdb import from_meshio, write

write(from_meshio(meshio.read("part.msh")), "part.cdb")
```

Then in MAPDL:

```python
from ansys.mapdl.core import launch_mapdl

mapdl = launch_mapdl()
mapdl.prep7()
mapdl.cdread("DB", "part.cdb")
```

## Elements

| cell | MAPDL |
|---|---|
| `tetra` | SOLID285 |
| `tetra10` | SOLID187 |
| `hexahedron`, `wedge`, `pyramid` | SOLID185 |
| `hexahedron20`, `wedge15`, `pyramid13` | SOLID186 |

Wedges and pyramids are written as degenerate SOLID185/186 with repeated nodes. Unsupported cell types raise rather than being silently dropped.

## Named regions

gmsh physical groups and Abaqus `*NSET`/`*ELSET` become MAPDL components:

```python
gmsh.model.addPhysicalGroup(2, [face], name="fixed")   # in the mesher
```

```python
mapdl.cmsel("S", "FIXED")                              # in MAPDL
mapdl.d("ALL", "ALL", 0)
```

Solid groups become element components; surface groups become node components. Names are uppercased, non-alphanumeric characters become underscores, and the limit is 32 characters. Two names that collide after that are refused rather than merged.

The mesh converts from every format meshio reads. Names do not:

| source | mesh | named regions |
|---|---|---|
| `.msh` saved by gmsh | yes | yes |
| `.inp` (Abaqus) | yes | yes |
| `.msh` written by meshio | yes | no |
| `.vtu`, `.vtk`, `.bdf` | yes | no |

## Not supported

Materials, sections, boundary conditions, loads and load steps. `.cdb` carries all of them; this writes nodes, elements, element types and components only.

Shells and beams.

CAD geometry. MAPDL cannot import STEP; mesh it in gmsh and convert the mesh.

## Tests

```
pip install mesh2cdb[test]

python tests/verify_meshio.py         # reader agreement
python tests/verify_formats.py        # what survives each format
python tests/verify_all_elements.py   # patch test per element type, launches MAPDL
python tests/verify_cmblock.py        # named regions reach MAPDL, launches MAPDL
```

Each asserts and exits non-zero. `tools/` holds interactive helpers for regenerating the node-ordering tables and inspecting a `.cdb`; they open windows, so they are run by hand.

gmsh and `ansys-mapdl-core` are test dependencies only. `ansys-mapdl-core>=0.73.2` is a hard floor: earlier versions fail to launch MAPDL 2026 R1 with `MapdlDidNotStart: No err file generated`.

## Licence

MIT. Not affiliated with Ansys, Inc. Using the output requires a legal Ansys licence.
