def test_09NodeDelete(self): import CGNS.PAT.cgnsutils as CGU import CGNS.PAT.cgnserrors as CGE import CGNS.PAT.cgnskeywords as CGK import numpy n = CGU.nodeCreate('Base', numpy.array([3, 3]), [], CGK.CGNSBase_ts) r = CGU.nodeCreate('ReferenceState', None, [], CGK.ReferenceState_ts, parent=n) d = CGU.nodeCreate('Data', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r) self.assertIsNotNone(CGU.hasChildName(r, 'Data')) CGU.nodeDelete(n, d) self.assertIsNone(CGU.hasChildName(r, 'Data')) d = CGU.nodeCreate('DataZ', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r) self.assertIsNotNone(CGU.hasChildName(r, 'DataZ')) CGU.nodeDelete(r, d) self.assertIsNone(CGU.hasChildName(r, 'DataZ')) CGU.nodeDelete(r, d) self.assertIsNone(CGU.hasChildName(r, 'DataZ')) n = CGU.nodeCreate('Base', numpy.array([3, 3]), [], CGK.CGNSBase_ts) r = CGU.nodeCreate('ReferenceState', None, [], CGK.ReferenceState_ts, parent=n) d = CGU.nodeCreate('Data', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r) self.assertIsNotNone(CGU.getNodeByPath(n, '/Base/ReferenceState/Data')) CGU.nodeDelete(n, d) self.assertIsNone(CGU.hasChildName(r, 'Data')) n = CGU.nodeCreate('Base', numpy.array([3, 3]), [], CGK.CGNSBase_ts) r = CGU.nodeCreate('ReferenceState', None, [], CGK.ReferenceState_ts, parent=n) d = CGU.nodeCreate('Data', numpy.array([3.14]), [], CGK.DataArray_ts, parent=r) self.assertIsNotNone(CGU.getNodeByPath(n, '/Base/ReferenceState/Data')) CGU.removeChildByName(r, 'Data') self.assertIsNone(CGU.hasChildName(r, 'Data'))
CGL.newPointRange(n, value=NPY.array([[1, cellsize]], 'i')) zbc[2] = [] n = CGL.newBoundary(zbc, 'BC', [range(1, cellsize + 1)], btype=CGK.Null_s, family=None, pttype=CGK.PointList_s) g = CGL.newGridLocation(n, value=CGK.CellCenter_s) TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'bc both PointList and PointRange' diag = False (T, b, z, zbc, n, g) = makeCorrectTree(vertexsize, cellsize, ntris) CGL.newPointRange(n, value=NPY.array([[cellsize + 1, cellsize + ntris]], 'i')) TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'bc no PointList or PointRange' diag = False (T, b, z, zbc, n, g) = makeCorrectTree(vertexsize, cellsize, ntris) CGU.removeChildByName(n, CGK.PointList_s) TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'bc FamilySpecified but not FamilyName' diag = False (T, b, z, zbc, n, g) = makeCorrectTree(vertexsize, cellsize, ntris) n[1] = CGU.setStringAsArray(CGK.FamilySpecified_s) TESTS.append((tag, T, diag))
# ------------------------------------------------------------------------- tag = 'gridconnectivity1to1 unvalid opposite GridConnectivity' diag = False (T, b, z) = makeCorrectTree() zgc = CGL.newZoneGridConnectivity(z[0]) gc = CGL.newGridConnectivity1to1(zgc, 'join1_2', 'Zone2', NPY.array([[1, 1], [1, 7], [1, 5]]), NPY.array([[1, 5], [1, 7], [5, 5]]), NPY.array([+1, +2, +3])) zgc = CGL.newZoneGridConnectivity(z[1]) gc = CGL.newGridConnectivity1to1(zgc, 'join2_1', 'Zone1', NPY.array([[1, 5], [1, 7], [5, 5]]), NPY.array([[1, 1], [1, 7], [1, 5]]), NPY.array([+1, +2, +3])) CGU.removeChildByName(gc, CGK.PointRangeDonor_s) TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'gridconnectivity1to1 bad shape on Transform' diag = False (T, b, z) = makeCorrectTree() zgc = CGL.newZoneGridConnectivity(z[0]) gc = CGL.newGridConnectivity1to1(zgc, 'join1_2', 'Zone2', NPY.array([[1, 1], [1, 7], [1, 5]]), NPY.array([[1, 5], [1, 7], [5, 5]]), NPY.array([[+1, +2, +3]])) zgc = CGL.newZoneGridConnectivity(z[1]) gc = CGL.newGridConnectivity1to1(zgc, 'join2_1', 'Zone1', NPY.array([[1, 5], [1, 7], [5, 5]]), NPY.array([[1, 1], [1, 7], [1, 5]]),
order='F')) CGL.newIndexArray(gc, CGK.PointListDonor_s, value=NPY.array([range(cellsize + 2, cellsize + ntris)], order='F')) CGL.newGridLocation(gc, value=CGK.FaceCenter_s) TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'elements absent children' diag = False (T, b, z) = makeCorrectTree(vertexsize, cellsize) tetras = CGL.newElements(z, 'TETRAS', CGK.TETRA_4_s, NPY.ones((cellsize * 4), dtype='int32'), NPY.array([[1, cellsize]], 'i', order='F')) CGU.removeChildByName(tetras, CGK.ElementRange_s) # ElementRange child absent CGU.removeChildByName( tetras, CGK.ElementConnectivity_s) # ElementConnectivity child absent TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'elements out of range' diag = False (T, b, z) = makeCorrectTree(vertexsize, cellsize) tetras = CGL.newElements(z, 'TETRAS', CGK.TETRA_4_s, NPY.ones((cellsize * 4), dtype='int32'), NPY.array([[1, cellsize]], 'i', order='F')) tetras[2][0][1][0] = vertexsize + 1 # ElementConnectity element out of range TESTS.append((tag, T, diag)) # -------------------------------------------------------------------------
pttype=CGK.PointRange_s) g = CGL.newGridLocation(n, value=CGK.FaceCenter_s) z = [z1, z2] return (T, b, z) (T, b, z) = makeStTree() TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'zone structured uncomplete BC and GridConnect (warning)' diag = False (T, b, z) = makeStTree() pth = CGU.getAllNodesByTypeOrNameList(z[0], ['Zone_t', 'ZoneBC_t', '{BC1_1}'])[0] CGU.removeChildByName(CGU.getNodeByPath(z[0], CGU.getPathAncestor(pth)), '{BC1_1}') pth = CGU.getAllNodesByTypeOrNameList( z[1], ['Zone_t', 'ZoneGridConnectivity_t', 'join2_1'])[0] CGU.removeChildByName(CGU.getNodeByPath(z[1], CGU.getPathAncestor(pth)), 'join2_1') TESTS.append((tag, T, diag)) # ------------------------------------------------------------------------- tag = 'zone structured doubly defined BC and GridConnect (warning)' diag = False (T, b, z) = makeStTree() pth = CGU.getAllNodesByTypeOrNameList(z[0], ['Zone_t', 'ZoneBC_t'])[0] zbc = CGU.getNodeByPath(z[0], pth) n = CGL.newBoundary(zbc, '{BC1_1b}', [[5, 5], [1, 2], [1, 2]], btype=CGK.Null_s,