Skip to content

Commit

Permalink
support alternate root name in partition
Browse files Browse the repository at this point in the history
  • Loading branch information
joostvanzwieten committed Apr 16, 2021
1 parent 7380aa1 commit d2a4ca6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nutils/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ def trim(self, levelset, maxrefine, ndivisions=8, name='trimmed', leveltopo=None

@log.withcontext
@types.apply_annotations
def partition(self, levelset:function.asarray, maxrefine:types.strictint, posname:types.strictstr, negname:types.strictstr, *, ndivisions=8, arguments=None):
partsroot = function.Root('parts', 0)
def partition(self, levelset:function.asarray, maxrefine:types.strictint, posname:types.strictstr, negname:types.strictstr, *, ndivisions=8, arguments=None, rootname:types.strictstr='parts'):
partsroot = function.Root(rootname, 0)
pos = self._trim(levelset, maxrefine=maxrefine, ndivisions=ndivisions, arguments=arguments)
refs = tuple((pref, bref-pref) for bref, pref in zip(self.references, pos))
return PartitionedTopology(self, partsroot, refs, (posname, negname))
Expand Down Expand Up @@ -2644,6 +2644,13 @@ def getitem(self, item):
refs = tuple(tuple(ref & bref for ref in self.refs[self.basetopo.transforms.index(trans)]) for bref, trans in zip(topo.references, topo.transforms))
return PartitionedTopology(topo, self.partsroot, refs, self.names)

def slice(self, items):
topo = self.basetopo.slice(items)
if not topo:
return topo * EmptyTopology((self.partsroot,), 0)
refs = tuple(tuple(ref & bref for ref in self.refs[self.basetopo.transforms.index(trans)]) for bref, trans in zip(topo.references, topo.transforms))
return PartitionedTopology(topo, self.partsroot, refs, self.names)

@property
def boundary(self):
baseboundary = self.basetopo.boundary
Expand Down

0 comments on commit d2a4ca6

Please sign in to comment.