X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FSwig%2FMEDLoaderTest3.py;h=bb5ec84d4312db52600e4630feca9335a8c82afc;hb=cb54d2dfae1264079cd33b157d781e801b1c1964;hp=2682b2dd9baf1aef722ef277754b65919cb07bbb;hpb=281f5b3852ce7e4e71642292f133e0138b27d5e9;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index 2682b2dd9..bb5ec84d4 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -4360,5 +4360,131 @@ class MEDLoaderTest(unittest.TestCase): pass pass + def testMEDFileJoint1(self): + fileName="Pyfile88.med" + coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)]) + coo.setInfoOnComponents(["x [cm]","y [cm]","z [cm]"]) + mm=MEDFileUMesh() + mm.setCoords(coo) + mm.setName("maa1") + mm.setDescription("un maillage") + mm.write(fileName,2) + node_correspond=MEDFileJointCorrespondence(DataArrayInt([1,2,3,4,5,6,7,8])) + cell_correspond=MEDFileJointCorrespondence(DataArrayInt([9,10,11,12]),NORM_TRI3,NORM_TRI3) + one_step_joint=MEDFileJointOneStep() + one_step_joint.pushCorrespondence(cell_correspond) + one_step_joint.pushCorrespondence(node_correspond) + one_joint=MEDFileJoint() + one_joint.pushStep(one_step_joint) + one_joint.setLocalMeshName("maa1") + one_joint.setRemoteMeshName("maa1") + one_joint.setDescription("joint_description") + one_joint.setJointName("joint_1") + one_joint.setDomainNumber(1) + self.assertEqual( one_joint.getLocalMeshName(), "maa1") + self.assertEqual( one_joint.getRemoteMeshName(), "maa1") + self.assertEqual( one_joint.getDescription(), "joint_description") + self.assertEqual( one_joint.getJointName(), "joint_1") + self.assertEqual( one_joint.getDomainNumber(), 1) + joints=MEDFileJoints() + joints.pushJoint(one_joint); + joints.write(fileName,0) + # read back + jointsR=MEDFileJoints(fileName,mm.getName()) + self.assertEqual( jointsR.getNumberOfJoints(), 1 ) + jR = jointsR.getJointAtPos(0) + self.assertTrue( jR.isEqual( one_joint )) + self.assertRaises( InterpKernelException, jointsR.getJointAtPos,1) + self.assertRaises( InterpKernelException, jointsR.destroyJointAtPos,1) + jointsR.destroyJointAtPos(0) + + pass + def testMEDFileJoint2(self): + fileNameWr="Pyfile89.med" + coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)]) + coo.setInfoOnComponents(["x [cm]","y [cm]","z [cm]"]) + mm=MEDFileUMesh() + mm.setCoords(coo) + mm.setName("maa1") + mm.setDescription("un maillage") + node_correspond=MEDFileJointCorrespondence(DataArrayInt([13,14,15,16])) + cell_correspond=MEDFileJointCorrespondence(DataArrayInt([17,18]),NORM_TETRA4,NORM_PENTA6) + one_step_joint=MEDFileJointOneStep() + two_step_joint=MEDFileJointOneStep() + one_joint=MEDFileJoint() + two_joint=MEDFileJoint() + one_step_joint.pushCorrespondence(node_correspond) + one_joint.pushStep(one_step_joint) + two_step_joint.pushCorrespondence(cell_correspond) + two_step_joint.pushCorrespondence(node_correspond) + two_joint.pushStep(two_step_joint) + one_joint.setLocalMeshName("maa1") + one_joint.setRemoteMeshName("maa1") + one_joint.setDescription("joint_description_1") + one_joint.setJointName("joint_1") + one_joint.setDomainNumber(1) + two_joint.setLocalMeshName("maa1") + two_joint.setRemoteMeshName("maa1") + two_joint.setDescription("joint_description_2") + two_joint.setJointName("joint_2") + two_joint.setDomainNumber(2) + joints=MEDFileJoints() + joints.pushJoint(one_joint) + joints.pushJoint(two_joint) + mm.setJoints( joints ) + mm.write(fileNameWr,2) + # + mm=MEDFileMesh.New(fileNameWr) + self.assertEqual( mm.getNumberOfJoints(), 2) + jointsR = mm.getJoints(); + self.assertEqual( jointsR.getMeshName(), mm.getName() ) + self.assertEqual( len( jointsR ), 2 ) + jointR1 = jointsR[0] + jointR2 = jointsR[1] + self.assertFalse( jointR1 is None ) + self.assertFalse( jointR2 is None ) + self.assertTrue( jointR1.isEqual( one_joint )) + self.assertTrue( jointR2.isEqual( two_joint )) + pass + + def testMEDFileJoint1(self): + node_correspond=MEDFileJointCorrespondence(DataArrayInt([1,2,3,4,5,6,7,8])) + cell_correspond=MEDFileJointCorrespondence(DataArrayInt([9,10,11,12]),NORM_TRI3,NORM_TRI3) + cell_correspon2=MEDFileJointCorrespondence(DataArrayInt([9,10,11]),NORM_TRI3,NORM_TRI3) + cell_correspon3=MEDFileJointCorrespondence(DataArrayInt([9,10,11,12]),NORM_TRI3,NORM_QUAD4) + joint1st_1=MEDFileJointOneStep() + joint1st_1.pushCorrespondence(cell_correspond) + joint1st_1.pushCorrespondence(node_correspond) + joint1st_2=MEDFileJointOneStep() + joint1st_2.pushCorrespondence(cell_correspond) + joint1st_2.pushCorrespondence(node_correspond) + joint1st_3=MEDFileJointOneStep() + joint1st_3.pushCorrespondence(node_correspond) + joint1st_3.pushCorrespondence(cell_correspond) + joint1st_4=MEDFileJointOneStep() + joint1st_4.pushCorrespondence(cell_correspond) + joint1st_5=MEDFileJointOneStep() + joint1st_5.pushCorrespondence(cell_correspon2) + joint1st_6=MEDFileJointOneStep() + joint1st_6.pushCorrespondence(cell_correspon3) + self.assertTrue( joint1st_1.isEqual( joint1st_2 )) + self.assertTrue( joint1st_1.isEqual( joint1st_3 )) + self.assertFalse( joint1st_1.isEqual( joint1st_4 )) + self.assertFalse( joint1st_4.isEqual( joint1st_5 )) + self.assertFalse( joint1st_4.isEqual( joint1st_6 )) + one_joint=MEDFileJoint() + one_joint.pushStep(joint1st_1) + one_joint.setLocalMeshName("maa1") + one_joint.setRemoteMeshName("maa2") + one_joint.setDescription("joint_description") + one_joint.setJointName("joint_1") + one_joint.setDomainNumber(1) + self.assertEqual( "maa1", one_joint.getLocalMeshName()) + self.assertEqual( "maa2", one_joint.getRemoteMeshName()) + self.assertEqual( "joint_description", one_joint.getDescription()) + self.assertEqual( 1, one_joint.getDomainNumber()) + self.assertEqual( "joint_1", one_joint.getJointName()) + pass + pass unittest.main()