Methodology#
PyDAGMC provides a Pythonic abstraction layer over PyMOAB for interacting with DAGMC (Direct Accelerated Geometry Monte Carlo) .h5m files. This section delves into the underlying concepts, data structures, and design choices that enable PyDAGMC’s functionality.
File Loading#
When a file is loaded, its embedded geometric topology relationships and metadata (material/property assignments) are loaded according to the conventions established by the DAGMC library. This process culminates in a fully interactive Model object ready for querying and manipulation.
Core Design Philosophy#
The primary goal of PyDAGMC is to simplify common interactions with DAGMC models by:
Object-Oriented Interface: Representing DAGMC entities (Groups, Volumes, Surfaces) as intuitive Python objects with methods and properties relevant to their roles.
Abstraction of PyMOAB Complexity: Hiding some of the lower-level details of PyMOAB’s API, particularly around tag handling and entity set traversal for common DAGMC use cases.
Focus on DAGMC Semantics: Leveraging the specific metadata conventions established by DAGMC for identifying and relating geometric entities.
Ease of Use: Providing a higher-level API that reduces boilerplate code for common queries and manipulations.
The DAGMC Data Model#
PyDAGMC’s functionality is deeply tied to the data model established by DAGMC, which uses standard MOAB tags to imbue a .h5m file with specific semantic meaning. Understanding this data model is crucial to understanding how PyDAGMC interprets the geometry and its associated metadata.
Entity Sets (MBENTITYSET)#
At the core, DAGMC geometry is organized using MOAB Entity Sets. These are collections of other entities, which can include mesh elements (like triangles) or other entity sets, forming a hierarchical structure. PyDAGMC maps these entity sets to its Group, Volume, and Surface classes.
Implicit Relationships (Parent-Child)#
MOAB allows entity sets to contain other entity sets, forming parent-child relationships.
Volumes and Surfaces: A
Volumeentity set typically containsSurfaceentity sets that form its boundary. PyDAGMC usesmb.get_child_meshsets(volume_handle)to find aVolume’s surfaces andmb.get_parent_meshsets(surface_handle)to find aSurface’s parent volumes.Groups and Volumes/Surfaces: A
Groupentity set containsVolumeand/orSurfaceentity sets. PyDAGMC usesmb.get_entities_by_type_and_tagwithin the group’s handle to find its constituent volumes and surfaces.
PyDAGMC Class Structure#
The main classes in PyDAGMC mirror the DAGMC entity hierarchy:
Model:The entry point for loading and interacting with a DAGMC
.h5mfile.It initializes a
pymoab.core.Coreinstance.Provides access to all
Groups,Volumes, andSurfaces in the model via properties likemodel.groups_by_name,model.volumes_by_id, etc.Manages cached MOAB tag handles for efficiency.
Tracks used entity IDs to assist in assigning unique IDs to newly created entities.
GeometrySet(Abstract Base Class):Provides common functionality for
Group,Volume, andSurface.Manages the MOAB entity
handle.Provides properties for common tags (
id,geom_dimension,category).Includes methods for triangle data extraction (
triangle_handles,triangle_conn,triangle_coords,get_triangle_conn_and_coords), VTK export (to_vtk), and entity deletion (delete).The
_check_category_and_dimension()method enforces consistency betweenCATEGORY_TAGandGEOM_DIMENSION_TAG.
Surface(GeometrySet):Represents a 2D geometric surface.
Provides access to its sense data (
senses,forward_volume,reverse_volume).Calculates surface area (
area).Directly contains triangle mesh elements (
MBTRI).
Volume(GeometrySet):Represents a 3D geometric volume.
Provides access to its constituent
Surfaces (surfaces,surfaces_by_id).Determines its material assignment by looking for a parent
Groupwith a name like"mat:..."(materialproperty).Calculates its geometric volume (
volume) using the divergence theorem on its bounding surface triangles and their senses.
Group(GeometrySet):Represents a logical collection of
Volumes and/orSurfaces.Identified by a
name(fromNAME_TAG_NAME).Provides access to its contained
Volumes (volumes,volumes_by_id,volume_ids) andSurfaces (surfaces,surfaces_by_id,surface_ids).Supports adding (
add_set) and removing (remove_set) entities.The
merge()method allows combining two groups with the same name.
Limitations and Future Directions#
Curve and Vertex Entities: While DAGMC specifications include “Curve” and “Vertex” categories, PyDAGMC currently does not provide dedicated classes or extensive support for them.
Advanced Meshing Operations: PyDAGMC focuses on querying and metadata manipulation, not on mesh generation or modification (beyond loading STLs into surfaces).
Performance for Extremely Large Models: While PyMOAB is efficient, some PyDAGMC operations that iterate over many entities might be optimizable. Caching strategies are used (e.g., for tag handles) but could potentially be expanded.
This methodological overview should provide a clearer picture of how PyDAGMC functions internally and interacts with the underlying DAGMC and PyMOAB libraries.