Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -4216,7 +4216,7 @@ def sum(arg: IntoArray, axis: Optional[Union[int, Sequence[int]]] = None) -> Arr
return summed

@implements(numpy.product)
def product(arg: IntoArray, axis: int) -> Array:
def product(arg: IntoArray, axis: Optional[Union[int, Sequence[int]]] = None) -> Array:
arg = Array.cast(arg)
if arg.dtype == bool:
arg = arg.astype(int)
Expand Down
16 changes: 16 additions & 0 deletions nutils/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,8 @@ def unitcircle(nelems: int, variant: str) -> Tuple[Topology, function.Array]:
the same topological structure as :func:`unitsquare` with
``etype='multipatch'``.

* ``"triangle"``: unstructured mesh of triangles.

Returns
-------
:class:`nutils.topology.TransformChainsTopology`:
Expand All @@ -750,6 +752,20 @@ def unitcircle(nelems: int, variant: str) -> Tuple[Topology, function.Array]:
topo, geom = unitsquare(nelems, 'multipatch')
return topo, _square_to_circle(geom)

elif variant == 'triangle':
transforms = transformseq.IndexTransforms(ndims=2, length=6)
nodes = numpy.zeros((6, 3), dtype=int)
nodes[:,1] = 1, 2, 3, 4, 5, 1
nodes[:,2] = 2, 3, 4, 5, 6, 6
topo = topology.SimplexTopology('X', nodes, transforms, transforms)
x = .5
y = .5 * numpy.sqrt(3)
coords = numpy.array([[0, 0], [1, 0], [x, y], [-x, y], [-1, 0], [-x, -y], [x, -y]])
geom = topo.basis('std', 1) @ coords
scale = (1 - numpy.product(function.rootcoords('X', 2)))**-.5
nrefine = round(numpy.log2(nelems))
return topo.refine(nrefine), geom * scale

else:
raise Exception('invalid variant {!r}'.format(variant))

Expand Down
1 change: 1 addition & 0 deletions tests/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,4 @@ def test_interface(self):

unitcircle(variant='rectilinear')
unitcircle(variant='multipatch')
unitcircle(variant='triangle')