self.assertTrue(rd.isEqual(DataArrayInt([0,4,0,3,0,2,0,2,0,0,1,2,1,2,1,6,1,5,1,1,2,8,2,7,3,3,4,4,5,5,6,6,7,7,8,8])))
self.assertTrue(rdi.isEqual(DataArrayInt([0,2,4,6,8,9,10,12,14,16,18,19,20,22,24,25,27,28,29,31,33,35,36])))
pass
-
+
+ def testFieldIntIsOnStage2(self):
+ """ Very important test to check that isEqual of MEDCouplingFieldInt is OK !"""
+ m1=MEDCouplingCMesh() ; m1.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
+ m1=m1.buildUnstructured() ; m1.setName("mesh")
+ f1=MEDCouplingFieldInt(ON_CELLS) ; f1.setMesh(m1)
+ arr1=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr1.setInfoOnComponents(["aa","bbb"])
+ f1.setArray(arr1) ; f1.setName("f1") ; f1.setTime(2.,3,4)
+ #
+ m2=MEDCouplingCMesh() ; m2.setCoords(DataArrayDouble([0,1,2,3]),DataArrayDouble([0,1,2,3,4]))
+ m2=m2.buildUnstructured() ; m2.setName("mesh")
+ f2=MEDCouplingFieldInt(ON_CELLS) ; f2.setMesh(m2)
+ arr2=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr2.setInfoOnComponents(["aa","bbb"])
+ f2.setArray(arr2) ; f2.setName("f1") ; f2.setTime(2.,3,4)
+ #
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ f1.getArray()[:]*=2
+ self.assertTrue(not f1.isEqual(f2,1e-12,0.))
+ self.assertTrue(not f1.isEqualWithoutConsideringStr(f2,1e-12,0.))
+ f1.getArray()[:]/=2
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ #
+ f1.setName("F1")
+ self.assertTrue(not f1.isEqual(f2,1e-12,0.))
+ f1.setName("f1")
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ #
+ f1.getArray().setInfoOnComponents(["aa","bbbb"])
+ self.assertTrue(not f1.isEqual(f2,1e-12,0.))
+ self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,0.))
+ f1.getArray().setInfoOnComponents(["aa","bbb"])
+ self.assertTrue(f1.isEqual(f2,1e-12,0.))
+ #
+ f3=f2.deepCopy()
+ self.assertTrue(f1.isEqual(f3,1e-12,0.))
+ #
+ for fd,expected in ((ON_NODES,False),(ON_CELLS,True)):
+ f4=MEDCouplingFieldInt(fd) ; f4.setMesh(m2) ; f4.setTime(2.,3,4)
+ arr4=DataArrayInt([(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13),(14,15),(16,17),(18,19),(20,21),(22,23)]) ; arr4.setInfoOnComponents(["aa","bbb"])
+ f4.setArray(arr4) ; f4.setName("f1")
+ self.assertEqual(f1.isEqual(f4,1e-12,0.),expected)
+ pass
+ pass
+
+ def testDADSymmetry1(self):
+ arr=DataArrayDouble([2,3,4],1,3)
+ res=arr.symmetry3DPlane([0.,0.,0.],[0.,0.,2.])
+ self.assertTrue(res.isEqual(DataArrayDouble([2,3,-4],1,3),1e-14))
+ #
+ res=arr.symmetry3DPlane([-1000,100,-1],[0.,0.,2.])
+ self.assertTrue(res.isEqual(DataArrayDouble([2,3,-6],1,3),1e-14))
+ #
+ res=arr.symmetry3DPlane([0,0,0],[1.,0.,0.])
+ self.assertTrue(res.isEqual(DataArrayDouble([-2,3,4],1,3),1e-14))
+ #
+ res=arr.symmetry3DPlane([0,0,0],[0.,1.,0.])
+ self.assertTrue(res.isEqual(DataArrayDouble([2,-3,4],1,3),1e-14))
+ #
+ res=arr.symmetry3DPlane([0,0,0],[-1.,1.,0.])
+ self.assertTrue(res.isEqual(DataArrayDouble([3,2,4],1,3),1e-14))
+ #
+ plane=[5.,4.,-7.]
+ a=DataArrayDouble(DataArrayDouble.GiveBaseForPlane(plane))
+ self.assertAlmostEqual(DataArrayDouble.Dot(a[0],a[1]).magnitude()[0],0.,13)
+ self.assertAlmostEqual(DataArrayDouble.Dot(a[0],a[2]).magnitude()[0],0.,13)
+ self.assertAlmostEqual(DataArrayDouble.Dot(a[1],a[2]).magnitude()[0],0.,13)
+ coo=DataArrayDouble.Aggregate([10*a[0]+10*a[1],-10*a[0]+10*a[1],-10*a[0]-10*a[1],10*a[0]-10*a[1]])
+ m=MEDCouplingUMesh("",2) ; m.setCoords(coo) ; m.allocateCells()
+ m.insertNextCell(NORM_QUAD4,[0,1,2,3])
+ d,_=m.distanceToPoint(arr)
+ res=arr.symmetry3DPlane([0.,0.,0.],plane) #
+ d2,_=m.distanceToPoint(res)
+ self.assertAlmostEqual(abs(d-d2),0.,12)
+ self.assertAlmostEqual(DataArrayDouble.Dot(res-arr,a[0])[0],0.,12)
+ self.assertAlmostEqual(DataArrayDouble.Dot(res-arr,a[1])[0],0.,12)
+ self.assertAlmostEqual((res-arr).magnitude()[0]-2*d,0.,12)
+ self.assertTrue(res.isEqual(DataArrayDouble([2.666666666666667,3.5333333333333333,3.0666666666666666],1,3),1e-12))
+ pass
+
+ def testExtrudedMeshBuildUnstructured1(self):
+ """ Non reg test. ExtrudedMesh.buildUnstructured used to modify the coordinates of this. It used to lead to an extra amount of memory consumtion. The aim of the test here is to check that buildUnstructured method do not alter the content of the mesh"""
+ arr=DataArrayDouble(11) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr,arr)
+ m=m.buildUnstructured()
+ faces=MEDCouplingCMesh() ; faces.setCoords(arr,arr)
+ faces=faces.buildUnstructured()
+ faces.setCoords(m.getCoords())
+ em=MEDCouplingMappedExtrudedMesh(m,faces,0)
+ self.assertTrue(em.buildUnstructured().isEqual(m,1e-12))
+ self.assertTrue(em.buildUnstructured().isEqual(m,1e-12)) # the bug was here ... buildUnstructured used to modify em ...
+ self.assertTrue(em.buildUnstructured().isEqual(m,1e-12)) # the bug was here ... buildUnstructured used to modify em ...
+ pass
+
+ def testExtrudedMeshFromCMesh1(self):
+ arrX=DataArrayDouble([0,1,2,3]) ; arrY=DataArrayDouble([0,1,2,3,4]) ; arrZ=DataArrayDouble([0,1,2,3,4,5])
+ mesh3D=MEDCouplingCMesh() ; mesh3D.setCoords(arrX,arrY,arrZ)
+ ex=MEDCouplingMappedExtrudedMesh(mesh3D)
+ self.assertTrue(ex.buildUnstructured().isEqual(mesh3D.buildUnstructured(),1e-12))
+ pass
pass
if __name__ == '__main__':