def test_init(self): d = 2 lx = 1.2 ly = 2.3 geom = Geometry(d, lx, ly) self.assertEqual(d, geom.d) self.assertEqual(lx, geom.lx) self.assertEqual(ly, geom.ly)
def test_init(self): geometry = Geometry(1, 4.0) Nx = 10 cellNumPerDim = {'Nx': Nx, 'Ny': None, 'Nz': None} self.assertEqual('coarse', self.mesh.size) self.assertEqual(geometry.d, self.mesh.geometry.d) self.assertEqual(geometry.lx, self.mesh.geometry.lx) self.assertEqual(geometry.ly, self.mesh.geometry.ly) self.assertEqual(geometry.lz, self.mesh.geometry.lz)
def setUp(self): self.geometry = Geometry(3, 1.0, 1.0, 1.0) self.location = [0.1, 0.0, 0.0] self.fwhm = 0.1 self.fct = 'uniform' self.a = 1.0 self.b = 0.0 self.src = Source(self.geometry, self.location, self.fwhm, self.fct, self.a, self.b)
def test_validateGeometry_dimension(self): ''' generate error if d > 3 ''' d = 9 lx = 1.0 with six.assertRaisesRegex(self, ValueError, 'd=9 is not a valid dimension.'): Geometry(d, lx)
def test_init(self): geometry = Geometry(2, 4.0, 2.98) Nx = 10 Ny = int(2.98 / 0.4) cellNumPerDim = {'Nx': Nx, 'Ny': Ny, 'Nz': None} self.assertEqual('coarse', self.mesh.size) self.assertEqual(geometry.d, self.mesh.geometry.d) self.assertEqual(geometry.lx, self.mesh.geometry.lx) self.assertEqual(geometry.ly, self.mesh.geometry.ly) self.assertEqual(geometry.lz, self.mesh.geometry.lz)
def test_init(self): d = 3 lx = 1.2 ly = 2.3 lz = 4.1 geom = Geometry(d, lx, ly, lz) self.assertEqual(d, geom.d) self.assertEqual(lx, geom.lx) self.assertEqual(ly, geom.ly) self.assertEqual(lz, geom.lz)
def test_getConnectivity(self): geometry = Geometry(2, 1.0, 0.2) mesh = Mesh('coarse', geometry) c = np.array([[0, 1, 11, 12], [1, 2, 12, 13], [2, 3, 13, 14], [3, 4, 14, 15], [4, 5, 15, 16], [5, 6, 16, 17], [6, 7, 17, 18], [7, 8, 18, 19], [8, 9, 19, 20], [9, 10, 20, 21], [11, 12, 22, 23], [12, 13, 23, 24], [13, 14, 24, 25], [14, 15, 25, 26], [15, 16, 26, 27], [16, 17, 27, 28], [17, 18, 28, 29], [18, 19, 29, 30], [19, 20, 30, 31], [20, 21, 31, 32]]) np.testing.assert_array_equal(c, mesh.getConnectivity())
def setUp(self): self.mesh = Mesh('coarse', Geometry(3, 1.0, 1.0, 1.0)) self.bcType = ['dirichlet', 'dirichlet', 'dirichlet'] self.g1 = ['uniform', 'uniform', 'uniform'] self.a1 = [0.0, 0.0, 1.0] self.b1 = [0.0, 2.0, 0.9] self.k1 = [-3.0, 0.0, 0.0] self.g2 = ['uniform', 'uniform', 'uniform'] self.a2 = [0.0, -1.0, 0.0] self.b2 = [0.0, 2.1, 0.0] self.k2 = [0.0, 0.0, 0.4] self.bnd = Boundary(self.mesh, self.bcType, self.g1, self.a1, self.b1, self.k1, self.g2, self.a2, self.b2, self.k2)
def __init__(self, geometry=Geometry(), location=[ds[0], ds[1], ds[2]], fwhm=ds[3], fct=ds[4], a=ds[5], b=ds[6]): self.geometry = geometry self.location = location self.fwhm = fwhm self.fct = fct self.a = a self.b = b
def test_checkLength_length(self): ''' generate error if l < 0 ''' d = 1 lx = 1.0 geom = Geometry(d, lx) with six.assertRaisesRegex(self, ValueError, 'lx must be positive.'): geom.checkLength(-1.0, 'x') with six.assertRaisesRegex( self, ValueError, 'Please set the length in ' 'the x direction.'): geom.checkLength(None, 'x') with six.assertRaisesRegex(self, ValueError, 'l=u is not a valid length.'): geom.checkLength('u', 'x')
def test_checkLength_length(self): ''' generate error if l < 0 ''' d = 1 lx = 1.0 geom = Geometry(d, lx) with six.assertRaisesRegex(self, ValueError, 'lx must be positive.'): geom.checkLength(-1.0, 'x') with six.assertRaisesRegex(self, ValueError, 'Please set the length in ' 'the x direction.'): geom.checkLength(None, 'x') with six.assertRaisesRegex(self, ValueError, 'l=u is not a valid length.'): geom.checkLength('u', 'x')
def test_getConnectivity(self): geometry = Geometry(3, 1.0, 0.2, 0.1) mesh = Mesh('coarse', geometry) c = np.array([[0, 1, 6, 7, 2, 3, 8, 9], [2, 3, 8, 9, 4, 5, 10, 11], [6, 7, 12, 13, 8, 9, 14, 15], [8, 9, 14, 15, 10, 11, 16, 17], [12, 13, 18, 19, 14, 15, 20, 21], [14, 15, 20, 21, 16, 17, 22, 23], [18, 19, 24, 25, 20, 21, 26, 27], [20, 21, 26, 27, 22, 23, 28, 29], [24, 25, 30, 31, 26, 27, 32, 33], [26, 27, 32, 33, 28, 29, 34, 35], [30, 31, 36, 37, 32, 33, 38, 39], [32, 33, 38, 39, 34, 35, 40, 41], [36, 37, 42, 43, 38, 39, 44, 45], [38, 39, 44, 45, 40, 41, 46, 47], [42, 43, 48, 49, 44, 45, 50, 51], [44, 45, 50, 51, 46, 47, 52, 53], [48, 49, 54, 55, 50, 51, 56, 57], [50, 51, 56, 57, 52, 53, 58, 59], [54, 55, 60, 61, 56, 57, 62, 63], [56, 57, 62, 63, 58, 59, 64, 65]]) np.testing.assert_array_equal(c, mesh.getConnectivity())
def test_getConnectivity(self): geometry = Geometry(1, 1.0) mesh = Mesh('coarse', geometry) c = np.array([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) np.testing.assert_array_equal(c, mesh.getConnectivity())
def setUp(self): #super().setUp() geometry = Geometry(1, 4.0) self.mesh = Mesh('coarse', geometry)
def setUp(self): #super().setUp() geometry = Geometry(3, 4.0, 2.98, 2.1) self.mesh = Mesh('coarse', geometry)
def test_init(self): d = 1 lx = 1.2 geom = Geometry(d, lx) self.assertEqual(d, geom.d) self.assertEqual(lx, geom.lx)