def setupMesh(self, n): points, simplices = example_simplex_mesh((n, n, n)) self.M = discretize.SimplexMesh(points, simplices) return 1.0 / n self.M = discretize.SimplexMesh(points, simplices) return 1.0 / n
def test_find_containing(self): n = 4 points, simplices = example_simplex_mesh((n, n)) mesh = discretize.SimplexMesh(points, simplices) x = np.array([[0.1, 0.2], [0.3, 0.4]]) inds = mesh.point2index(x) np.testing.assert_equal(inds, [16, 5])
def doTestEdge(self, h, rep): nodes, simplices = example_simplex_mesh(h) mesh = discretize.SimplexMesh(nodes, simplices) v = np.random.rand(mesh.n_edges) sig = np.random.rand(1) if rep == 0 else np.random.rand(mesh.nC * rep) def fun(sig): M = mesh.get_edge_inner_product(sig) Md = mesh.get_edge_inner_product_deriv(sig) return M * v, Md(v) print("Edge", rep) return discretize.tests.check_derivative(fun, sig, num=5, plotIt=False)
def test_cell_gradient_stencil(self): n = 4 points, simplices = example_simplex_mesh((n, n)) mesh = discretize.SimplexMesh(points, simplices) G_sten = mesh.stencil_cell_gradient mod = np.zeros(mesh.n_cells) test_cell = 21 mod[test_cell] = 1.0 diff = G_sten @ mod np.testing.assert_equal( np.where(diff != 0.0)[0], np.sort(mesh._simplex_faces[21])) np.testing.assert_equal(diff[diff != 0.0], [-1, 1, -1])
def setupMesh(self, n): dim = self.meshDimension points, simplices = example_simplex_mesh(dim * (n, )) self.M = discretize.SimplexMesh(points, simplices) return 1.0 / n
def setUp(self): n = 8 points, simplices = example_simplex_mesh((n, n)) self.mesh = discretize.SimplexMesh(points, simplices)