def runTest(self): m = self.prepare_mesh() basis = CellBasis(m, self.element_type()) x = projection(lambda x: x[0] ** 2, basis) fun = basis.interpolator(x) X = np.linspace(0, 1, 10) dim = m.dim() if dim == 3: y = fun(np.array([X, [0.31] * 10, [0.62] * 10])) elif dim == 2: y = fun(np.array([X, [0.31] * 10])) else: y = fun(np.array([X])) assert_allclose(y, X ** 2, atol=1e-10)
def test_interpolator_probes(mtype, e, nrefs, npoints): m = mtype() if nrefs > 0: m = m.refined(nrefs) np.random.seed(0) X = np.random.rand(m.p.shape[0], int(npoints)) basis = CellBasis(m, e) y = projection(lambda x: x[0] + x[1], basis) assert_allclose(basis.probes(X) @ y, basis.interpolator(y)(X)) assert_allclose(basis.probes(X) @ y, X[0] + X[1])