File: test_curl.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 (37 lines) | stat: -rw-r--r-- 852 bytes parent folder | download | duplicates (2)
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
import pathlib

import numpy as np

import meshplex

this_dir = pathlib.Path(__file__).resolve().parent


def test_pacman():
    mesh = meshplex.read(this_dir / ".." / "meshes" / "pacman.vtu")

    # mesh = meshplex.MeshTri(mesh.points[:, :2], mesh.cells("points"))
    # mesh.signed_cell_volumes
    # exit(1)

    # Create circular vector field 0.5 * (y, -x, 0)
    # which has curl (0, 0, 1).
    A = np.array([[-0.5 * coord[1], 0.5 * coord[0], 0.0] for coord in mesh.points])
    # Compute the curl numerically.
    B = mesh.compute_ncurl(A)

    # mesh.write(
    #     'curl.vtu',
    #     point_data={'A': A},
    #     cell_data={'B': B}
    #     )

    tol = 1.0e-14
    for b in B:
        assert abs(b[0] - 0.0) < tol
        assert abs(b[1] - 0.0) < tol
        assert abs(b[2] - 1.0) < tol


if __name__ == "__main__":
    test_pacman()