-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathtest_create.py
More file actions
83 lines (69 loc) · 2.38 KB
/
Copy pathtest_create.py
File metadata and controls
83 lines (69 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright (c) 2022 Matthew Scroggs
# FEniCS Project
# SPDX-License-Identifier: MIT
import pytest
import basix
cells = [
basix.CellType.point,
basix.CellType.interval,
basix.CellType.triangle,
basix.CellType.quadrilateral,
basix.CellType.tetrahedron,
basix.CellType.hexahedron,
basix.CellType.prism,
basix.CellType.pyramid,
]
elements = [
basix.ElementFamily.P,
basix.ElementFamily.RT,
basix.ElementFamily.BDM,
basix.ElementFamily.N1E,
basix.ElementFamily.N2E,
basix.ElementFamily.Regge,
basix.ElementFamily.HHJ,
basix.ElementFamily.bubble,
basix.ElementFamily.serendipity,
basix.ElementFamily.DPC,
basix.ElementFamily.CR,
basix.ElementFamily.Hermite,
basix.ElementFamily.iso,
basix.ElementFamily.custom,
]
variants = [
[basix.LagrangeVariant.gll_isaac],
[basix.LagrangeVariant.gll_warped],
[basix.LagrangeVariant.legendre],
[basix.LagrangeVariant.bernstein],
[basix.LagrangeVariant.unset, basix.DPCVariant.diagonal_gll],
[basix.LagrangeVariant.unset, basix.DPCVariant.legendre],
[basix.LagrangeVariant.legendre, basix.DPCVariant.legendre],
]
def test_all_cells_included():
all_cells = [cell for cell in basix.CellType]
assert sorted(all_cells) == sorted(cells)
def test_all_elements_included():
all_elements = [e for e in basix.ElementFamily]
assert sorted(all_elements) == sorted(elements)
@pytest.mark.parametrize("cell", cells)
@pytest.mark.parametrize("degree", range(-1, 5))
@pytest.mark.parametrize("family", elements)
@pytest.mark.parametrize("variant", variants)
def test_create_element(cell, degree, family, variant):
"""Check that either the element is created or a RuntimeError is thrown."""
try:
element = basix.create_element(family, cell, degree, *variant)
assert element.degree == degree
except RuntimeError as e:
# Don't allow cryptic "dgesv failed" messages
if len(e.args) == 0 or "dgesv" in e.args[0]:
raise e
try:
element = basix.create_element(family, cell, degree, *variant, discontinuous=True)
assert element.degree == degree
except RuntimeError as e:
if len(e.args) == 0 or "dgesv" in e.args[0]:
raise e
def test_create_high_degree_lagrange():
basix.create_element(
basix.ElementFamily.P, basix.CellType.hexahedron, 7, basix.LagrangeVariant.gll_isaac
)