Test interpolation into an element with a value size that uses an identity map.
()
| 808 | |
| 809 | |
| 810 | def test_custom_vector_element(): |
| 811 | """Test interpolation into an element with a value size that uses an identity map.""" |
| 812 | mesh = create_unit_square(MPI.COMM_WORLD, 10, 10) |
| 813 | wcoeffs = np.eye(6) |
| 814 | x = [[], [], [], []] |
| 815 | x[0].append(np.array([[0.0, 0.0]])) |
| 816 | x[0].append(np.array([[1.0, 0.0]])) |
| 817 | x[0].append(np.array([[0.0, 1.0]])) |
| 818 | for _ in range(3): |
| 819 | x[1].append(np.zeros((0, 2))) |
| 820 | x[2].append(np.zeros((0, 2))) |
| 821 | M = [[], [], [], []] |
| 822 | for _ in range(3): |
| 823 | M[0].append(np.array([[[[1.0]], [[0.0]]], [[[0.0]], [[1.0]]]])) |
| 824 | for _ in range(3): |
| 825 | M[1].append(np.zeros((0, 2, 0, 1))) |
| 826 | M[2].append(np.zeros((0, 2, 0, 1))) |
| 827 | e = custom_element( |
| 828 | basix.CellType.triangle, |
| 829 | [2], |
| 830 | wcoeffs, |
| 831 | x, |
| 832 | M, |
| 833 | 0, |
| 834 | basix.MapType.identity, |
| 835 | basix.SobolevSpace.H1, |
| 836 | False, |
| 837 | 1, |
| 838 | 1, |
| 839 | dtype=default_real_type, |
| 840 | ) |
| 841 | |
| 842 | V = functionspace(mesh, e) |
| 843 | gdim = mesh.geometry.dim |
| 844 | W = functionspace(mesh, ("Lagrange", 1, (gdim,))) |
| 845 | v = Function(V) |
| 846 | w = Function(W) |
| 847 | v.interpolate(lambda x: (x[0], x[1])) |
| 848 | w.interpolate(lambda x: (x[0], x[1])) |
| 849 | assert np.abs(assemble_scalar(form(ufl.inner(v - w, v - w) * ufl.dx))) == pytest.approx(0) |
| 850 | |
| 851 | |
| 852 | @pytest.mark.skip_in_parallel |
nothing calls this directly
no test coverage detected