Skip to main content

⚠️ This library is in development. Expect breaking changes and bugs, and feel welcome to contribute.

⚠️ See logging to enable logging output when using Jupyter.

Stellarmesh is a Gmsh wrapper and DAGMC geometry creator for fusion neutronics workflows, building on other libraries such as cad-to-dagmc and cad-to-openmc. The goal is to reach feature parity with the Cubit plugin to enable a fully-featured and open-source workflow.

Progress:

  • Import of CadQuery, build123d, STEP and BREP geometry
  • Correct implementation of surface-sense
  • Imprinting and merging of conformal geometry
  • Mesh refinement
  • Automated testing and integration
  • Programatic manipulation of .h5m tags e.g. materials

Contents

Installation

pip install stellarmesh

or install the development version with:

pip install https://github.com/Thea-Energy/stellarmesh.git

Note: Stellarmesh requires an installation of MOAB with pymoab, which is not available on PyPi and must be installed either from source or using Conda.

Usage

Geometry construction

Stellarmesh supports both build123d (recommended) and CadQuery for geometry construction but does not depend on either.

The included examples use build123d. To install, run:

pip install git+https://github.com/gumyr/build123d

For documentation and usage examples, see Read the Docs.

Examples

Simple torus geometry

import build123d as bd
import stellarmesh as sm

solids = [bd.Solid.make_torus(1000, 100)]
for _ in range(3):
    solids.append(solids[-1].faces()[0].thicken(100))
solids = solids[1:]

geometry = sm.Geometry(solids, material_names=["a", "a", "c"])
mesh = sm.Mesh.mesh_geometry(geometry, min_mesh_size=50, max_mesh_size=50)
mesh.write("test.msh")
mesh.render("doc/torus-mesh-reversed.png", rotation_xyz=(90, 0, -90), normals=15)

h5m = sm.MOABModel.make_from_mesh(mesh)
h5m.write("dagmc.h5m")
h5m.write("dagmc.vtk")


Rendered mesh with normals.

Check overlaps
❯ overlap_check dagmc.h5m

NOTICE:
     Performing overlap check using triangle vertex locations only.
     Use the '-p' option to check more points on the triangle edges.
     Run '$ overlap_check --help' for more information.

Running overlap check:
100% |===============================================================>|+
No overlaps were found.
Check materials
❯ mbsize -ll dagmc.h5m | grep mat:

NAME = mat:a
NAME = mat:c
Check watertight
❯ check_watertight dagmc.h5m

number of surfaces=4
number of volumes=3

0/0 (nan%) unmatched edges
0/4 (0%) unsealed surfaces
0/3 (0%) unsealed volumes
leaky surface ids=
leaky volume ids=
0.173068 seconds

Other

Logging

Stellarmesh uses the logging library for debug, info and warning messages. Set the level with:

import logging

logging.basicConfig() # Required in Jupyter to correctly set output stream
logging.getLogger("stellarmesh").setLevel(logging.INFO)

Mesh refinement

Note: given CAD geometry, Gmsh often produces high-quality meshes that do not benefit from remeshing.

Stellarmesh supports mesh refinement using the mmg library. Refine a mesh with:

refined_mesh = mesh.refine(
  ...
)

and consult the Mesh.refine and mmgs documentations for parameter values.



The refined mesh has more triangles in regions with high curvature thanks to the hausdorff parameter.

Many thanks to Erik B. Knudsen for his work on remeshing for CAD-to-OpenMC.

Comparison to other libraries

Stellarmesh CAD-to-DAGMC CAD-to-OpenMC Cubit
Developer Thea Energy Jonathan Shimwell Erik B. Knudsen Coreform
Meshing backend Gmsh Gmsh Gmsh/CQ Cubit
In development ✓ ✓ ✓ ✓
Open-source ✓ ✓ ✓
Surface-sense handling ✓ ✓ 1 ✓
Mesh refinement ✓ ✓ ✓
Manipulation of .h5m files 2

Note: Please file an issue if this table is out-of-date.

1 In development on a personal branch

2 In development

Metadata

Release files for stellarmesh 0.3.0

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

Source distribution (sdist)

Source distribution for stellarmesh 0.3.0
File Size Uploaded Provenance Actions
stellarmesh-0.3.0.tar.gz 14.3 kB Without provenance Details for stellarmesh-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 26.8 kB

Release files / stellarmesh-0.3.0.tar.gz

Download URL stellarmesh-0.3.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
56939b83fb9f0ea0b2f0476a3d6040a128c685fefdcd19f5e870c109eeb0099d
BLAKE2b-256 checksum
How to use checksums
f8256bb95c922119b5c0091a32b6b38caa323abe7ed47a767e961bd1cdab4f43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / stellarmesh-0.3.0-py3-none-any.whl

Download URL stellarmesh-0.3.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c532863270badba5a7f70ccab50eba5a1b4b68ecf6c0a3c612d089ce47cf4ab
BLAKE2b-256 checksum
How to use checksums
7a855878428e15c3a74838fec70b8132117cbb18233f34d3b2bd5df4c4e5a6c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.5

Security for stellarmesh 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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