Metadata-Version: 2.4
Name: mixdpy
Version: 0.2.2
Summary: MIXD format mesh handler
Author-email: Moritz Billen <billen@cats.rwth-aachen.de>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: numpy
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"

<div align="center">
<h1><span style="font-family: monospace;"><span style="color: red;">m</span><span style="color: orange;">i</span><span style="color: yellow;">x</span><span style="color: green;">d</span><span style="color: blue;">p</span><span style="color: indigo;">y</span></span></h1>
Package for handling mixd meshes and associated data
</div>

---

This package provides read and write routines for big-endian binary files. It was mainly developed for the MIXD mesh format developed at [CATS](https://cats.rwth-aachen.de).

The package also provides a class for reading the MIXD mesh format and associated data.

## Installation

In your python environment run:

```zsh
pip install git+ssh://git@git.rwth-aachen.de/cats-gitolite/private/tools/mixdpy.git
```

## Examples

Some examples:

### Write and read binaries

```python
import mixdpy
import numpy as np

arr = np.arange(24, dtype=np.int32).reshape(2, 3, 4)
filename = "somebinarray"

mixdpy.write_int(filename, arr, shift=False)
out = mixdpy.read_int(filename, shape=(3, 4), shift=False)
```


### Reading a mesh

```python
import mixdpy

path_to_mesh = "mesh"

mesh = mixdpy.Mixd(path_to_mesh, minf_name="minf.space") # Infers dpst flag from mien entries

# Read associated data
ndf = mesh.nsd + 1
ins_data_out = mesh.read_node_float("data.out",entry_shape=(ndf,))
ins_data_all = mesh.read_node_float("data.all",entry_shape=(ndf,),nts=-1)

print(mesh.get_bounds())
```

### Export mesh using meshio

```python
import mixdpy
import meshio

path_to_mesh = "mesh"
mesh = mixdpy.Mixd(path_to_mesh)

ndf = mesh.nsd + 1
ins_data_out = mesh.read_node_float("data.out",entry_shape=(ndf,))

export_mesh = meshio.Mesh(
    mesh.mxyz,
    {"tetra":mesh.mien}
    point_data = {
        "velocity" : ins_data_out[0,:,:mesh.nsd],
        "pressure" : ins_data_out[0,:,mesh.nsd]
    }
)
export_mesh.write("ins.vtk")
```
