self.assertTrue(a.isEqual(DataArrayInt([])))
pass
+ def testSwig21SGTUMesh1(self):
+ m=MEDCoupling1GTUMesh.New("m",NORM_PENTA6)
+ m.__repr__() ; m.__str__()
+ self.assertTrue(isinstance(m,MEDCoupling1SGTUMesh))
+ m.setCoords(DataArrayDouble(20,3))
+ m.allocateCells()
+ m.__repr__() ; m.__str__()
+ m.insertNextCell([0,1,2,5,7,2])
+ self.assertEqual(1,m.getNumberOfCells())
+ self.assertTrue(DataArrayInt([6]).isEqual(m.computeNbOfNodesPerCell()))
+ self.assertTrue(DataArrayInt([5]).isEqual(m.computeNbOfFacesPerCell()))
+ m.__repr__() ; m.__str__()
+ m.checkCoherency()
+ m.checkCoherency2()
+ #
+ cm=MEDCouplingCMesh() ; cm.setName("m")
+ arr0=DataArrayDouble(6) ; arr0.iota()
+ arr1=DataArrayDouble([0,1])
+ cm.setCoords(arr0,arr1,arr1) ; um=cm.buildUnstructured()
+ #
+ m=MEDCoupling1SGTUMesh("m",NORM_QUAD4)
+ m.allocateCells(5)
+ self.assertIn(m.getHeapMemorySize(),xrange(80,90))
+ self.assertEqual(m.getNodalConnectivity().getNbOfElemAllocated(),20)
+ m.setCoords(um.getCoords())
+ m.insertNextCell([1,0,6,7])
+ self.assertEqual(1,m.getNumberOfCells())
+ m.insertNextCell([2,1,7,8])
+ m.insertNextCell([3,2,8,9])
+ m.insertNextCell([4,3,9,10])
+ m.insertNextCell([5,4,10,11])
+ self.assertEqual(5,m.getNumberOfCells())
+ self.assertRaises(InterpKernelException,m.insertNextCell,[0,6,7])
+ self.assertRaises(InterpKernelException,m.insertNextCell,[0,6,7,1,2])
+ self.assertEqual(m.getNodalConnectivity().getNbOfElemAllocated(),20)
+ f=m.getMeasureField(ON_CELLS)
+ self.assertEqual(f.getMesh().getHiddenCppPointer(),m.getHiddenCppPointer())
+ self.assertTrue(f.getArray().isUniform(1,1e-14))
+ self.assertEqual(m.getType(),10)
+ self.assertEqual(m.getCellModelEnum(),NORM_QUAD4)
+ mo=MEDCoupling1SGTUMesh("m",NORM_QUAD4) ; mo.setCoords(m.getCoords())
+ mo.setNodalConnectivity(DataArrayInt([1,0,6,7,2,1,7,8,3,2,8,9,4,3,9,10,5,4,10,11]))
+ self.assertTrue(m.isEqual(mo,1e-12))
+ #
+ m1=um.buildDescendingConnectivity()[0]
+ ids=m1.getCellIdsFullyIncludedInNodeIds(DataArrayInt.Range(0,12,1))
+ m1=m1[ids]
+ m1c=m1.convertIntoSingleGeoTypeMesh()
+ self.assertTrue(isinstance(m1c,MEDCoupling1SGTUMesh))
+ self.assertEqual(m1c.getCoords().getHiddenCppPointer(),m.getCoords().getHiddenCppPointer())
+ m1c.checkCoherency2()
+ self.assertTrue(m1c.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,2,1,7,8,3,2,8,9,4,3,9,10,5,4,10,11])))
+ self.assertEqual(20,m1c.getNodalConnectivityLength())
+ self.assertTrue(m.isEqual(m1c,1e-12))
+ m.getNodalConnectivity().setIJ(1,0,1)
+ self.assertTrue(not m.isEqual(m1c,1e-12))
+ m.getNodalConnectivity().setIJ(1,0,0)
+ self.assertTrue(m.isEqual(m1c,1e-12))
+ m1c.setCoords(m.getCoords().deepCpy())
+ self.assertTrue(m.isEqual(m1c,1e-12))
+ m1c.getCoords().setIJ(0,1,0.1)
+ self.assertTrue(not m.isEqual(m1c,1e-12))
+ m1c.getCoords().setIJ(0,1,0)
+ self.assertTrue(m.isEqual(m1c,1e-12))
+ m1c.getCoords().setInfoOnComponent(1,"X")
+ self.assertTrue(not m.isEqual(m1c,1e-12) and m.isEqualWithoutConsideringStr(m1c,1e-12))
+ m.getCoords().setInfoOnComponent(1,"X")
+ self.assertTrue(m.isEqual(m1c,1e-12) and m.isEqualWithoutConsideringStr(m1c,1e-12))
+ m.setName("m2")
+ self.assertTrue(not m.isEqual(m1c,1e-12) and m.isEqualWithoutConsideringStr(m1c,1e-12))
+ #
+ m.checkCoherency() ; m.checkCoherency1() ; m.checkCoherency2()
+ self.assertEqual(m.getMeshDimension(),2)
+ self.assertTrue(m.giveCellsWithType(NORM_QUAD4).isEqual(DataArrayInt([0,1,2,3,4])))
+ self.assertTrue(m.giveCellsWithType(NORM_TRI3).isEqual(DataArrayInt([])))
+ self.assertEqual(m.getNumberOfCellsWithType(NORM_QUAD4),5)
+ self.assertEqual(m.getNumberOfCellsWithType(NORM_TRI3),0)
+ self.assertEqual(m.getTypeOfCell(3),NORM_QUAD4)
+ self.assertRaises(InterpKernelException,m.getTypeOfCell,5)
+ self.assertEqual(m.getAllGeoTypes(),[NORM_QUAD4])
+ self.assertEqual(m.getDistributionOfTypes(),[[NORM_QUAD4,5,0]])
+ ##
+ pfl1=DataArrayInt([1,3,4])
+ a,b,c=m.splitProfilePerType(pfl1)
+ d,e,f=m.buildUnstructured().splitProfilePerType(pfl1)
+ self.assertTrue(a==[[4,3,0]] and len(b)==1 and b[0].isEqual(DataArrayInt([0,1,2])) and len(c)==1 and c[0].getHiddenCppPointer()==pfl1.getHiddenCppPointer())
+ self.assertTrue(a==d and len(b)==1 and b[0].isEqual(e[0]) and len(c)==1 and c[0].isEqual(f[0]))
+ #
+ pfl2=DataArrayInt([0,1,2,3])
+ a,b,c=m.splitProfilePerType(pfl2)
+ d,e,f=m.buildUnstructured().splitProfilePerType(pfl2)
+ self.assertTrue(a==[[4,4,0]] and len(b)==1 and b[0].isEqual(DataArrayInt([0,1,2,3])) and len(c)==1 and c[0].getHiddenCppPointer()==pfl2.getHiddenCppPointer())
+ self.assertTrue(a==d and len(b)==1 and b[0].isEqual(e[0]) and len(c)==1 and c[0].isEqual(f[0]))
+ #
+ pfl3=DataArrayInt([0,1,2,3,4])
+ a,b,c=m.splitProfilePerType(pfl3)
+ d,e,f=m.buildUnstructured().splitProfilePerType(pfl3)
+ self.assertTrue(a==[[4,5,-1]] and len(b)==1 and b[0].isEqual(DataArrayInt([0,1,2,3,4])) and c==[])
+ self.assertTrue(a==d and len(b)==1 and b[0].isEqual(e[0]) and c==[])
+ #
+ invalidPfl=DataArrayInt([1,2,3,4,5])
+ self.assertRaises(InterpKernelException,m.splitProfilePerType,invalidPfl)
+ self.assertRaises(InterpKernelException,m.buildUnstructured().splitProfilePerType,invalidPfl)
+ ##
+ pfl1=DataArrayInt([1,2,3])
+ a=m.checkTypeConsistencyAndContig([NORM_QUAD4,3,0],[pfl1])
+ b=m.buildUnstructured().checkTypeConsistencyAndContig([NORM_QUAD4,3,0],[pfl1])
+ self.assertTrue(a.isEqual(b) and pfl1.getHiddenCppPointer(),a.getHiddenCppPointer())
+ #
+ pfl2=DataArrayInt([0,1,2,3])
+ a=m.checkTypeConsistencyAndContig([NORM_QUAD4,4,0],[pfl2])
+ b=m.buildUnstructured().checkTypeConsistencyAndContig([NORM_QUAD4,4,0],[pfl2])
+ self.assertTrue(a.isEqual(b) and pfl2.getHiddenCppPointer()==a.getHiddenCppPointer())
+ #
+ pfl3=DataArrayInt([0,1,2,3,4])
+ a=m.checkTypeConsistencyAndContig([NORM_QUAD4,4,0],[pfl3])
+ b=m.buildUnstructured().checkTypeConsistencyAndContig([NORM_QUAD4,5,0],[pfl3])
+ self.assertTrue(a.isEqual(b) and pfl3.getHiddenCppPointer()==a.getHiddenCppPointer())
+ #
+ invalidPfl=DataArrayInt([1,2,3,4,5])
+ self.assertRaises(InterpKernelException,m.checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl])
+ #self.assertRaises(InterpKernelException,m.buildUnstructured().checkTypeConsistencyAndContig,[NORM_QUAD4,5,0],[invalidPfl])# should throw debug
+ ##
+ self.assertTrue(DataArrayInt([4,4,4,4,4]).isEqual(m.computeNbOfNodesPerCell()))
+ ##
+ self.assertEqual(m.getNodeIdsOfCell(1),[2,1,7,8])
+ ##
+ self.assertTrue(m.computeIsoBarycenterOfNodesPerCell().isEqual(DataArrayDouble([(0.5,0.5,0),(1.5,0.5,0),(2.5,0.5,0),(3.5,0.5,0),(4.5,0.5,0)]),1e-13))
+ ##
+ ref=m.getCoords().getHiddenCppPointer()
+ mcpy=m.deepCpy() ; mcpy.insertNextCell([1,0,6,7])
+ c=m.getNodalConnectivity().deepCpy()
+ o2n=DataArrayInt([2,0,1,4,3])
+ m.renumberCells(o2n,False)
+ c.rearrange(4) ; c.renumberInPlace(o2n) ; c.rearrange(1)
+ self.assertTrue(c.isEqual(m.getNodalConnectivity()))
+ self.assertEqual(ref,m.getCoords().getHiddenCppPointer())
+ m2=mcpy.mergeMyselfWith(m)
+ self.assertTrue(isinstance(m2,MEDCoupling1SGTUMesh))
+ self.assertEqual(11,m2.getNumberOfCells())
+ self.assertEqual(48,m2.getNumberOfNodes())
+ self.assertTrue(m2.getCoords().isEqual(DataArrayDouble.Aggregate([m.getCoords(),m.getCoords()]),1e-12))
+ self.assertTrue(m2.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,2,1,7,8,3,2,8,9,4,3,9,10,5,4,10,11,1,0,6,7,26,25,31,32,27,26,32,33,25,24,30,31,29,28,34,35,28,27,33,34])))
+ ##
+ mu=m.buildUnstructured()
+ mu.checkCoherency2()
+ self.assertEqual(mu.getCoords().getHiddenCppPointer(),m.getCoords().getHiddenCppPointer())
+ self.assertEqual(2,mu.getMeshDimension())
+ self.assertEqual([NORM_QUAD4],mu.getAllGeoTypes())
+ self.assertTrue(mu.getNodalConnectivity().isEqual(DataArrayInt([4,2,1,7,8,4,3,2,8,9,4,1,0,6,7,4,5,4,10,11,4,4,3,9,10])))
+ self.assertTrue(mu.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25])))
+ ##
+ for typ in [0,1]:
+ mcpy2=m.deepCpy() ; umcpy2=mcpy2.buildUnstructured()
+ ids=mcpy2.simplexize(typ) ; ids2=umcpy2.simplexize(typ)
+ self.assertTrue(ids.isEqual(ids2))
+ mcpy3=umcpy2.convertIntoSingleGeoTypeMesh()
+ self.assertTrue(mcpy2.isEqual(mcpy3,1e-14))
+ pass
+ um1=um.convertIntoSingleGeoTypeMesh()
+ self.assertEqual(8,um1.getNumberOfNodesPerCell())
+ for typ in [PLANAR_FACE_5,PLANAR_FACE_6]:
+ mcpy2=um1.deepCpy() ; umcpy2=mcpy2.buildUnstructured()
+ ids=mcpy2.simplexize(typ) ; ids2=umcpy2.simplexize(typ)
+ self.assertTrue(ids.isEqual(ids2))
+ mcpy3=umcpy2.convertIntoSingleGeoTypeMesh()
+ self.assertTrue(mcpy2.isEqual(mcpy3,1e-14))
+ pass
+ ##
+ self.assertRaises(InterpKernelException,mcpy.mergeMyselfWithOnSameCoords,m)
+ mcpy.tryToShareSameCoords(m,1e-14)
+ m3=mcpy.mergeMyselfWithOnSameCoords(m)
+ self.assertTrue(isinstance(m3,MEDCoupling1SGTUMesh))
+ self.assertEqual(11,m3.getNumberOfCells())
+ self.assertEqual(24,m3.getNumberOfNodes())
+ self.assertEqual(m3.getCoords().getHiddenCppPointer(),mcpy.getCoords().getHiddenCppPointer())
+ self.assertTrue(m3.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,2,1,7,8,3,2,8,9,4,3,9,10,5,4,10,11,1,0,6,7,2,1,7,8,3,2,8,9,1,0,6,7,5,4,10,11,4,3,9,10])))
+ ##
+ ref=mcpy.getCoords().deepCpy()
+ c3=mcpy.getNodalConnectivity()[:]
+ mcpy.getNodalConnectivity().setIJ(int(c3.getIdsEqual(11)),0,24)
+ c2=DataArrayDouble.Aggregate([mcpy.getCoords(),mcpy.getCoords()[11:]])
+ mcpy.setCoords(c2)
+ mcpy.checkCoherency2()
+ a,b=mcpy.getNodeIdsInUse()
+ self.assertEqual(12,b)
+ self.assertTrue(a.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])))
+ ids=mcpy.zipCoordsTraducer()
+ self.assertTrue(ids.isEqual(DataArrayInt([0,1,2,3,4,5,6,7,8,9,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])))
+ self.assertTrue(mcpy.getCoords().isEqual(ref[:12],1e-12))
+ self.assertTrue(mcpy.getNodalConnectivity().isEqual(c3))
+ mcpy.checkCoherency2()
+ ##
+ m4=mcpy[DataArrayInt([0,3,4])]
+ m5=mcpy.buildPartOfMySelfKeepCoords(DataArrayInt([0,3,4]))
+ self.assertTrue(isinstance(m4,MEDCoupling1SGTUMesh))
+ self.assertTrue(m4.isEqual(m5,-1e-14))# < 0 not a bug it proves that coordinates pointer are equal
+ self.assertTrue(m4.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,4,3,9,10,5,4,10,11])))
+ m6=mcpy[::2]
+ self.assertTrue(isinstance(m6,MEDCoupling1SGTUMesh))
+ self.assertTrue(m6.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,3,2,8,9,5,4,10,11])))
+ ##
+ mcpy.setCoords(DataArrayDouble.Aggregate([mcpy.getCoords(),mcpy.getCoords()]))
+ mcpy.checkCoherency2()
+ a,b=mcpy.getReverseNodalConnectivity()
+ self.assertTrue(a.isEqual(DataArrayInt([0,5,0,1,5,1,2,2,3,3,4,4,0,5,0,1,5,1,2,2,3,3,4,4])))
+ self.assertTrue(b.isEqual(DataArrayInt([0,2,5,7,9,11,12,14,17,19,21,23,24,24,24,24,24,24,24,24,24,24,24,24,24])))
+ self.assertTrue(mcpy.fillCellIdsToKeepFromNodeIds([0,1,6,7],False).isEqual(DataArrayInt([0,1,5])))
+ self.assertTrue(mcpy.fillCellIdsToKeepFromNodeIds([0,1,6,7],True).isEqual(DataArrayInt([0,5])))
+ self.assertTrue(mcpy.getCellsInBoundingBox([(0,1),(0,1),(0,1)],1e-12).isEqual(DataArrayInt([0,1,5])))
+ f=mcpy.buildOrthogonalField()
+ self.assertEqual(f.getMesh().getHiddenCppPointer(),mcpy.getHiddenCppPointer())
+ self.assertTrue(f.getArray().isEqual(DataArrayDouble(6*[(0,0,-1)]),1e-12))
+ mcpy.changeSpaceDimension(2)
+ self.assertEqual(1,mcpy.getCellContainingPoint([1.5,0.5],1e-12))
+ pass
+
def setUp(self):
pass
pass