File: geometrytype.py

package info (click to toggle)
dune-geometry 2.11.0-1~exp2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,316 kB
  • sloc: cpp: 15,164; python: 262; makefile: 6
file content (23 lines) | stat: -rw-r--r-- 1,085 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception

from dune.geometry import *

# make sure t can be reconstructed from str(t)
for t in (vertex, line, triangle, quadrilateral, tetrahedron, pyramid, prism, hexahedron):
    assert GeometryType(str(t)) == t

for d in range(10):
    assert GeometryType(str(simplex(d))) == simplex(d)
    assert GeometryType(str(cube(d))) == cube(d)
    assert GeometryType(str(none(d))) == none(d)

# make sure simplices with special names can be constructed by general mechanism
for d, t in enumerate((vertex, line, triangle, tetrahedron)):
    assert GeometryType("simplex(" + str(d) + ")") == t
    assert GeometryType("general( 0, " + str(d) + ")") == t

# make sure cube with special names can be constructed by general mechanism
for d, t in enumerate((vertex, line, quadrilateral, hexahedron)):
    assert GeometryType("cube(" + str(d) + ")") == t
    assert GeometryType("general( " + str(2**d-1) + ", " + str(d) + ")") == t