Skip to main content

mixdpy

Package for handling mixd meshes and associated data

Pipeline Status Coverage Report Latest Release

This package provides an interface for handling the MIXD mesh format developed at CATS. Routines for reading/writing big endian binary files and a Mixd class for reading meshes and associated data are provided.

Installation

In your python environment run:

pip install mixdpy

Examples

Some examples:

Write and read binaries

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

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

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,
    {mesh.get_meshio_elem():mesh.mien},
    point_data = {
        "velocity" : ins_data_out[0,:,:mesh.nsd],
        "pressure" : ins_data_out[0,:,mesh.nsd]
    }
)
export_mesh.write("ins.vtk")

Visualize partitioning with pyvista

import pyvista as pv
import mixdpy
import numpy as np

path_to_mesh = "tests/meshes/hypermesh2mixd_sd"
mesh = mixdpy.Mixd(path_to_mesh)
pv_cell_type = pv.CellType.TRIANGLE
n_part = 4

# Pad mesh array with 0s if necessary
coords = np.pad(mesh.mxyz, (0, 3-mesh.nsd))

# Read mipe array from mesh path (nrec, ne, 1). If nrec is 1 the dimension is NOT collapsed.
partitioning_array = mesh.read_elem_int(mesh.path / f"mipe.{n_part:04d}")

out_mesh = pv.UnstructuredGrid({pv_cell_type:mesh.mien}, coords)

out_mesh.cell_data[f"Partitoning {n_part}"] = partitioning_array[0] 

out_mesh.plot(show_edges=True)

Metadata

Release files for mixdpy 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for mixdpy 0.3.1
File Interpreter ABI Platform
mixdpy-0.3.1-py3-none-any.whl Python 3 none any Details

Release files / mixdpy-0.3.1-py3-none-any.whl

Download URL mixdpy-0.3.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54ea73298cbf8424579f3683587a78ce89f41420995c5cbb37ec121223884c3e
BLAKE2b-256 checksum
How to use checksums
ff65cc6b78bd0de3feb8cf988cd3906d43d124b735a5ee780f4e10682f0b82b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.29

Release history Release notifications | RSS feed

0.3.2

2 release files

This release

0.3.1 This release

1 release file

0.2.3

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page