##
mcpy.setCoords(DataArrayDouble.Aggregate([mcpy.getCoords(),mcpy.getCoords()]))
mcpy.checkCoherency2()
+ ##
+ mcppy=mcpy.deepCpyConnectivityOnly()
+ self.assertTrue(mcppy.isEqual(mcpy,1e-12))
+ self.assertTrue(mcppy.getCoords().getHiddenCppPointer()==mcpy.getCoords().getHiddenCppPointer())
+ self.assertTrue(mcppy.getNodalConnectivity().isEqual(mcpy.getNodalConnectivity()))
+ self.assertTrue(mcppy.getNodalConnectivity().getHiddenCppPointer()!=mcpy.getNodalConnectivity().getHiddenCppPointer())
+ ##
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.assertRaises(InterpKernelException,mcpy.checkGeoEquivalWith,mcpy2,1,1e-12)#fast equal
pass
+ def testSwig21DGTUMesh1(self):
+ a0=DataArrayInt([0,2,3,5,6,8])
+ a1=DataArrayInt([0,4,7,11,14,18,21,25])
+ a2=DataArrayInt([0,1,4,5])
+ self.assertTrue(DataArrayInt.AggregateIndexes([a0,a1,a2]).isEqual(DataArrayInt([0,2,3,5,6,8,12,15,19,22,26,29,33,34,37,38])))
+ self.assertEqual(a1[3:].front(),11)
+ self.assertEqual(a1[4:].convertToDblArr().front(),14.)
+ a1c=DataArrayInt([5,7,1,2, 8,11,0, 5,6,3,12, 1,5,2, 13,12,11,7, 6,1,0, 20,21,19,17])
+ d,e=MEDCouplingUMesh.ExtractFromIndexedArrays2(1,5,2,a1c,a1)
+ self.assertTrue(d.isEqual(DataArrayInt([8,11,0,1,5,2])))
+ self.assertTrue(e.isEqual(DataArrayInt([0,3,6])))
+ #
+ m=MEDCouplingDataForTest.build2DTargetMesh_1()[0,3,4]
+ ref=DataArrayInt([0,3,4,1,6,7,4,3,7,8,5,4])
+ self.assertTrue(m.convertNodalConnectivityToStaticGeoTypeMesh().isEqual(ref))
+ d,e=m.convertNodalConnectivityToDynamicGeoTypeMesh()
+ self.assertTrue(d.isEqual(ref))
+ self.assertTrue(e.isEqual(DataArrayInt.Range(0,13,4)))
+ self.assertTrue(m.fillCellIdsToKeepFromNodeIds(DataArrayInt([6,7]),False).isEqual(DataArrayInt([1,2])))
+ #
+ m=MEDCoupling1GTUMesh.New("m",NORM_POLYHED)
+ self.assertTrue(isinstance(m,MEDCoupling1DGTUMesh))
+ m.__repr__() ; m.__str__()
+ m.setCoords(DataArrayDouble(20,3))
+ m.allocateCells()
+ m.__repr__() ; m.__str__()
+ m.insertNextCell([0,1,2,5,7,2,-1,1,3])
+ self.assertEqual(1,m.getNumberOfCells())
+ self.assertTrue(DataArrayInt([8]).isEqual(m.computeNbOfNodesPerCell()))
+ self.assertTrue(DataArrayInt([2]).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() ; um.convertAllToPoly()
+ um2=um.deepCpyConnectivityOnly()
+ self.assertTrue(um2.isEqual(um,1e-12))
+ self.assertEqual(um2.getCoords().getHiddenCppPointer(),um.getCoords().getHiddenCppPointer())
+ self.assertTrue(um2.getNodalConnectivity().isEqual(um.getNodalConnectivity()))
+ self.assertTrue(um2.getNodalConnectivity().getHiddenCppPointer()!=um.getNodalConnectivity().getHiddenCppPointer())
+ self.assertTrue(um2.getNodalConnectivityIndex().isEqual(um.getNodalConnectivityIndex()))
+ self.assertTrue(um2.getNodalConnectivityIndex().getHiddenCppPointer()!=um.getNodalConnectivityIndex().getHiddenCppPointer())
+ #
+ self.assertRaises(InterpKernelException,MEDCoupling1SGTUMesh.New,"m",NORM_POLYHED)
+ m=MEDCoupling1DGTUMesh("m",NORM_POLYHED)
+ m.allocateCells(5)
+ self.assertEqual(15,m.getNodalConnectivity().getNbOfElemAllocated())
+ self.assertEqual(6,m.getNodalConnectivityIndex().getNbOfElemAllocated())
+ m.setCoords(um.getCoords())
+ m.insertNextCell([1,0,6,7,-1,7,6,1])
+ self.assertEqual(1,m.getNumberOfCells())
+ m.insertNextCell([2,1,7,8,-1,2,1,-1,8,-1,7])
+ m.insertNextCell([3,2,8,9])
+ m.insertNextCell([4,3,9,10,-1,5,3,9])
+ m.insertNextCell([5,4,10,11,-1,11,10,-1,5])
+ m.checkCoherency()
+ m.checkCoherency2()
+ self.assertEqual(5,m.getNumberOfCells())
+ self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,8,19,23,31,40])))
+ self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,-1,7,6,1,2,1,7,8,-1,2,1,-1,8,-1,7,3,2,8,9,4,3,9,10,-1,5,3,9,5,4,10,11,-1,11,10,-1,5])))
+ #
+ m4=m.deepCpy()
+ self.assertTrue(m.isEqual(m4,1e-12))
+ m4.getNodalConnectivity().setIJ(2,0,5)
+ self.assertTrue(not m.isEqual(m4,1e-12))
+ m4.getNodalConnectivity().setIJ(2,0,6)
+ self.assertTrue(m.isEqual(m4,1e-12))
+ m4.getNodalConnectivityIndex().setIJ(2,0,21)
+ self.assertTrue(not m.isEqual(m4,1e-12))
+ m4.getNodalConnectivityIndex().setIJ(2,0,19)
+ self.assertTrue(m.isEqual(m4,1e-12))
+ m4.getCoords().setIJ(10,1,1.1)
+ self.assertTrue(not m.isEqual(m4,1e-12))
+ m4.getCoords().setIJ(10,1,1.)
+ self.assertTrue(m.isEqual(m4,1e-12))
+ m4.getNodalConnectivity().pushBackSilent(7)
+ self.assertTrue(not m.isEqual(m4,1e-12))
+ self.assertEqual(7,m4.getNodalConnectivity().popBackSilent())
+ self.assertTrue(m.isEqual(m4,1e-12))
+ m4.setName("m4")
+ self.assertTrue(not m.isEqual(m4,1e-12))
+ m4.setName("m")
+ self.assertTrue(m.isEqual(m4,1e-12))
+ #
+ self.assertEqual(6,m.getNodalConnectivityIndex().getNbOfElemAllocated())
+ self.assertEqual(60,m.getNodalConnectivity().getNbOfElemAllocated())
+ self.assertTrue(m.computeNbOfNodesPerCell().isEqual(DataArrayInt([7,8,4,7,7])))
+ self.assertTrue(m.computeNbOfFacesPerCell().isEqual(DataArrayInt([2,4,1,2,3])))
+ self.assertEqual(m.getNodeIdsOfCell(1),[2,1,7,8,-1,2,1,-1,8,-1,7])
+ f=m.computeIsoBarycenterOfNodesPerCell()
+ self.assertTrue(DataArrayDouble([(0.5714285714285714,0.5714285714285714,0),(1.5,0.5,0),(2.5,0.5,0),(3.5714285714285712,0.42857142857142855,0),(4.5714285714285712,0.5714285714285714,0)]).isEqual(f,1e-14))
+ mu0=m.buildUnstructured()
+ o2n=[1,2,0,4,3]
+ m2=m.deepCpy()
+ m3=m.deepCpyConnectivityOnly()
+ self.assertTrue(m3.isEqual(m,1e-12))
+ self.assertEqual(m3.getCoords().getHiddenCppPointer(),m.getCoords().getHiddenCppPointer())
+ self.assertTrue(m3.getNodalConnectivity().getHiddenCppPointer()!=m.getNodalConnectivity().getHiddenCppPointer())
+ self.assertTrue(m3.getNodalConnectivity().isEqual(m.getNodalConnectivity()))
+ self.assertTrue(m3.getNodalConnectivityIndex().getHiddenCppPointer()!=m.getNodalConnectivityIndex().getHiddenCppPointer())
+ self.assertTrue(m3.getNodalConnectivityIndex().isEqual(m.getNodalConnectivityIndex()))
+ m.renumberCells(o2n)
+ mu0.renumberCells(o2n)
+ self.assertTrue(mu0.isEqual(m.buildUnstructured(),1e-12))
+ self.assertTrue(m.getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,12,23,32,40])))
+ self.assertTrue(m.getNodalConnectivity().isEqual(DataArrayInt([3,2,8,9,1,0,6,7,-1,7,6,1,2,1,7,8,-1,2,1,-1,8,-1,7,5,4,10,11,-1,11,10,-1,5,4,3,9,10,-1,5,3,9])))
+ #
+ mcpy0=m.buildUnstructured()
+ self.assertTrue(isinstance(mcpy0,MEDCouplingUMesh))
+ self.assertTrue(mcpy0.getNodalConnectivity().isEqual(DataArrayInt([31,3,2,8,9,31,1,0,6,7,-1,7,6,1,31,2,1,7,8,-1,2,1,-1,8,-1,7,31,5,4,10,11,-1,11,10,-1,5,31,4,3,9,10,-1,5,3,9])))
+ self.assertTrue(mcpy0.getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,14,26,36,45])))
+ self.assertEqual(mcpy0.getAllTypes(),[NORM_POLYHED])
+ mcpy0.checkCoherency()
+ mcpy0.checkCoherency2()
+ mcpy1=mcpy0.convertIntoSingleGeoTypeMesh()
+ self.assertTrue(mcpy1.isEqual(m,1e-12))
+ #
+ m_mrg=MEDCoupling1DGTUMesh.Merge1DGTUMeshes([m2,m,m2])
+ self.assertTrue(m_mrg.getNodalConnectivityIndex().isEqual(DataArrayInt([0,8,19,23,31,40,44,52,63,72,80,88,99,103,111,120])))
+ self.assertTrue(m_mrg.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,-1,7,6,1,2,1,7,8,-1,2,1,-1,8,-1,7,3,2,8,9,4,3,9,10,-1,5,3,9,5,4,10,11,-1,11,10,-1,5,27,26,32,33,25,24,30,31,-1,31,30,25,26,25,31,32,-1,26,25,-1,32,-1,31,29,28,34,35,-1,35,34,-1,29,28,27,33,34,-1,29,27,33,49,48,54,55,-1,55,54,49,50,49,55,56,-1,50,49,-1,56,-1,55,51,50,56,57,52,51,57,58,-1,53,51,57,53,52,58,59,-1,59,58,-1,53])))
+ m_mrg2=MEDCoupling1DGTUMesh.Merge1DGTUMeshesOnSameCoords([m3,m,m3])
+ self.assertTrue(m_mrg2.getNodalConnectivityIndex().isEqual(DataArrayInt([0,8,19,23,31,40,44,52,63,72,80,88,99,103,111,120])))
+ self.assertTrue(m_mrg2.getNodalConnectivity().isEqual(DataArrayInt([1,0,6,7,-1,7,6,1,2,1,7,8,-1,2,1,-1,8,-1,7,3,2,8,9,4,3,9,10,-1,5,3,9,5,4,10,11,-1,11,10,-1,5,3,2,8,9,1,0,6,7,-1,7,6,1,2,1,7,8,-1,2,1,-1,8,-1,7,5,4,10,11,-1,11,10,-1,5,4,3,9,10,-1,5,3,9,1,0,6,7,-1,7,6,1,2,1,7,8,-1,2,1,-1,8,-1,7,3,2,8,9,4,3,9,10,-1,5,3,9,5,4,10,11,-1,11,10,-1,5])))
+ a,b=m_mrg2.getReverseNodalConnectivity()
+ self.assertTrue(b.isEqual(DataArrayInt([0,3,15,24,33,39,48,54,66,75,84,93,99,99,99,99,99,99,99,99,99,99,99,99,99])))
+ self.assertTrue(a.isEqual(DataArrayInt([0,6,10,0,0,1,1,6,6,7,7,10,10,11,11,1,1,2,5,7,7,11,11,12,2,3,3,5,9,9,12,13,13,3,4,8,9,13,14,3,4,4,8,8,9,13,14,14,0,0,6,6,10,10,0,0,1,1,6,6,7,7,10,10,11,11,1,1,2,5,7,7,11,11,12,2,3,3,5,9,9,12,13,13,3,4,4,8,8,9,13,14,14,4,4,8,8,14,14])))
+ self.assertTrue(m_mrg2.fillCellIdsToKeepFromNodeIds([7],False).isEqual(DataArrayInt([0,1,6,7,10,11])))
+ self.assertTrue(m_mrg2.fillCellIdsToKeepFromNodeIds([0,1,6,7],True).isEqual(DataArrayInt([0,6,10])))
+ #
+ self.assertTrue(m_mrg2.isPacked())
+ self.assertEqual(120,m_mrg2.getNodalConnectivityIndex().popBackSilent())
+ self.assertEqual(m_mrg2.getNumberOfCells(),14)
+ m_mrg2.checkCoherency2()
+ self.assertTrue(not m_mrg2.isPacked())
+ m_mrg4,b=m_mrg2.copyWithNodalConnectivityPacked()
+ self.assertTrue(not b)
+ m_mrg4.checkCoherency2()
+ self.assertEqual(m_mrg4.getNumberOfCells(),14)
+ self.assertTrue(m_mrg4.getNodalConnectivityIndex().isEqual(m_mrg2.getNodalConnectivityIndex()))
+ self.assertEqual(len(m_mrg4.getNodalConnectivity()),111)
+ self.assertEqual(len(m_mrg2.getNodalConnectivity()),120)
+ self.assertTrue(m_mrg4.getNodalConnectivity().isEqual(m_mrg2.getNodalConnectivity()[:111]))
+ #
+ m0=m_mrg2[:5]
+ m1=m_mrg2[[5,6,7,8,9]]
+ m2=m_mrg2[10:]
+ self.assertTrue(m1.isEqualWithoutConsideringStr(m,1e-12))
+ a,b=m.checkGeoEquivalWith(m0,12,1e-12)
+ self.assertTrue(a.isEqual(DataArrayInt(o2n)))
+ self.assertTrue(b is None)
+ pass
+
def setUp(self):
pass
pass