(self)
| 67 | # TODO: accuracy is not great... |
| 68 | |
| 69 | def test_2D(self): |
| 70 | tri = pymesh.triangle() |
| 71 | tri.points = np.array([ |
| 72 | [0.0, 0.0], |
| 73 | [1.0, 0.0], |
| 74 | [0.0, 1.0], |
| 75 | [1.0, 1.0], |
| 76 | ]) |
| 77 | tri.keep_convex_hull = True |
| 78 | tri.max_area = 0.0001 |
| 79 | tri.verbosity = 0 |
| 80 | tri.run() |
| 81 | |
| 82 | mesh = tri.mesh |
| 83 | self.assertLess(0, mesh.num_faces) |
| 84 | |
| 85 | solver = pymesh.HarmonicSolver.create(mesh) |
| 86 | bd_indices = mesh.boundary_vertices.ravel() |
| 87 | # f(x,y) = ln(x^2 + y^2) is known to be harmonic. |
| 88 | target_solution = np.log(np.square(numpy.linalg.norm(mesh.vertices + |
| 89 | 1.0, axis=1))) |
| 90 | bd_values = target_solution[bd_indices] |
| 91 | |
| 92 | solver.boundary_indices = bd_indices |
| 93 | solver.boundary_values = bd_values |
| 94 | solver.order = 1 |
| 95 | solver.pre_process() |
| 96 | solver.solve() |
| 97 | |
| 98 | sol = solver.solution.ravel() |
| 99 | |
| 100 | #mesh.add_attribute("target_solution") |
| 101 | #mesh.set_attribute("target_solution", target_solution) |
| 102 | #mesh.add_attribute("solution") |
| 103 | #mesh.set_attribute("solution", sol) |
| 104 | #pymesh.save_mesh("tmp.msh", mesh, *mesh.attribute_names) |
| 105 | |
| 106 | self.assertEqual(mesh.num_vertices, len(sol)) |
| 107 | self.assert_array_almost_equal(target_solution, sol, 3) |
nothing calls this directly
no test coverage detected