Git Product home page Git Product logo

stellarmesh's Introduction

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

⚠️ Use MOAB version <= 5.3.1. Later versions suffer from undocumented transport errors in DAGMC.

⚠️ 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.from_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.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

stellarmesh's People

Contributors

akoen avatar paulromano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

stellarmesh's Issues

Properly support FACETING_TOL and GEOMETRY_RESABS

FACETING_TOL represents the maximum distance between a mesh face and the underlying geometry. This would appear not supported in Gmsh.

GEOMETRY_RESABS would appear to be a cubit constant.

Both are used exclusively by DAGMC's make_watertight

Support realtime subprocess logging

By default when subprocess output is captured it gets piped. However, this means that logs aren't visible until the process has completed.

Allow stl import

Currently brep and step files are allowable import formats.

In theroy this package could also allow stl import via moab directly.

It might be a bit different to the existing import files but might be worth considering

import_step not working

Ran code to import step file (2 solids)
import build123d as bd
import stellarmesh as sm
geometry = sm.Geometry
geometry.import_step(filename='blanket_both.stp', material_names=['SiC', 'breed'])
mesh = sm.Mesh.mesh_geometry(geometry, min_mesh_size=10, max_mesh_size=50)

And received error telling me geometry has no solid attribute.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.