Skip to content

Commit

Permalink
Assign new ID to group upon creation, check surfaces in __contains__
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano committed Jan 17, 2024
1 parent 4372b52 commit 77759da
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dagmc/dagnav.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from abc import abstractmethod
from functools import cached_property
from itertools import chain
from typing import Optional, Dict

import numpy as np
Expand Down Expand Up @@ -254,8 +255,9 @@ def material(self, name: str):
group.remove_set(self)

if not existing_group:
# Create new group, add name/category tags, add entity
new_group = Group.create(self.model, name=f"mat:{name}")
# Create new group and add entity
group_id = max(g.id for g in self.model.groups.values()) + 1
new_group = Group.create(self.model, name=f"mat:{name}", group_id=group_id)
new_group.add_set(self)

def get_surfaces(self):
Expand All @@ -273,7 +275,8 @@ def _get_triangle_sets(self):
class Group(DAGSet):

def __contains__(self, ent_set: DAGSet):
return any(vol.handle == ent_set.handle for vol in self.get_volumes().values())
return any(vol.handle == ent_set.handle for vol in chain(
self.get_volumes().values(), self.get_surfaces().values()))

@property
def name(self) -> str:
Expand Down

0 comments on commit 77759da

Please sign in to comment.