import tfields import numpy as np import unittest import sympy # NOQA: F401 import os import sys from .test_core import TensorFields_Check THIS_DIR = os.path.dirname( os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__)))) sys.path.append(os.path.normpath(os.path.join(THIS_DIR))) class Mesh3D_Check(TensorFields_Check): def test_cut_split(self): x, y, z = sympy.symbols('x y z') self._inst.cut(x + 1./100*y > 0, at_intersection='split') def test_triangle(self): tri = self._inst.triangles() mesh = tri.mesh() # print(self._inst, self._inst.maps) # print(tri) # print(mesh, mesh.maps) # print(tfields.Tensors(self._inst).equal(mesh)) self.assertTrue(self._inst.equal(mesh)) class Square_Test(Mesh3D_Check, unittest.TestCase): def setUp(self): self._inst = tfields.Mesh3D.plane((0, 1, 2j), (0, 1, 2j), (0, 0, 1j)) class Sphere_Test(Mesh3D_Check, unittest.TestCase): def setUp(self): self._inst = tfields.Mesh3D.grid( (1, 1, 1), (-np.pi, np.pi, 12), (-np.pi / 2, np.pi / 2, 12), coord_sys='spherical') self._inst.transform('cartesian') self._inst[:, 1] += 2 class IO_Stl_test(unittest.TestCase): # no Mesh3D_Check for speed def setUp(self): self._inst = tfields.Mesh3D.load(os.path.join(THIS_DIR, '../data/baffle.stl')) if __name__ == '__main__': unittest.main()