pydagmc.dagnav#

This file includes the pydagmc module which is designed to manage and manipulate hierarchical geometric data structures used in computational modeling and simulation built upon the PyMOAB package.

class pydagmc.dagnav.Model(moab_file=None)[source]#

Bases: object

mb: Core#
property surfaces#
property surfaces_by_id#
property volumes#
property volumes_by_id#
property volumes_by_material: Dict[str, list[Volume]]#

Returns a dictionary mapping material names to lists of Volume objects associated with that material.

Material names are derived from group names like “mat:material_name”. The dictionary key will be “material_name”. Volumes without a material group are excluded.

Returns:

A dictionary where keys are material names (str) and values are lists of Volume objects.

Return type:

Dict[str, list[Volume]]

find_volumes_by_material(material_name)[source]#

Retrieves a list of Volume objects associated with the provided material name.

If the exact material name is not found, it KeyError is raised suggesting potential close matches for the requested material.

Parameters:

material_name (str) – The name of the material to search for (e.g., “fuel”, “water”).

Returns:

A list of Volume objects tagged with the specified material name.

Return type:

list[Volume]

Raises:

KeyError – If the material_name is not found in the model. The error message will include suggestions for similar material names if any exist.

property volumes_without_material: list[Volume]#

Returns a list of Volume objects that have not been assigned a material group (i.e., volume.material is None).

property groups#
property groups_by_name: Dict[str, Group]#
property group_names: list[str]#
property id_tag[source]#

Returns the ID tag.

property category_tag[source]#

Returns the category tag used to intidate the use of meshset. Values include “Group”, “Volume”, “Surface”. “Curve” and “Vertex” are also present in the model options but those classes are not supported in this package.

property name_tag[source]#
property geom_dimension_tag[source]#
property surf_sense_tag[source]#

Surface sense tag.

property faceting_tol_tag[source]#

Faceting tolerance tag.

write_file(filename)[source]#

Write the model to a file.

Parameters:

filename (path-like) – The file to write to.

add_groups(group_map)[source]#

Adds groups of GeometrySets to the model.

Parameters:

group_map (dict) – A dictionary whose keys are 2-tuples of (str, int) containing the group name and group ID respectively and whose values are iterables of GeometrySet objects or GeometrySet ID numbers.

create_group(name=None, group_id=None)[source]#

Create a new empty group instance with the given name, or return an existing group if one exists.

Return type:

Group

Parameters:
  • name (str | None)

  • group_id (int | None)

create_volume(global_id=None)[source]#

Create a new empty volume set

Return type:

Volume

Parameters:

global_id (int | None)

create_surface(global_id=None, filename=None)[source]#

Create a new surface set.

Parameters:
  • global_id (int, optional) – The global ID of the surface. If None, a new ID will be generated.

  • filename (path-like, optional) – The file to read from. If None, the surface will be created empty.

Returns:

The new surface set.

Return type:

Surface

class pydagmc.dagnav.GeometrySet(model, handle)[source]#

Bases: object

Generic functionality for a DAGMC EntitySet.

Parameters:
  • model (Model)

  • handle (np.uint64)

property id: int#

Return the DAGMC set’s ID.

property geom_dimension: int#

Return the DAGMC set’s geometry dimension.

property category: str | None#

Return the DAGMC set’s category.

to_vtk(filename)[source]#

Write the set to a VTK file. This will recursively gather all triangles under the group, volume or surface and generate a VTK file.

property triangle_handles#

Returns a pymoab.rng.Range of all triangle handles under this set.

property triangle_conn#

Returns the triangle connectivity for all triangles under this set.

Return type:

numpy.ndarray shape=(N, 3), dtype=np.uint64

property triangle_coords#

Returns the triangle coordinates for all triangles under this set.

Return type:

numpy.ndarray shape=(N, 3), dtype=np.float64

get_triangle_conn_and_coords(compress=False)[source]#

Returns the triangle connectivity and coordinates for all triangles under this set.

Triangle vertex values can be retrieved using:

triangle_conn, coords = Volume.get_triangle_conn_and_coords() triangle_zero_coords = coords[triangle_conn[0]]

Parameters:

compress (bool, optional) – If False, a coordinate numpy array of size (N, 3) will be returned. If True, the coordinates will be compressed to a unique set of coordinates. In either case, entries in the triangle EntityHandle mapping will correspond with the appropriate indices in the coordinate array.

Returns:

  • numpy.ndarray shape=(N, 3), dtype=np.uint64

  • numpy.ndarray shape=(N, 3), dtype=np.float64

get_triangle_coordinate_mapping(compress=False)[source]#

Returns a maping from triangle EntityHandle to triangle coordinate indices triangle coordinates.

Triangle vertex values can be retrieved using:

triangle_handles = Volume.get_triangle_handles() triangle_map, coords = Volume.triangle_coordinate_mapping() triangle_zero_coords = coords[triangle_map[triangle_handles[0]]]

Parameters:

compress (bool, optional) – If False, a coordinate numpy array of size (N, 3) will be returned. If True, the coordinates will be compressed to a unique set of coordinates. In either case, entries in the triangle EntityHandle mapping will correspond with the appropriate indices in the coordinate array.

Return type:

numpy.ndarray shape=(N, 3), dtype=np.uint64

delete()[source]#

Delete this set from the MOAB database, but doesn’t delete this GeometrySet object. The object remains but no longer refers to anything in the model. In many cases, it may make sense to delete this GeometrySet object immediately following this operation.

classmethod create(model, global_id=None)[source]#

Create new set

Return type:

GeometrySet

Parameters:
class pydagmc.dagnav.Surface(model, handle)[source]#

Bases: GeometrySet

Parameters:
  • model (Model)

  • handle (np.uint64)

property senses: list[Volume | None]#

Surface sense data.

property forward_volume: Volume | None#

Volume with forward sense with respect to the surface.

property reverse_volume: Volume | None#

Volume with reverse sense with respect to the surface.

property volumes: list[Volume]#

Get the parent volumes of this surface.

property num_triangles: int#

Returns the number of triangles in this surface

property area: float#

Returns the area of the surface

class pydagmc.dagnav.Volume(model, handle)[source]#

Bases: GeometrySet

Parameters:
  • model (Model)

  • handle (np.uint64)

property groups: list[Group]#

Get list of groups containing this volume.

property material: str | None#

Name of the material assigned to this volume.

property surfaces: list[Surface]#

Returns surface objects for all surfaces making up this vollume

property surfaces_by_id: dict[int, Surface]#
property num_triangles: int#

Returns the number of triangles in this volume

property volume: float#

Returns the volume of the volume

class pydagmc.dagnav.Group(model, handle)[source]#

Bases: GeometrySet

Parameters:
  • model (Model)

  • handle (np.uint64)

property name: str | None#

Returns the name of this group.

property volumes: list[Volume]#

Returns a list of Volume objects for the volumes contained by the group set.

property volumes_by_id: dict[int, Volume]#
property surfaces: list[Surface]#

Returns a list of Surface objects for the surfaces contained by the group set.

property surfaces_by_id: dict[int, Surface]#
property volume_ids#

Returns a list of the contained Volume IDs

property surface_ids#

Returns a lsit of the contained Surface IDs

remove_set(ent_set)[source]#

Remove an entity set from the group.

add_set(ent_set)[source]#

Add an entity set to the group.

merge(other_group)[source]#

Merge another group into this group. This will remove the other group from the DAGMC file.

classmethod create(model, name=None, group_id=None)[source]#

Create a new group instance with the given name, or return an existing group if one exists.

Return type:

Group

Parameters:
  • model (Model)

  • name (str | None)

  • group_id (int | None)