@@ -86,7 +86,7 @@ def volumes_by_material(self) -> Dict[str, list[Volume]]:
8686 A dictionary where keys are material names (str) and values
8787 are lists of Volume objects.
8888 """
89- material_map : DefaultDict [str , list [Volume ]] = defaultdict (list )
89+ material_map : defaultdict [str , list [Volume ]] = defaultdict (list )
9090 for volume in self .volumes :
9191 if volume .material is None :
9292 continue
@@ -347,7 +347,7 @@ def _check_category_and_dimension(self):
347347 raise ValueError (f"{ identifier } has no category or geom_dimension tags assigned." )
348348
349349 def __eq__ (self , other ):
350- return type (other ) == type (self ) and \
350+ return type (other ) is type (self ) and \
351351 self .model == other .model and \
352352 self .handle == other .handle
353353
@@ -403,6 +403,11 @@ def category(self, category: str):
403403 """Set the DAGMC set's category."""
404404 self ._tag_set_data (self .model .category_tag , category )
405405
406+ @property
407+ def groups (self ) -> list [Group ]:
408+ """Get list of groups containing this DAGMC set."""
409+ return [group for group in self .model .groups if self in group ]
410+
406411 @abstractmethod
407412 def _get_triangle_sets (self ):
408413 """Retrieve all (surface) sets under this set that contain triangle elements.
@@ -584,6 +589,34 @@ def reverse_volume(self) -> Optional[Volume]:
584589 def reverse_volume (self , volume : Volume ):
585590 self .senses = [self .forward_volume , volume ]
586591
592+ @property
593+ def _boundary_group (self ) -> Optional [Group ]:
594+ for group in self .groups :
595+ if "boundary:" in group .name :
596+ return group
597+ return None
598+
599+ @property
600+ def boundary (self ) -> Optional [str ]:
601+ """Name of the boundary assigned to this surface."""
602+ group = self ._boundary_group
603+ if group is not None :
604+ return group .name .removeprefix ('boundary:' )
605+ return None
606+
607+ @boundary .setter
608+ def boundary (self , name : Optional [str ]):
609+ group = self ._boundary_group
610+
611+ if group is not None :
612+ # Remove surface from existing group
613+ group .remove_set (self )
614+
615+ # create a new group or get an existing group
616+ if name is not None :
617+ group = Group .create (self .model , name = f"boundary:{ name } " )
618+ group .add_set (self )
619+
587620 @property
588621 def volumes (self ) -> list [Volume ]:
589622 """Get the parent volumes of this surface.
@@ -619,12 +652,7 @@ def __init__(self, model: Model, handle: np.uint64):
619652 self ._check_category_and_dimension ()
620653
621654 @property
622- def groups (self ) -> list [Group ]:
623- """Get list of groups containing this volume."""
624- return [group for group in self .model .groups if self in group ]
625-
626- @property
627- def _material_group (self ):
655+ def _material_group (self ) -> Optional [Group ]:
628656 for group in self .groups :
629657 if "mat:" in group .name :
630658 return group
0 commit comments