How kip-hart/microstructpy works
Project Type and Purpose
• MicroStructPy is an open-source Python library and command-line tool for generating and visualizing 2D/3D microstructure meshes.
High-Level Components
a. User Interfaces
• CLI (“microstructpy” executable, parses XML inputs)
• Python API (importable package for custom scripts)
b. Core Library Modules
• seeding: Seed and SeedList classes for particle placement strategies
• meshing:
– PolyMesh: builds polygonal (Voronoi) meshes from seeds
– TriMesh: converts PolyMesh to triangular meshes
• verification: checks mesh quality and consistency
• _misc: helper utilities
c. I/O and Examples
• XML reader (CLI-driven)
• File writers: common mesh formats, CSV, XML, etc.
• Examples folder (built-in demos and sample XML files)
d. Support Infrastructure
• Documentation (Sphinx via docs/source)
• Tests (pytest suites under tests/)
• Packaging & CI (setup.py, GitHub Actions for build, test, publish)
Component Relationships and Data Flow
1) User invokes CLI or API → XML or Python parameters
2) CLI parser instantiates geometry.Domain and seeding.SeedList
3) seeds.position(domain) → positioned seed list
4) PolyMesh.from_seeds(seeds, domain) → polygon mesh
5) TriMesh.from_polymesh(polygon_mesh) → triangular mesh
6) verification.run(mesh) → quality metrics/errors
7) Output phase: write files, plot with matplotlib
8) Examples serve as preconfigured pipelines, documentation & tests validate each stage
Architectural Patterns and Design Principles
• Modular layering: distinct packages for geometry, seeding, meshing, verification
• Factory methods (“from_seeds”, “from_polymesh”) encapsulate construction logic
• Separation of concerns: CLI layer vs. core library vs. I/O vs. visualization
Technologies and Frameworks
• Language: Python
• Build & packaging: setuptools (setup.py, setup.cfg), pytest, tox
• Documentation: Sphinx, ReadTheDocs
• Continuous Integration: GitHub Actions (testing, security scans, publishing)
• Visualization: matplotlib
• Optional C++ bindings: pybind11 (as fallback dependency)