Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
pshriwise committed Jan 13, 2024
1 parent f0de216 commit 50022cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 6 additions & 3 deletions dagmc/dagnav.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def __init__(self, model, handle):
def __eq__(self, other):
return self.handle == other.handle

def __repr__(self):
return f'{type(self).__name__} {self.id}, {self.num_triangles()} triangles'

@property
def id(self):
"""Return the DAGMC set's ID.
Expand Down Expand Up @@ -114,7 +117,7 @@ def get_triangle_handles(self):
r = rng.Range()
for s in self._get_triangle_sets():
handle = s if not isinstance(s, DAGSet) else s.handle
r.merge(self.mb.get_entities_by_type(handle, types.MBTRI))
r.merge(self.model.mb.get_entities_by_type(handle, types.MBTRI))
return r

def get_triangle_conn(self):
Expand Down Expand Up @@ -170,7 +173,7 @@ def get_triangle_conn_and_coords(self, compress=False):

return conn, coords

def triangle_coordinate_mapping(self, compress=False):
def get_triangle_coordinate_mapping(self, compress=False):
"""Returns a maping from triangle EntityHandle to triangle coordinate indices triangle coordinates.
Triangle vertex values can be retrieved using:
Expand All @@ -195,7 +198,7 @@ def triangle_coordinate_mapping(self, compress=False):

# create a mapping from triangle EntityHandle to triangle index
tri_map = {eh: c for eh, c in zip(triangle_handles, conn)}
return tri_map, conn
return tri_map, coords


class Surface(DAGSet):
Expand Down
8 changes: 7 additions & 1 deletion test/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,15 @@ def test_compressed_coords(request, capfd):
for i in range(v1.num_triangles()):
assert (coords[conn[i]] == ucoords[uconn[i]]).all()

conn_map, coords = v1.get_triangle_coordinate_mapping()
tris = v1.get_triangle_handles()
assert (conn_map[tris[0]].size == 3)
assert (coords[conn_map[tris[0]]].size == 9)

def test_coords(request, capfd):
test_file = str(request.path.parent / 'fuel_pin.h5m')
groups = dagmc.groups_from_file(test_file)
model = dagmc.DAGModel(test_file)
groups = model.groups

group = groups['mat:fuel']
conn, coords = group.get_triangle_conn_and_coords()
Expand Down

0 comments on commit 50022cb

Please sign in to comment.