File: test_gradient.py

package info (click to toggle)
python-meshplex 0.17.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 668 kB
  • sloc: python: 3,626; makefile: 13
file content (46 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download | duplicates (3)
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
# from helpers import download_mesh
# import meshplex
#
# import numpy as np
# import unittest
#
#
# class GradientTest(unittest.TestCase):
#
#     def setUp(self):
#         return
#
#     def _run_test(self, mesh):
#         num_nodes = len(mesh.points)
#         # Create function  2*x + 3*y.
#         a_x = 7.0
#         a_y = 3.0
#         a0 = 1.0
#         u = a_x * mesh.points[:, 0] + \
#             a_y * mesh.points[:, 1] + \
#             a0 * np.ones(num_nodes)
#         # Get the gradient analytically.
#         sol = np.empty((num_nodes, 2))
#         sol[:, 0] = a_x
#         sol[:, 1] = a_y
#         # Compute the gradient numerically.
#         grad_u = mesh.compute_gradient(u)
#
#         tol = 1.0e-13
#         for k in range(num_nodes):
#             self.assertAlmostEqual(grad_u[k][0], sol[k][0], delta=tol)
#             self.assertAlmostEqual(grad_u[k][1], sol[k][1], delta=tol)
#         return
#
#     def test_pacman(self):
#         filename = download_mesh(
#                 'pacman.vtk',
#                 '2da8ff96537f844a95a83abb48471b6a'
#                 )
#         mesh, _, _, _ = meshplex.read(filename)
#         self._run_test(mesh)
#         return
#
#
# if __name__ == '__main__':
#     unittest.main()