Back to index

salome-med  6.5.0
Public Member Functions
MEDCouplingBasicsTest.MEDCouplingBasicsTest Class Reference

List of all members.

Public Member Functions

def testArray2
def testArray3
def testMesh
def testMeshPointsCloud
def testMeshM1D
def testDeepCopy
def testRevNodal
def testConvertToPolyTypes
def testDescConn2D
def testDescConn3D
def testFindBoundaryNodes
def testBoundaryMesh
def testBuildPartOfMySelf
def testBuildPartOfMySelfNode
def testZipCoords
def testZipConnectivity
def testEqualMesh
def testEqualFieldDouble
def testNatureChecking
def testBuildSubMeshData
def testExtrudedMesh1
def testExtrudedMesh3
def testExtrudedMesh4
def testFindCommonNodes
def testCheckButterflyCells
def testMergeMesh1
def testMergeMeshOnSameCoords1
def testMergeField1
def testFillFromAnalytic
def testFillFromAnalytic2
def testApplyFunc
def testApplyFunc2
def testOperationsOnFields
def testOperationsOnFields2
def testOperationsOnFields3
def testOperationsOnFields4
def testMergeNodesOnField
def testCheckConsecutiveCellTypes
def testRearrange2ConsecutiveCellTypes
def testSplitByType
def testFuseUMeshesOnSameCoords
def testFuseUMeshesOnSameCoords2
def testBuildOrthogonalField
def testGetCellsContainingPoint
def testGetValueOn1
def testCMesh0
def testCMesh1
def testCMesh2
def testScale
def testTryToShareSameCoords
def testFindNodeOnPlane
def testRenumberCells
def testChangeSpaceDimension
def testGaussPointField1
def testGaussPointNEField1
def testCellOrientation1
def testCellOrientation2
def testPolyhedronBarycenter
def testNormL12Integ1D
def testAreaBary2D
def testAreaBary3D
def testRenumberCellsForFields
def testRenumberNodesForFields
def testConvertQuadraticCellsToLinear
def testCheckGeoEquivalWith
def testCheckGeoEquivalWith2
def testCopyTinyStringsFromOnFields
def testTryToShareSameCoordsPermute
def testTryToShareSameCoordsPermute2
def testChangeUnderlyingMesh1
def testGetMaxValue1
def testSubstractInPlaceDM1
def testDotCrossProduct1
def testMinMaxFields1
def testApplyLin1
def testGetIdsInRange1
def testBuildSubPart1
def testDoublyContractedProduct1
def testDeterminant1
def testEigenValues1
def testEigenVectors1
def testInverse1
def testTrace1
def testDeviator1
def testMagnitude1
def testMaxPerTuple1
def testChangeNbOfComponents
def testSortPerTuple1
def testIsEqualWithoutConsideringStr1
def testGetNodeIdsOfCell1
def testGetEdgeRatioField1
def testFillFromAnalytic3
def testFieldDoubleOpEqual1
def testAreaBary3D2
def testGetMeasureFieldCMesh1
def testFieldDoubleZipCoords1
def testFieldDoubleZipConnectivity1
def testDaDoubleRenumber1
def testDaDoubleRenumberAndReduce1
def testDaDoubleRenumberInPlace1
def testDaDoubleRenumberR1
def testDaDoubleRenumberInPlaceR1
def testDaDoubleSelectByTupleId1
def testDaDoubleGetMinMaxValues1
def testFieldDoubleGetMinMaxValues2
def testBuildUnstructuredCMesh1
def testDataArrayIntInvertO2NNO21
def testDoublyContractedProduct1
def testDeterminant1
def testEigenValues1
def testEigenVectors1
def testInverse1
def testTrace1
def testDeviator1
def testMagnitude1
def testMaxPerTuple1
def testChangeNbOfComponents
def testSortPerTuple1
def testKeepSetSelectedComponent1
def testKeepSetSelectedComponent2
def testElementaryDAThrowAndSpecialCases
def testDAIGetIdsEqual1
def testDAIGetIdsEqualList1
def testDAFromNoInterlace1
def testDAToNoInterlace1
def testDAIsUniform1
def testDADFromPolarToCart1
def testDADFromCylToCart1
def testDADFromSpherToCart1
def testUnPolyze1
def testConvertDegeneratedCells1
def testGetNodeIdsNearPoints1
def testFieldCopyTinyAttrFrom1
def testExtrudedMesh5
def testExtrudedMesh6
def testExtrudedMesh7
def testSimplexize1
def testSimplexize2
def testDAMeld1
def testFieldMeld1
def testMergeNodes2
def testMergeField2
def testDAIBuildComplement1
def testDAIBuildUnion1
def testDAIBuildIntersection1
def testDAIDeltaShiftIndex1
def testDaDoubleSelectByTupleIdSafe1
def testAreCellsIncludedIn1
def testSwigErrorProtection1
def testDAIBuildSubstraction1
def testBuildOrthogonalField2
def testSwigErrorProtection2
def testUMInsertNextCell1
def testFieldOperatorDivDiffComp1
def testDARearrange1
def testDARearrange1
def testSwigErrorProtection3
def testDAIBuildPermutationArr1
def testAreCellsIncludedIn2
def testUMeshGetPartBarycenterAndOwner1
def testUMeshGetPartMeasureField1
def testUMeshBuildPartOrthogonalField1
def testUMeshGetTypesOfPart1
def testUMeshKeepCellIdsByType1
def testSwigErrorDaIntSelectByTupleId1
def testSwigErrorRenum
def testSwigGetItem1
def testSwigGetItem2
def testSwigSetItem1
def testSwigSetItem2
def testSwigDADOp
def testSwigDAIOp
def testSwigDAIOp2
def testSwigDAIOp3
def testSwigDADOp3
def testSwigDataArrayIntIterator1
def testSwigDataArrayDoubleIterator1
def testSwigUMeshIterator1
def testSwigUMeshIterator2
def testDAIAggregateMulti1
def testMergeUMeshes2
def testBuild0DMeshFromCoords1
def testDescriptionInMeshTimeUnit1
def testMultiFields1
def testFieldOverTime1
def testDAICheckAndPreparePermutation1
def testDAIChangeSurjectiveFormat1
def testUMeshGetCellIdsLyingOnNodes1
def testUMeshFindCellsIdsOnBoundary1
def testMeshSetTime1
def testApplyFuncTwo1
def testApplyFuncThree1
def testFillFromAnalyticTwo1
def testFillFromAnalyticThree1
def testDAUnitVar1
def testGaussCoordinates1
def testP2Localization1
def testP2Localization2
def testGetValueOn2
def testDAIGetIdsNotEqual1
def testDAIComputeOffsets1
def testUMeshHexagonPrism1
def testDADCheckIsMonotonic
def testCheckCoherencyDeeper1
def testUnPolyze2
def testDACpyFrom1
def testDAITransformWithIndArr1
def testDAIBuildPermArrPerLevel1
def testDAIOperations1
def testEmulateMEDMEMBDC1
def testGetLevArrPerCellTypes1
def testSortCellsInMEDFileFrmt1
def testBuildPartAndReduceNodes1
def testDAITransformWithIndArrR1
def testDAISplitByValueRange1
def testUMeshSplitProfilePerType1
def testDAIBuildExplicitArrByRanges1
def testDAIComputeOffsets2
def testMergeField3
def testGetDistributionOfTypes1
def testNorm2_1
def testNormMax1
def testFindAndCorrectBadOriented3DExtrudedCells1
def testConvertExtrudedPolyhedra1
def testNonRegressionCopyTinyStrings
def testDaDSetPartOfValuesAdv1
def testUMeshBuildSetInstanceFromThis1
def testUMeshMergeMeshesCVW1
def testChangeUnderlyingMeshWithCMesh1
def testDADFindCommonTuples1
def testDABack1
def testDADGetDifferentValues1
def testDAIBuildOld2NewArrayFromSurjectiveFormat2
def testDADIReverse1
def testGetNodeIdsInUse1
def testBuildDescendingConnec2
def testIntersect2DMeshesTmp1
def testFindNodesOnLine1
def testIntersect2DMeshesTmp2
def testBuildPartOfMySelfSafe1
def testIntersect2DMeshesTmp3
def testUMeshTessellate2D1
def testIntersect2DMeshesTmp4
def testGetCellIdsCrossingPlane1
def testBuildSlice3D1
def testBuildSlice3DSurf1
def testDataArrayDoubleAdvSetting1
def testDataArrayIntAdvSetting1
def testBuildDescendingConnec2Of3DMesh1
def testAre2DCellsNotCorrectlyOriented1
def testDataArrayAbs1
def testGetValueOn3
def testGetNodeIdsOfCell2
def testSwigDADOp4
def testSwigDAIOp4
def testSwigDADOp5
def testSwigDADOp6
def testRenumberNodesInConn1
def testComputeNeighborsOfCells1
def testCheckButterflyCellsBug1
def testDataArrayIntRange1
def testSwigUMeshGetItem1
def testSwigGetItem3
def testSwigDADISub1
def testDataArrayDoubleGetMinMaxPerComponent1
def testDataArrayIntGetHashCode1
def testZipConnectivityPol1
def setUp

Detailed Description

Definition at line 26 of file MEDCouplingBasicsTest.py.


Member Function Documentation

Definition at line 10099 of file MEDCouplingBasicsTest.py.

10099 
10100     def setUp(self):
        pass

Definition at line 1078 of file MEDCouplingBasicsTest.py.

01078 
01079     def testApplyFunc(self):
01080         m=MEDCouplingDataForTest.build2DTargetMesh_1();
01081         f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+(2*(x+y))*JVec");
01082         f1.checkCoherency();
01083         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01084         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01085         self.assertEqual(2,f1.getNumberOfComponents());
01086         self.assertEqual(9,f1.getNumberOfTuples());
01087         f1.applyFunc(1,"x+y");
01088         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01089         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01090         self.assertEqual(1,f1.getNumberOfComponents());
01091         self.assertEqual(9,f1.getNumberOfTuples());
01092         values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2]
01093         tmp=f1.getArray().getValues();
01094         self.assertEqual(len(values1),len(tmp))
01095         for i in xrange(len(tmp)):
01096             self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
01097             pass
01098         pass

Definition at line 1099 of file MEDCouplingBasicsTest.py.

01099 
01100     def testApplyFunc2(self):
01101         m=MEDCouplingDataForTest.build2DTargetMesh_1();
01102         f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+2*(x+y)*JVec");
01103         f1.checkCoherency();
01104         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01105         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01106         self.assertEqual(2,f1.getNumberOfComponents());
01107         self.assertEqual(9,f1.getNumberOfTuples());
01108         #
01109         f2=f1.clone(True);
01110         self.assertRaises(InterpKernelException, f2.applyFunc, 1, "a+b+c+d");
01111         self.assertRaises(InterpKernelException, f2.applyFunc, 1, "a/0");
01112         self.assertRaises(InterpKernelException, f2.applyFunc, "a/0");
01113         f2.applyFunc("abs(u)^2.4+2*u");
01114         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01115         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01116         self.assertEqual(2,f1.getNumberOfComponents());
01117         self.assertEqual(9,f1.getNumberOfTuples());
01118         values2=[-0.9065304805418678, -0.85105859001709905, -0.19601892829446504, -0.37898777756476987,
01119                  0.91090317490482353, 2.1853504664669781, -0.19601892829446504, -0.37898777756476987,
01120                  0.91090317490482353, 2.1853504664669781, 2.5765725275664879, 7.6987743736515295,
01121                  0.91090317490482353, 2.1853504664669781, 2.5765725275664879, 7.6987743736515295,
01122                  5.0423700574830965, 17.435300118916864]
01123         tmp=f2.getArray().getValues();
01124         self.assertEqual(len(tmp),len(values2))
01125         for i in xrange(len(tmp)):
01126             self.assertTrue(abs(tmp[i]-values2[i])<1.e-12)
01127             pass
01128         #
01129         f1.applyFunc(1,"x+y");
01130         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01131         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01132         self.assertEqual(1,f1.getNumberOfComponents());
01133         self.assertEqual(9,f1.getNumberOfTuples());
01134         values1=[-1.8,-0.3,1.2,-0.3,1.2,2.7,1.2,2.7,4.2]
01135         tmp=f1.getArray().getValues();
01136         self.assertEqual(len(tmp),len(values1))
01137         for i in xrange(len(tmp)):
01138             self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
01139             pass
01140         pass

Definition at line 7267 of file MEDCouplingBasicsTest.py.

07267 
07268     def testApplyFuncThree1(self):
07269         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
07270         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
07271         f1.setMesh(m1);
07272         #
07273         vals=[1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.]
07274         da=DataArrayDouble.New();
07275         da.setValues(vals,5,3);
07276         f1.setArray(da);
07277         #
07278         vs=3*[None];
07279         vs[0]="x"; vs[1]="Y"; vs[2]="z";
07280         self.assertRaises(InterpKernelException, da.applyFunc3, 1, vs, "y+z");
07281         self.assertRaises(InterpKernelException, da.applyFunc3, 1, vs, "x+Y+z+zz+zzz");
07282         self.assertRaises(InterpKernelException, da.applyFunc3, 1, vs, "x/0");
07283         vs[1]="y";
07284         da2=da.applyFunc3(1,vs,"y+z");
07285         expected1=[32.,34.,36.,38.,40.]
07286         for i in xrange(5):
07287             self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12);
07288             pass
07289         f1.setArray(da);
07290         self.assertEqual(3,f1.getNumberOfComponents());
07291         self.assertEqual(5,f1.getNumberOfTuples());
07292         f1.applyFunc3(1,vs,"y+z");
07293         self.assertEqual(1,f1.getNumberOfComponents());
07294         self.assertEqual(5,f1.getNumberOfTuples());
07295         for i in xrange(5):
07296             self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
07297             pass
07298         pass

Definition at line 7224 of file MEDCouplingBasicsTest.py.

07224 
07225     def testApplyFuncTwo1(self):
07226         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
07227         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
07228         f1.setMesh(m1);
07229         #
07230         vals=[1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.]
07231         da=DataArrayDouble.New();
07232         da.setValues(vals,5,3);
07233         f1.setArray(da);
07234         #
07235         self.assertRaises(InterpKernelException,da.applyFunc2,1,"y+z");
07236         da.setInfoOnComponent(0,"x [m]");
07237         da.setInfoOnComponent(1,"y [mm]");
07238         da.setInfoOnComponent(2,"z [km]");
07239         
07240         self.assertRaises(InterpKernelException, da.applyFunc2, 1, "x+y+zz+zzz");
07241         self.assertRaises(InterpKernelException, da.applyFunc2, 1, "toto(x+y)");
07242         self.assertRaises(InterpKernelException, da.applyFunc2, 1, "x/0");
07243         
07244         da2=da.applyFunc2(1,"y+z");
07245         self.assertEqual(1,da2.getNumberOfComponents());
07246         self.assertEqual(5,da2.getNumberOfTuples());
07247         expected1=[32.,34.,36.,38.,40.]
07248         for i in xrange(5):
07249             self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12);
07250             pass
07251         da2=da.applyFunc(1,"y+z");
07252         expected2=[12.,14.,16.,18.,20.]
07253         for i in xrange(5):
07254             self.assertAlmostEqual(expected2[i],da2.getIJ(0,i),12);
07255             pass
07256         #
07257         self.assertEqual(3,f1.getNumberOfComponents());
07258         self.assertEqual(5,f1.getNumberOfTuples());
07259         f1.applyFunc2(1,"y+z");
07260         self.assertEqual(1,f1.getNumberOfComponents());
07261         self.assertEqual(5,f1.getNumberOfTuples());
07262         for i in xrange(5):
07263             self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
07264             pass
07265         #
07266         pass

Definition at line 2987 of file MEDCouplingBasicsTest.py.

02987 
02988     def testApplyLin1(self):
02989         mesh1=MEDCouplingDataForTest.build2DTargetMesh_3();
02990         f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
02991         f1.setMesh(mesh1);
02992         array=DataArrayDouble.New();
02993         arr=[7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.]
02994         array.setValues(arr,mesh1.getNumberOfCells(),2);
02995         f1.setArray(array);
02996         #
02997         f1.applyLin(2.,3.,0);
02998         expected1=[17.,107.,19.,108.,21.,109.,23.,110.,25.,111.,27.,112.,29.,113.,31.,114.,33.,115.,35.,116.]
02999         for i in xrange(20):
03000             self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),9);
03001             pass
03002         #
03003         arr2=[2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.]
03004         array=DataArrayDouble.New();
03005         array.setValues(arr2,mesh1.getNumberOfCells(),2);
03006         f1.setEndArray(array);
03007         #
03008         f1.applyLin(4.,5.,1);
03009         #
03010         expected2=[17.,433.,19.,437.,21.,441.,23.,445.,25.,449.,27.,453.,29.,457.,31.,461.,33.,465.,35.,469.]
03011         for i in xrange(20):
03012             self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),9);
03013             pass
03014         expected3=[2.,413.,3.,417.,4.,421.,5.,425.,6.,429.,7.,433.,8.,437.,9.,441.,10.,445.,11.,449.]
03015         for i in xrange(20):
03016             self.assertAlmostEqual(expected3[i],f1.getEndArray().getIJ(0,i),9);
03017             pass
03018         #
03019         pass

Definition at line 9176 of file MEDCouplingBasicsTest.py.

09176 
09177     def testAre2DCellsNotCorrectlyOriented1(self):
09178         m1Coords=[1.,1.,-1.,-1.,-1.,-1.,1.,-1.]
09179         m1Conn=[0,3,1,2]
09180         m1=MEDCouplingUMesh.New();
09181         m1.setMeshDimension(2);
09182         m1.allocateCells(1);
09183         m1.insertNextCell(NORM_QUAD4,4,m1Conn[0:4])
09184         m1.finishInsertingCells();
09185         myCoords1=DataArrayDouble.New();
09186         myCoords1.setValues(m1Coords,4,2);
09187         m1.setCoords(myCoords1);
09188         #
09189         vec1=[0.,0.,1.]
09190         for i in xrange(18):
09191             vec2=[3.*cos(pi/9.*i),3.*sin(pi/9.*i)];
09192             m1Cpy=m1.deepCpy();
09193             m1Cpy.translate(vec2);
09194             self.assertRaises(InterpKernelException,m1Cpy.are2DCellsNotCorrectlyOriented,vec1,False);
09195             m1Cpy.changeSpaceDimension(3);
09196             res=m1Cpy.are2DCellsNotCorrectlyOriented(vec1,False)
09197             self.assertEqual([0],res.getValues());
09198             pass
09199         pass

Definition at line 2336 of file MEDCouplingBasicsTest.py.

02336 
02337     def testAreaBary2D(self):
02338         m1=MEDCouplingDataForTest.build2DTargetMesh_3();
02339         f1=m1.getMeasureField(False);
02340         self.assertEqual(10,f1.getArray().getNumberOfTuples());
02341         self.assertEqual(1,f1.getNumberOfComponents());
02342         expected1=[-0.5,-1,-1.5,-0.5,-1,  0.5,1,1.5,0.5,1]
02343         ptr=f1.getArray().getValues();
02344         for i in xrange(10):
02345             self.assertTrue(abs(expected1[i]-ptr[i])<1e-12);
02346             pass
02347         f1=m1.getMeasureField(True);
02348         ptr=f1.getArray().getValues();
02349         for i in xrange(10):
02350             self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12);
02351             pass
02352         f2=m1.getBarycenterAndOwner();
02353         self.assertEqual(10,f2.getNumberOfTuples());
02354         self.assertEqual(2,f2.getNumberOfComponents());
02355         expected2=[0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5,0.5,0.3333333333333333,0.5,0.5,0.5,0.77777777777777777,0.5,0.3333333333333333,0.5,0.5]
02356         ptr=f2.getValues();
02357         for i in xrange(20):
02358             self.assertTrue(abs(expected2[i]-ptr[i])<1e-12);
02359             pass
02360         m1.changeSpaceDimension(3);
02361         f1=m1.getMeasureField(False);
02362         self.assertEqual(10,f1.getArray().getNumberOfTuples());
02363         self.assertEqual(1,f1.getNumberOfComponents());
02364         ptr=f1.getArray().getValues();
02365         for i in xrange(10):
02366             self.assertTrue(abs(abs(expected1[i])-ptr[i])<1e-12);
02367             pass
02368         f2=m1.getBarycenterAndOwner();
02369         self.assertEqual(10,f2.getNumberOfTuples());
02370         self.assertEqual(3,f2.getNumberOfComponents());
02371         ptr=f2.getValues();
02372         expected3=[0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0., 0.5,0.3333333333333333,0.,0.5,0.5,0.,0.5,0.77777777777777777,0.,0.5,0.3333333333333333,0.,0.5,0.5,0.]
02373         for i in xrange(30):
02374             self.assertTrue(abs(expected3[i]-ptr[i])<1e-12);
02375             pass
02376         pass

Definition at line 2377 of file MEDCouplingBasicsTest.py.

02377 
02378     def testAreaBary3D(self):
02379         coords=[ 0.241310763507 , 0.0504777305619 , 0.0682283524903 , 0.252501053866 , -0.0625176732937 , 0.137272639894 ,
02380                  0.152262663601 , 0.241816569527 , 0.133812556197 , 0.18047750211 , -0.0789949051358 , 0.339098173401 ,
02381                  0.151741971857 , 0.238885278571 , 0.137715037333 , 0.242532155481 , -0.0928169086456 , 0.0678043417367 ,
02382                  0.240941965335 , -0.015461491464 , 0.0617186345825 , 0.24127650112 , 0.0499427876717 , 0.0679634099148 ,
02383                  -0.145828917428 , 0.206291632565 , 0.0310071927543 , 0.0125651775307 , 0.266262085828 , 0.105228430543 ,
02384                  -0.0994066533286 , 0.233224271238 , 0.0572213839567 , -0.0951345338317 , 0.234819509426 , 0.0592126284538 ,
02385                  0.136580574205 , -0.205486212579 , 0.0572866072014 , 0.0637270784978 , -0.168886355238 , 0.446614057077 ,
02386                  0.041337157151 , -0.213402568198 , 0.372407095999 , 0.0411601970268 , -0.202387875756 , 0.411334979491 ,
02387                  -0.108355701857 , 0.193636239335 , 0.204886756738 , 0.00639779029829 , 0.155296981517 , 0.252585892979 ,
02388                  0.0262473111702 , -0.112919732543 , 0.424286639249 ,-0.224103052733 , -0.139430015438 , -0.0122352295701 ,
02389                 -0.0312760589481 , -0.274272003594 , 0.0323959636568 , -0.166663422532 , -0.217754445175 , 0.00392109070364 ,
02390                  -0.30586619777 , -0.0475168041091 , -0.0144585228182 , -0.280881480586 , 0.135571293538 , 0.00623923647986 ,
02391                  -0.25548538234 , 0.156819217766 , 0.0645277879769 , -0.131567009284 , 0.184133752309 , 0.206021802753 ,
02392                  -0.196204010965 , 0.151602971681 , 0.212974777736 , -0.183713879463 , 0.0802946639531 , 0.260115662599 ,
02393                  -0.244241178767 , -0.0738873389604 , 0.144590565817 , -0.155804057829 , -0.164892720025 , 0.210613950558 ,
02394                  -0.170950800428 , -0.215099334026 , 0.00610122860092 , -0.30552634869 , -0.0490020791904 , -0.0132786533145 ,
02395                  0.271831011884 , 0.15105657296 , 0.0230534827908 , 0.281919192283 , 0.0898544306288 , -0.0625201489143 ,
02396                  0.260240727276 , -0.0120688706637 , -0.0532316588626 , 0.244947737722 , 0.0197984684293 , 0.0309341209233 ,
02397                  0.23439631578 , 0.229825279875 , 0.0508520585381 , 0.160921316875 , 0.265078502128 , 0.121716560626 ,
02398                  -0.315088694175 , 0.0747700471918 , -0.245836615071 , -0.327728781776 , 0.0857114674649 , -0.239431905957 ,
02399                  -0.308385460634 , 0.145142997084 , -0.149886828433 , 0.0488236045164 , 0.309462801914 , 0.0849169148265 ,
02400                 -0.0244964803395 , 0.33145611751 , -0.0476415818061 , 0.0060567994229 , 0.32418412014 , 0.0367779543812 ,
02401                  -0.0950221448063 , 0.236675326003 , 0.0572594453983 , 0.248723023186 , 0.0886648784791 , -0.176629430538 ,
02402                  0.116796984 , 0.256596599567 , -0.292863523603 , 0.118024552914 , 0.229154257843 , -0.34233232501 ,
02403                  0.217507892549 , -0.0417822335742 , -0.176771782888 , -0.224429321304 , 0.0125595300114 , -0.362064725588 ,
02404                  0.0937301100955 , -0.0500824832657 , -0.299713548444 , -0.244162220397 , 0.0383853931293 , -0.389856984411 ,
02405                  -0.0281989366102 , 0.097392811563 , -0.458244577284 , -0.385010847162 , 0.10122766194 , -0.140052859922 ,
02406                  -0.377936358012 , 0.110875172128 , -0.176207095463 , 0.244483045556 , -0.0991073977045 , 0.0575134372934 ,
02407                 0.262605120167 , -0.100243191645 , -0.0495620806935 , 0.240306880972 , -0.136153701579 , -0.114745281696 ,
02408                  0.215763176129 , -0.0836766059189 , -0.183249640616 , 0.237870396603 , -0.132449578286 , -0.121598854639 ,
02409                  -0.0637683083097 , -0.27921020214 , -0.149112321992 , -0.0856211014977 , -0.2973233473 , -0.0446878139589 ,
02410                  0.104675342288 , -0.0625908305324 , -0.290346256534 , 0.0248264249186 , -0.247797708548 , -0.165830884019 ,
02411                  0.0719302438309 , -0.178468260473 , -0.211432157345 , 0.142871843159 , -0.208769948542 , 0.0454101128246 ,
02412                  0.167803379307 , -0.207851396623 , -0.088802726124 , 0.12868717152 , -0.230920439715 , 0.00760508389036 ,
02413                  -0.0372812069535 , -0.286740286332 , 0.00963701291166 ]
02414         
02415         connN = [ #polyhedron 0
02416             0 , 1 , 3 , 4 , 2 , -1 , 1 , 5 , 6 , 7 , 0 , -1 , 0 , 7 , 8 , 10 , 11 , 9 , 2 , -1 , 1 , 5 , 12 , 14 , 15 , 13 , 3 , -1 , 16 , 9 , 2 , 4 , 17 , -1
02417             , 4 , 3 , 13 , 18 , 17 , -1 , 5 , 6 , 19 , 21 , 20 , 12 , -1 , 6 , 7 , 8 , 23 , 22 , 19 , -1 , 23 , 24 , 10 , 8 , -1 , 25 , 11 , 9 , 16 , -1
02418             , 24 , 26 , 25 , 11 , 10 , -1 , 12 , 14 , 20 , -1 , 27 , 28 , 29 , 15 , 13 , 18 , -1 , 14 , 15 , 29 , 30 , 21 , 20 , -1 , 26 , 27 , 18 , 17 , 16 , 25 , -1
02419             , 22 , 19 , 21 , 30 , 31 , -1 , 22 , 31 , 28 , 27 , 26 , 24 , 23 , -1 , 31 , 30 , 29 , 28,
02420             # polyhedron 1
02421             0 , 7 , 8 , 10 , 11 , 9 , 2 , -1 , 32 , 0 , 7 , 35 , 34 , 33 , -1 , 32 , 0 , 2 , 37 , 36 , -1 , 35 , 7 , 8 , 40 , 39 , 38 , -1
02422             , 2 , 37 , 41 , 9 , -1 , 40 , 8 , 10 , 44 , 43 , 42 , -1 , 41 , 9 , 11 , 44 , 43 , -1 , 44 , 11 , 10 , -1 , 32 , 33 , 45 , 47 , 46 , 36 , -1
02423             , 33 , 34 , 48 , 45 , -1 , 35 , 34 , 48 , 50 , 49 , 38 , -1 , 41 , 43 , 42 , 46 , 36 , 37 , -1 , 38 , 39 , 51 , 49 , -1
02424             , 39 , 40 , 42 , 46 , 47 , 52 , 51 , -1 , 45 , 47 , 52 , 50 , 48 , -1 , 52 , 51 , 49 , 50,
02425             # polyhedron 2
02426             6 , 7 , 8 , 23 , 22 , 19 , -1 , 6 , 35 , 7 , -1 , 6 , 35 , 38 , 19 , -1 , 35 , 7 , 8 , 40 , 39 , 38 , -1 , 53 , 22 , 19 , 38 , 39 , 54 , -1
02427             , 23 , 53 , 54 , 40 , 8 , -1 , 53 , 22 , 23 , -1 , 39 , 54 , 40,
02428             # polyhedron 3
02429             35 , 34 , 48 , 50 , 49 , 38 , -1 , 6 , 35 , 34 , 56 , 55 , 5 , -1 , 6 , 35 , 38 , 19 , -1 , 34 , 56 , 57 , 59 , 58 , 48 , -1
02430             , 60 , 61 , 21 , 19 , 38 , 49 , -1 , 62 , 50 , 48 , 58 , -1 , 60 , 63 , 64 , 62 , 50 , 49 , -1 , 5 , 6 , 19 , 21 , 20 , 12 , -1
02431             , 55 , 5 , 12 , 65 , -1 , 66 , 67 , 65 , 55 , 56 , 57 , -1 , 63 , 66 , 57 , 59 , 64 , -1 , 64 , 62 , 58 , 59 , -1
02432             , 60 , 63 , 66 , 67 , 68 , 61 , -1 , 61 , 68 , 20 , 21 , -1 , 67 , 68 , 20 , 12 , 65]
02433         
02434         barys = [ -0.0165220465527 , -0.0190922868195 , 0.158882733414 ,
02435                   0.0287618656076 , 0.135874379934 , -0.14601588119 ,
02436                   -0.147128055553 , 0.0465995097041 , -0.049391174453 ,
02437                   -0.00142506732317 , -0.0996953090351 , -0.115159183132 ]
02438         meshN=MEDCouplingUMesh.New();
02439         meshN.setName("ForBary");
02440         meshN.setMeshDimension(3);
02441         meshN.allocateCells(4);
02442         meshN.insertNextCell(NORM_POLYHED,113,connN);
02443         meshN.insertNextCell(NORM_POLYHED,99,connN[113:]);
02444         meshN.insertNextCell(NORM_POLYHED,43,connN[212:]);
02445         meshN.insertNextCell(NORM_POLYHED,92,connN[255:]);
02446         meshN.finishInsertingCells();
02447         myCoords=DataArrayDouble.New();
02448         myCoords.setValues(coords,69,3);
02449         meshN.setCoords(myCoords);
02450         meshN.checkCoherency();
02451         res1=meshN.arePolyhedronsNotCorrectlyOriented();
02452         meshN.orientCorrectlyPolyhedrons();
02453         res1=meshN.arePolyhedronsNotCorrectlyOriented();
02454         self.assertTrue(len(res1)==0);
02455         #
02456         da=meshN.getBarycenterAndOwner();
02457         self.assertEqual(4,da.getNumberOfTuples());
02458         self.assertEqual(3,da.getNumberOfComponents());
02459         daPtr=da.getValues();
02460         for i in xrange(12):
02461             self.assertTrue(abs(barys[i]-daPtr[i])<1e-12);
02462             pass
02463         pass

Definition at line 3780 of file MEDCouplingBasicsTest.py.

03780 
03781     def testAreaBary3D2(self):
03782         coordsForHexa8=[-75.45749305371, 180.95495078401, 39.515472018008,
03783                         -9.755591679144, 23.394927935279, 5.108794294848,
03784                         14.337630157832, 61.705351002702, 160.42422501908,
03785                         -27.273893776752, 167.567731083961, 192.830034145464,
03786                         99.857193154796,264.499264735586,-8.287335493412,
03787                         144.939882761126,156.38626563134,-31.896173894226,
03788                         161.34096835726,182.4654895809,73.832387065572,
03789                         132.680430393685,255.37973247196,96.15235602819];
03790         volHexa8=3258520.29637466;
03791         baryHexa8=[43.925705821778, 155.31893955289, 65.874418109644]
03792         
03793         coordsForPenta6=[-68.199829618726,178.938498373416,62.608505919588,
03794                          8.461744647847,76.653979804423,165.00018874933,
03795                          -27.273893776752,167.567731083961,192.830034145464,
03796                          106.586501038965,262.629609408327,13.124533008813,
03797                          155.465082847275,197.414118382622,78.408350795821,
03798                          132.680430393685,255.37973247196,96.15235602819];
03799         volPenta6=944849.868507338;
03800         baryPenta6=[39.631002313543,182.692711783428,106.98540473964]
03801         
03802         coordsForPyra5=[132.680430393685,255.37973247196,96.15235602819,
03803                         -27.273893776752,167.567731083961,192.830034145464,
03804                         8.461744647847,76.653979804423,165.00018874933,
03805                         155.465082847275,197.414118382622,78.408350795821,
03806                         -68.199829618726,178.938498373416,62.608505919588];
03807         volPyra5=756943.92980254;
03808         baryPyra5=[29.204294116618,172.540129749156,118.01035951483]
03809         mesh=MEDCouplingUMesh.New("Bary3D2",3);
03810         coo=DataArrayDouble.New();
03811         tmp=coordsForHexa8+coordsForPenta6+coordsForPyra5
03812         coo.setValues(tmp,19,3);
03813         mesh.setCoords(coo);
03814         #
03815         tmpConn=[0,1,2,3,4,5,6,7]
03816         mesh.allocateCells(3);
03817         self.assertRaises(InterpKernelException,mesh.insertNextCell,NORM_HEXA8,9,tmpConn[0:8])
03818         mesh.insertNextCell(NORM_HEXA8,tmpConn[0:8])
03819         mesh.insertNextCell(NORM_PENTA6,6,[i+8 for i in tmpConn])
03820         mesh.insertNextCell(NORM_PYRA5,5,[i+14 for i in tmpConn])
03821         mesh.finishInsertingCells();
03822         mesh.checkCoherency();
03823         mesh.mergeNodes(1e-7)
03824         self.assertEqual(12,mesh.getNumberOfNodes());
03825         vols=mesh.getMeasureField(True);
03826         self.assertEqual(3,vols.getNumberOfTuples());
03827         self.assertEqual(1,vols.getNumberOfComponents());
03828         self.assertAlmostEqual(volHexa8,vols.getIJ(0,0),6);
03829         self.assertAlmostEqual(volPenta6,vols.getIJ(1,0),7);
03830         self.assertAlmostEqual(volPyra5,vols.getIJ(2,0),7);
03831         bary=mesh.getBarycenterAndOwner();
03832         self.assertEqual(3,bary.getNumberOfTuples());
03833         self.assertEqual(3,bary.getNumberOfComponents());
03834         self.assertAlmostEqual(baryHexa8[0],bary.getIJ(0,0),11);
03835         self.assertAlmostEqual(baryHexa8[1],bary.getIJ(0,1),11);
03836         self.assertAlmostEqual(baryHexa8[2],bary.getIJ(0,2),11);
03837         self.assertAlmostEqual(baryPenta6[0],bary.getIJ(1,0),11);
03838         self.assertAlmostEqual(baryPenta6[1],bary.getIJ(1,1),11);
03839         self.assertAlmostEqual(baryPenta6[2],bary.getIJ(1,2),11);
03840         self.assertAlmostEqual(baryPyra5[0],bary.getIJ(2,0),11);
03841         self.assertAlmostEqual(baryPyra5[1],bary.getIJ(2,1),11);
03842         self.assertAlmostEqual(baryPyra5[2],bary.getIJ(2,2),11);
03843         pass

Definition at line 5892 of file MEDCouplingBasicsTest.py.

05892 
05893     def testAreCellsIncludedIn1(self):
05894         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
05895         pt=[1,3]
05896         m2=m.buildPartOfMySelf(pt,True);
05897         ret,tmp=m.areCellsIncludedIn(m2,0)
05898         self.assertTrue(ret);
05899         self.assertEqual(2,tmp.getNumberOfTuples());
05900         self.assertEqual(1,tmp.getNumberOfComponents());
05901         self.assertEqual(pt[0],tmp.getIJ(0,0));
05902         self.assertEqual(pt[1],tmp.getIJ(0,1));
05903         ret,tmp=m2.areCellsIncludedIn(m,0)
05904         self.assertTrue(not ret);
05905         pass

Definition at line 6175 of file MEDCouplingBasicsTest.py.

06175 
06176     def testAreCellsIncludedIn2(self):
06177         myName="Vitoo";
06178         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
06179         m2=m.buildPartOfMySelf([],True);
06180         self.assertEqual(0,m2.getNumberOfCells());
06181         self.assertEqual(3,m2.getSpaceDimension());
06182         self.assertEqual(2,m2.getMeshDimension());
06183         m2.setName(myName);
06184         test,tmp=m.areCellsIncludedIn(m2,0)
06185         self.assertTrue(test);
06186         self.assertEqual(myName,tmp.getName());
06187         self.assertEqual(0,tmp.getNumberOfTuples())
06188         self.assertEqual(1,tmp.getNumberOfComponents())
06189         pass

Definition at line 27 of file MEDCouplingBasicsTest.py.

00027 
00028     def testArray2(self):
00029         arr=DataArrayDouble.New()
00030         arr.setValues([12.,11.,10.,9.,8.,7.,6.,5.,4.,3.,2.,1.],3,4)
00031         arr.setInfoOnComponent(0,"ggg");
00032         arr.setInfoOnComponent(1,"hhhh");
00033         arr.setInfoOnComponent(2,"jj");
00034         arr.setInfoOnComponent(3,"kkkkkk");
00035         arr2=arr.convertToIntArr();
00036         arr3=arr2.convertToDblArr();
00037         self.assertTrue(arr.isEqual(arr3,1e-14))
00038         pass

Definition at line 39 of file MEDCouplingBasicsTest.py.

00039 
00040     def testArray3(self):
00041         arr1=DataArrayInt.New();
00042         arr1Ref=[0,10,1,11,2,12,3,13,4,14,5,15,6,16]
00043         arr1.setValues(arr1Ref,7,2);
00044         self.assertEqual(7,arr1.getNumberOfTuples());
00045         self.assertEqual(2,arr1.getNumberOfComponents());
00046         self.assertEqual(arr1Ref,list(arr1.getValues()));
00047         arr2=arr1.substr(3);
00048         self.assertEqual(4,arr2.getNumberOfTuples());
00049         self.assertEqual(2,arr2.getNumberOfComponents());
00050         self.assertEqual(arr1Ref[6:],list(arr2.getValues()));
00051         arr3=arr1.substr(2,5);
00052         self.assertEqual(3,arr3.getNumberOfTuples());
00053         self.assertEqual(2,arr3.getNumberOfComponents());
00054         self.assertEqual(arr1Ref[4:10],list(arr3.getValues()));
00055         #
00056         arr4=DataArrayDouble.New();
00057         arr4Ref=[0.8,10.8,1.9,11.9,2.1,12.1,3.2,13.2,4.3,14.3,5.4,15.4,6.5,16.5]
00058         arr4.setValues(arr4Ref,7,2);
00059         self.assertEqual(7,arr4.getNumberOfTuples());
00060         self.assertEqual(2,arr4.getNumberOfComponents());
00061         tmp=arr4.getValues()
00062         for i in xrange(14):
00063             self.assertTrue(abs(arr4Ref[i]-tmp[i])<1e-14);
00064             pass
00065         arr5=arr4.substr(3);
00066         self.assertEqual(4,arr5.getNumberOfTuples());
00067         self.assertEqual(2,arr5.getNumberOfComponents());
00068         tmp=arr5.getValues()
00069         for i in xrange(8):
00070             self.assertTrue(abs(arr4Ref[6+i]-tmp[i])<1e-14);
00071             pass
00072         arr6=arr4.substr(2,5);
00073         self.assertEqual(3,arr6.getNumberOfTuples());
00074         self.assertEqual(2,arr6.getNumberOfComponents());
00075         tmp=arr6.getValues()
00076         for i in xrange(6):
00077             self.assertTrue(abs(arr4Ref[4+i]-tmp[i])<1e-14);
00078             pass
00079         pass

Definition at line 352 of file MEDCouplingBasicsTest.py.

00352 
00353     def testBoundaryMesh(self):
00354         mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
00355         mesh2=mesh.buildBoundaryMesh(False);
00356         self.assertEqual(24,mesh2.getNumberOfCells());
00357         self.assertEqual(26,mesh2.getNumberOfNodes());
00358         pass

Definition at line 6974 of file MEDCouplingBasicsTest.py.

06974 
06975     def testBuild0DMeshFromCoords1(self):
06976         sourceCoords=[-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.]
06977         coo=DataArrayDouble.New();
06978         coo.setValues(sourceCoords,4,3);
06979         coo.setName("My0D");
06980         m=MEDCouplingUMesh.Build0DMeshFromCoords(coo);
06981         m.checkCoherency();
06982         self.assertEqual(4,m.getNumberOfNodes());
06983         self.assertEqual(4,m.getNumberOfCells());
06984         self.assertEqual(3,m.getSpaceDimension());
06985         self.assertEqual(0,m.getMeshDimension());
06986         types1=m.getAllTypes();
06987         self.assertEqual([NORM_POINT1],types1);
06988         for i in xrange(4):
06989             conn=m.getNodeIdsOfCell(i);
06990             self.assertEqual([i],conn);
06991             self.assertTrue(NORM_POINT1==m.getTypeOfCell(i));
06992             pass
06993         self.assertEqual(m.getName(),"My0D");
06994         pass

Definition at line 8569 of file MEDCouplingBasicsTest.py.

08569 
08570     def testBuildDescendingConnec2(self):
08571         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
08572         #
08573         mesh2,desc,descIndx,revDesc,revDescIndx=mesh.buildDescendingConnectivity2();
08574         mesh2.checkCoherency();
08575         self.assertEqual(1,mesh2.getMeshDimension());
08576         self.assertEqual(13,mesh2.getNumberOfCells());
08577         self.assertEqual(14,revDescIndx.getNbOfElems()); self.assertEqual(14,revDescIndx.getNumberOfTuples());
08578         self.assertEqual(6,descIndx.getNbOfElems()); self.assertEqual(6,descIndx.getNumberOfTuples());
08579         self.assertEqual(18,desc.getNbOfElems()); self.assertEqual(18,desc.getNumberOfTuples());
08580         self.assertEqual(18,revDesc.getNbOfElems()); self.assertEqual(18,revDesc.getNumberOfTuples());
08581         expected1=[1,2,3,4,-3,5,6, 7,8,-5,9,10,-2,11, 12,13,-7,-10]
08582         self.assertEqual(expected1,desc.getValues());
08583         expected2=[0,4,7,10,14,18]
08584         self.assertEqual(expected2,descIndx.getValues());
08585         expected3=[0,1,3,5,6,8,9,11,12,13,15,16,17,18]
08586         self.assertEqual(expected3,revDescIndx.getValues());
08587         expected4=[0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4]
08588         self.assertEqual(expected4,revDesc.getValues());
08589         conn=mesh2.getNodalConnectivity();
08590         connIndex=mesh2.getNodalConnectivityIndex();
08591         expected5=[0,3,6,9,12,15,18,21,24,27,30,33,36,39]
08592         self.assertEqual(expected5,connIndex.getValues());
08593         expected6=[1, 0, 3, 1, 3, 4, 1, 4, 1, 1, 1, 0, 1, 4, 2, 1, 2, 1, 1, 4, 5, 1, 5, 2, 1, 6, 7, 1, 7, 4, 1, 3, 6, 1, 7, 8, 1, 8, 5]
08594         self.assertEqual(expected6,conn.getValues());
08595         pass

Definition at line 9149 of file MEDCouplingBasicsTest.py.

09149 
09150     def testBuildDescendingConnec2Of3DMesh1(self):
09151         mesh=MEDCouplingDataForTest.build3DSourceMesh_1();
09152         #
09153         mesh2,desc,descIndx,revDesc,revDescIndx=mesh.buildDescendingConnectivity2();
09154         mesh2.checkCoherency();
09155         self.assertEqual(2,mesh2.getMeshDimension());
09156         self.assertEqual(30,mesh2.getNumberOfCells());
09157         self.assertEqual(31,revDescIndx.getNbOfElems()); self.assertEqual(31,revDescIndx.getNumberOfTuples());
09158         self.assertEqual(13,descIndx.getNbOfElems()); self.assertEqual(13,descIndx.getNumberOfTuples());
09159         self.assertEqual(48,desc.getNbOfElems()); self.assertEqual(48,desc.getNumberOfTuples());
09160         self.assertEqual(48,revDesc.getNbOfElems()); self.assertEqual(48,revDesc.getNumberOfTuples());
09161         expected1=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,-10,15,-5,-13,16,17,-14,18,-4,19,-2,20,21,22,23,24,25,-11,26,-1,-12,-25,-22,27,28,-7,-20,-24,29,-16,-18,30,-8,-28]
09162         self.assertEqual(expected1,desc.getValues());
09163         expected2=[0,4,8,12,16,20,24,28,32,36,40,44,48]
09164         self.assertEqual(expected2,descIndx.getValues());
09165         expected3=[0,2,4,5,7,9,10,12,14,15,17,19,21,23,25,26,28,29,31,32,34,35,37,38,40,42,43,44,46,47,48]
09166         self.assertEqual(expected3,revDescIndx.getValues());
09167         expected4=[0,8,0,6,0,0,5,1,4,1,1,9,1,11,2,2,3,2,7,2,8,3,4,3,5,3,4,10,4,5,11,5,6,10,6,6,9,7,7,10,7,8,8,9,9,11,10,11]
09168         self.assertEqual(expected4,revDesc.getValues());
09169         conn=mesh2.getNodalConnectivity();
09170         connIndex=mesh2.getNodalConnectivityIndex();
09171         expected5=[0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120]
09172         self.assertEqual(expected5,connIndex.getValues());
09173         expected6=[3,8,1,7,3,8,3,1,3,1,3,7,3,7,3,8,3,6,0,8,3,6,2,0,3,0,2,8,3,8,2,6,3,7,4,5,3,7,8,4,3,4,8,5,3,5,8,7,3,6,8,4,3,6,7,8,3,4,7,6,3,8,4,0,3,0,4,6,3,6,3,8,3,7,3,6,3,8,0,1,3,1,0,3,3,3,0,8,3,4,1,5,3,4,8,1,3,1,8,5,3,1,7,5,3,0,2,3,3,3,2,8,3,1,4,0,3,3,2,6]
09174         self.assertEqual(expected6,conn.getValues());
09175         pass

Definition at line 1508 of file MEDCouplingBasicsTest.py.

01508 
01509     def testBuildOrthogonalField(self):
01510         targetMesh=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
01511         field=targetMesh.buildOrthogonalField();
01512         expected=[0.70710678118654746,0.,-0.70710678118654746]
01513         self.assertEqual(5,field.getNumberOfTuples());
01514         self.assertEqual(3,field.getNumberOfComponents());
01515         vals=field.getArray().getValues();
01516         for i in xrange(15):
01517             self.assertTrue(abs(expected[i%3]-vals[i])<1e-12);
01518         # testing
01519         targetCoords=[0.,0.,0.,0.5,0.,0.5,1.,0.,1.,0.,1.,0.]
01520         targetConn=[0,1,2,3]
01521         targetMesh=MEDCouplingUMesh.New();
01522         targetMesh.setMeshDimension(2);
01523         targetMesh.allocateCells(1);
01524         targetMesh.insertNextCell(NORM_QUAD4,targetConn[0:4])
01525         targetMesh.finishInsertingCells();
01526         myCoords=DataArrayDouble.New();
01527         myCoords.setValues(targetCoords,4,3);
01528         targetMesh.setCoords(myCoords);
01529         field=targetMesh.buildOrthogonalField();
01530         self.assertEqual(1,field.getNumberOfTuples());
01531         self.assertEqual(3,field.getNumberOfComponents());
01532         vals=field.getArray().getValues();
01533         self.assertTrue(abs(-0.70710678118654746-vals[0])<1e-12);
01534         self.assertTrue(abs(0.-vals[1])<1e-12);
01535         self.assertTrue(abs(0.70710678118654746-vals[2])<1e-12);
01536         pass

Definition at line 5933 of file MEDCouplingBasicsTest.py.

05933 
05934     def testBuildOrthogonalField2(self):
05935         m=MEDCouplingDataForTest.build2DTargetMesh_1();
05936         d1=DataArrayInt.New();
05937         d2=DataArrayInt.New();
05938         d3=DataArrayInt.New();
05939         d4=DataArrayInt.New();
05940         m1=m.buildDescendingConnectivity(d1,d2,d3,d4);
05941         #
05942         f1=m1.buildOrthogonalField();
05943         da1=f1.getArray();
05944         self.assertEqual(2,da1.getNumberOfComponents());
05945         self.assertEqual(13,da1.getNumberOfTuples());
05946         #
05947         expected1=[-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.];
05948         for i in xrange(26):
05949             self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),14);
05950             pass
05951         pass

Definition at line 8008 of file MEDCouplingBasicsTest.py.

08008 
08009     def testBuildPartAndReduceNodes1(self):
08010         m=MEDCouplingDataForTest.build2DTargetMesh_1();
08011         arr=[1,0]
08012         m2,da=m.buildPartAndReduceNodes(arr);
08013         self.assertEqual(5,m2.getNumberOfNodes());
08014         self.assertEqual(2,m2.getNumberOfCells());
08015         f=m2.getMeasureField(True);
08016         self.assertAlmostEqual(0.125,f.getArray().getIJ(0,0),12);
08017         self.assertAlmostEqual(0.25,f.getArray().getIJ(1,0),12);
08018         #
08019         arr2=DataArrayInt.New()
08020         arr2.setValues(arr,2,1)
08021         m2,da=m.buildPartAndReduceNodes(arr2);
08022         self.assertEqual(5,m2.getNumberOfNodes());
08023         self.assertEqual(2,m2.getNumberOfCells());
08024         f=m2.getMeasureField(True);
08025         self.assertAlmostEqual(0.125,f.getArray().getIJ(0,0),12);
08026         self.assertAlmostEqual(0.25,f.getArray().getIJ(1,0),12);
08027         pass

Definition at line 359 of file MEDCouplingBasicsTest.py.

00359 
00360     def testBuildPartOfMySelf(self):
00361         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
00362         mesh.setName("Toto");
00363         tab1=[0,4]
00364         tab2=[0,2,3]
00365         #
00366         subMesh=mesh.buildPart(tab1)
00367         self.assertTrue(isinstance(subMesh,MEDCouplingUMesh))
00368         subMesh=mesh.buildPartOfMySelf(tab1,True);
00369         self.assertTrue(isinstance(subMesh,MEDCouplingUMesh))
00370         name=subMesh.getName();
00371         self.assertEqual(2,len(mesh.getAllTypes()));
00372         self.assertEqual(NORM_TRI3,mesh.getAllTypes()[0]);
00373         self.assertEqual(NORM_QUAD4,mesh.getAllTypes()[1]);
00374         self.assertEqual(1,len(subMesh.getAllTypes()));
00375         self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]);
00376         self.assertEqual(name,"PartOf_Toto");
00377         self.assertEqual(2,subMesh.getNumberOfCells());
00378         subConn=[4,0,3,4,1,4,7,8,5,4];
00379         subConnIndex=[0,5,10];
00380         self.assertEqual(10,subMesh.getNodalConnectivity().getNbOfElems());
00381         self.assertEqual(3,subMesh.getNodalConnectivityIndex().getNbOfElems());
00382         self.assertEqual(subConn[0:10],list(subMesh.getNodalConnectivity().getValues()));
00383         self.assertEqual(subConnIndex[0:3],list(subMesh.getNodalConnectivityIndex().getValues()));
00384         #
00385         subMesh=mesh.buildPartOfMySelf(tab2[0:3],True);
00386         self.assertTrue(isinstance(subMesh,MEDCouplingUMesh));
00387         name=subMesh.getName();
00388         self.assertEqual(2,len(subMesh.getAllTypes()));
00389         self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]);
00390         self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]);
00391         self.assertEqual(name,"PartOf_Toto");
00392         self.assertEqual(3,subMesh.getNumberOfCells());
00393         subConn2=[4,0,3,4,1,3,4,5,2,4,6,7,4,3]
00394         subConnIndex2=[0,5,9,14]
00395         self.assertEqual(14,subMesh.getNodalConnectivity().getNbOfElems());
00396         self.assertEqual(4,subMesh.getNodalConnectivityIndex().getNbOfElems());
00397         self.assertEqual(subConn2[0:14],list(subMesh.getNodalConnectivity().getValues()));
00398         self.assertEqual(subConnIndex2[0:4],list(subMesh.getNodalConnectivityIndex().getValues()));
00399         dd=DataArrayInt.New()
00400         dd.alloc(3,1)
00401         dd.iota(0)
00402         dd.setName("coucou")
00403         subMesh=subMesh.buildPartOfMySelf(dd,True);
00404         self.assertEqual("coucou",subMesh.getName());
00405         pass
    

Definition at line 406 of file MEDCouplingBasicsTest.py.

00406 
00407     def testBuildPartOfMySelfNode(self):
00408         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
00409         tab1=[5,7,8,4]
00410         subMesh=mesh.buildPartOfMySelfNode(tab1[0:4],True);
00411         self.assertTrue(isinstance(subMesh,MEDCouplingUMesh))
00412         self.assertEqual(1,len(subMesh.getAllTypes()));
00413         self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[0]);
00414         self.assertEqual(1,subMesh.getNumberOfCells());
00415         self.assertEqual(5,subMesh.getNodalConnectivity().getNbOfElems());
00416         self.assertEqual(2,subMesh.getNodalConnectivityIndex().getNbOfElems());
00417         subConn=[4,7,8,5,4]
00418         subConnIndex=[0,5]
00419         self.assertEqual(subConn[0:5],list(subMesh.getNodalConnectivity().getValues()));
00420         self.assertEqual(subConnIndex[0:2],list(subMesh.getNodalConnectivityIndex().getValues()));
00421         #
00422         ddd=DataArrayInt.New()
00423         ddd.setValues(tab1[0:2],2,1)
00424         ddd.setName("ddd")
00425         subMesh=mesh.buildPartOfMySelfNode(ddd,False);
00426         self.assertEqual("ddd",subMesh.getName())
00427         self.assertTrue(isinstance(subMesh,MEDCouplingUMesh))
00428         self.assertEqual(2,len(subMesh.getAllTypes()));
00429         self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]);
00430         self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]);
00431         self.assertEqual(3,subMesh.getNumberOfCells());
00432         self.assertEqual(14,subMesh.getNodalConnectivity().getNbOfElems());
00433         self.assertEqual(4,subMesh.getNodalConnectivityIndex().getNbOfElems());
00434         subConn2=[3,4,5,2,4,6,7,4,3,4,7,8,5,4]
00435         subConnIndex2=[0,4,9,14]
00436         self.assertEqual(subConn2[0:14],list(subMesh.getNodalConnectivity().getValues()));
00437         self.assertEqual(subConnIndex2[0:4],list(subMesh.getNodalConnectivityIndex().getValues()));
00438         #testing the case where length of tab2 is greater than max number of node per cell.
00439         tab2=[0,3,2,1,4,5,6]
00440         subMesh=mesh.buildPartOfMySelfNode(tab2[0:7],True);
00441         self.assertTrue(isinstance(subMesh,MEDCouplingUMesh))
00442         self.assertEqual(2,len(subMesh.getAllTypes()));
00443         self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]);
00444         self.assertEqual(NORM_QUAD4,subMesh.getAllTypes()[1]);
00445         self.assertEqual(3,subMesh.getNumberOfCells());
00446         pass
    

Definition at line 8699 of file MEDCouplingBasicsTest.py.

08699 
08700     def testBuildPartOfMySelfSafe1(self):
08701         mesh=MEDCouplingDataForTest.build2DTargetMesh_1()
08702         self.assertRaises(InterpKernelException,mesh.buildPartOfMySelf,[0,-1,4,2],True)
08703         self.assertRaises(InterpKernelException,mesh.buildPartOfMySelf,[0,4,5,4],True)
08704         pass

Definition at line 8872 of file MEDCouplingBasicsTest.py.

08872 
08873     def testBuildSlice3D1(self):
08874         mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
08875         vec1=[-0.07,1.,0.07]
08876         origin1=[1.524,1.4552,1.74768]
08877         slice1,ids=mesh3D.buildSlice3D(origin1,vec1,1e-10);
08878         expected1=[1,3,4,7,9,10,13,15,16]
08879         expected2=[5,42,41,40,43,44,5,42,46,45,41,5,44,43,40,47,48,5,49,42,44,50,5,49,51,46,42,5,50,44,48,52,5,53,49,50,54,5,53,55,51,49,5,54,50,52,56]
08880         expected3=[0,6,11,17,22,27,32,37,42,47]
08881         expected4=[1.,1.,0.,1.,1.25,0.,1.,1.5,0.,2.,1.,0.,1.,2.,0.,0.,2.,0.,3.,1.,0.,3.,2.,0.,0.,1.,0.,2.,2.,0.,1.,1.,1.,1.,1.25,1.,1.,1.5,1.,2.,1.,1.,1.,2.,1.,0.,2.,1.,3.,1.,1.,3.,2.,1.,0.,1.,1.,2.,2.,1.,1.,1.,2.,1.,1.25,2.,1.,1.5,2.,2.,1.,2.,1.,2.,2.,0.,2.,2.,3.,1.,2.,3.,2.,2.,0.,1.,2.,2.,2.,2.,1.,1.,3.,1.,1.25,3.,1.,1.5,3.,2.,1.,3.,1.,2.,3.,0.,2.,3.,3.,1.,3.,3.,2.,3.,0.,1.,3.,2.,2.,3.,1.,1.5408576,0.,2.,1.6108576000000001,0.,2.,1.5408576,1.,1.,1.5,0.5836800000000008,1.,1.4708576,1.,3.,1.6808576,0.,3.,1.6108576000000001,1.,0.,1.4708576,0.,0.,1.4008576,1.,2.,1.4708576,2.,1.,1.4008576000000001,2.,3.,1.5408575999999998,2.,0.,1.3308575999999999,2.,2.,1.4008576,3.,1.,1.3308576,3.,3.,1.4708576,3.,0.,1.2608576,3.]
08882         self.assertEqual(2,slice1.getMeshDimension());
08883         self.assertEqual(3,slice1.getSpaceDimension());
08884         self.assertEqual(57,slice1.getNumberOfNodes());
08885         self.assertEqual(9,slice1.getNumberOfCells());
08886         self.assertEqual(9,ids.getNumberOfTuples());
08887         self.assertEqual(47,slice1.getNodalConnectivity().getNumberOfTuples());
08888         self.assertEqual(10,slice1.getNodalConnectivityIndex().getNumberOfTuples());
08889         self.assertEqual(expected1,ids.getValues());
08890         self.assertEqual(expected2,slice1.getNodalConnectivity().getValues());
08891         self.assertEqual(expected3,slice1.getNodalConnectivityIndex().getValues());
08892         for i in xrange(171):
08893             self.assertAlmostEqual(expected4[i],slice1.getCoords().getIJ(0,i),12);
08894             pass
08895         # 2nd slice based on already existing nodes of mesh3D.
08896         vec2=[0.,3.,1.]
08897         origin2=[2.5,1.,3.]
08898         slice1,ids=mesh3D.buildSlice3D(origin2,vec2,1e-10);
08899         expected5=[5,50,10,4,51,5,50,52,7,10,5,51,4,5,53,5,54,50,51,55,56,5,54,57,52,50,5,56,55,51,53,58,5,38,59,56,54,43,5,54,57,46,43,5,38,59,56,58,48]
08900         expected6=[0,5,10,15,21,26,32,38,43,49]
08901         expected7=[1.,1.,0.,1.,1.25,0.,1.,1.5,0.,2.,1.,0.,1.,2.,0.,0.,2.,0.,3.,1.,0.,3.,2.,0.,0.,1.,0.,1.,3.,0.,2.,2.,0.,2.,3.,0.,1.,1.,1.,1.,1.25,1.,1.,1.5,1.,2.,1.,1.,1.,2.,1.,0.,2.,1.,3.,1.,1.,3.,2.,1.,0.,1.,1.,1.,3.,1.,2.,2.,1.,2.,3.,1.,0.,0.,2.,1.,1.,2.,1.,1.25,2.,1.,0.,2.,1.,1.5,2.,2.,0.,2.,2.,1.,2.,1.,2.,2.,0.,2.,2.,3.,1.,2.,3.,2.,2.,0.,1.,2.,2.,2.,2.,0.,0.,3.,1.,1.,3.,1.,1.25,3.,1.,0.,3.,1.,1.5,3.,2.,0.,3.,2.,1.,3.,1.,2.,3.,0.,2.,3.,3.,1.,3.,3.,2.,3.,0.,1.,3.,2.,2.,3.,2.,1.6666666666666667,1.,1.,1.6666666666666667,1.,3.,1.6666666666666667,1.,0.,1.6666666666666667,1.,2.,1.3333333333333335,2.,1.,1.5,1.5,1.,1.3333333333333333,2.,3.,1.3333333333333335,2.,0.,1.3333333333333335,2.,1.,1.25,2.25]
08902         self.assertEqual(2,slice1.getMeshDimension());
08903         self.assertEqual(3,slice1.getSpaceDimension());
08904         self.assertEqual(60,slice1.getNumberOfNodes());
08905         self.assertEqual(9,slice1.getNumberOfCells());
08906         self.assertEqual(9,ids.getNumberOfTuples());
08907         self.assertEqual(49,slice1.getNodalConnectivity().getNumberOfTuples());
08908         self.assertEqual(10,slice1.getNodalConnectivityIndex().getNumberOfTuples());
08909         self.assertEqual(expected1,ids.getValues());
08910         self.assertEqual(expected5,slice1.getNodalConnectivity().getValues());
08911         self.assertEqual(expected6,slice1.getNodalConnectivityIndex().getValues());
08912         for i in xrange(180):
08913             self.assertAlmostEqual(expected7[i],slice1.getCoords().getIJ(0,i),12);
08914             pass
08915         # 3rd slice based on shared face of mesh3D.
08916         vec3=[0.,0.,1.]
08917         origin3=[2.5,1.,2.]
08918         slice1,ids=mesh3D.buildSlice3D(origin3,vec3,1e-10);
08919         expected8=[6,7,8,9,10,11,12,13,14,15,16,17]
08920         expected9=[5,15,26,16,18,5,16,21,28,22,19,17,5,18,20,21,16,5,21,24,25,28,5,26,16,17,19,22,23,5,22,27,29,28,5,15,26,16,18,5,16,21,28,22,19,17,5,18,20,21,16,5,21,24,25,28,5,26,16,17,19,22,23,5,22,27,29,28]
08921         expected10=[0,5,12,17,22,29,34,39,46,51,56,63,68]
08922         expected11=[0.,0.,1.,1.,1.,1.,1.,1.25,1.,1.,0.,1.,1.,1.5,1.,2.,0.,1.,2.,1.,1.,1.,2.,1.,0.,2.,1.,3.,1.,1.,3.,2.,1.,0.,1.,1.,1.,3.,1.,2.,2.,1.,2.,3.,1.,0.,0.,2.,1.,1.,2.,1.,1.25,2.,1.,0.,2.,1.,1.5,2.,2.,0.,2.,2.,1.,2.,1.,2.,2.,0.,2.,2.,3.,1.,2.,3.,2.,2.,0.,1.,2.,1.,3.,2.,2.,2.,2.,2.,3.,2.,0.,0.,3.,1.,1.,3.,1.,1.25,3.,1.,0.,3.,1.,1.5,3.,2.,0.,3.,2.,1.,3.,1.,2.,3.,0.,2.,3.,3.,1.,3.,3.,2.,3.,0.,1.,3.,1.,3.,3.,2.,2.,3.,2.,3.,3.]
08923         self.assertEqual(2,slice1.getMeshDimension());
08924         self.assertEqual(3,slice1.getSpaceDimension());
08925         self.assertEqual(45,slice1.getNumberOfNodes());
08926         self.assertEqual(12,slice1.getNumberOfCells());
08927         self.assertEqual(12,ids.getNumberOfTuples());
08928         self.assertEqual(68,slice1.getNodalConnectivity().getNumberOfTuples());
08929         self.assertEqual(13,slice1.getNodalConnectivityIndex().getNumberOfTuples());
08930         self.assertEqual(expected8,ids.getValues());
08931         self.assertEqual(expected9,slice1.getNodalConnectivity().getValues());
08932         self.assertEqual(expected10,slice1.getNodalConnectivityIndex().getValues());
08933         for i in xrange(135):
08934             self.assertAlmostEqual(expected11[i],slice1.getCoords().getIJ(0,i),12);
08935             pass
08936         pass

Definition at line 8937 of file MEDCouplingBasicsTest.py.

08937 
08938     def testBuildSlice3DSurf1(self):
08939         mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
08940         mesh2D=mesh3D.buildDescendingConnectivity()[0];
08941         vec1=[-0.07,1.,0.07]
08942         origin1=[1.524,1.4552,1.74768]
08943         slice1,ids=mesh2D.buildSlice3DSurf(origin1,vec1,1e-10);
08944         expected1=[6,8,10,11,13,18,19,21,23,25,26,38,41,43,47,49,52,53,64,67,69,73,75,78,79]
08945         expected2=[1,40,41,1,42,41,1,40,43,1,44,43,1,42,44,1,45,41,1,42,46,1,46,45,1,47,40,1,47,48,1,44,48,1,49,42,1,44,50,1,49,50,1,49,51,1,51,46,1,48,52,1,50,52,1,53,49,1,50,54,1,53,54,1,53,55,1,55,51,1,52,56,1,54,56]
08946         expected3=[0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75];
08947         expected4=[1.,1.,0.,1.,1.25,0.,1.,1.5,0.,2.,1.,0.,1.,2.,0.,0.,2.,0.,3.,1.,0.,3.,2.,0.,0.,1.,0.,2.,2.,0.,1.,1.,1.,1.,1.25,1.,1.,1.5,1.,2.,1.,1.,1.,2.,1.,0.,2.,1.,3.,1.,1.,3.,2.,1.,0.,1.,1.,2.,2.,1.,1.,1.,2.,1.,1.25,2.,1.,1.5,2.,2.,1.,2.,1.,2.,2.,0.,2.,2.,3.,1.,2.,3.,2.,2.,0.,1.,2.,2.,2.,2.,1.,1.,3.,1.,1.25,3.,1.,1.5,3.,2.,1.,3.,1.,2.,3.,0.,2.,3.,3.,1.,3.,3.,2.,3.,0.,1.,3.,2.,2.,3.,1.,1.5408576,0.,2.,1.6108576000000001,0.,2.,1.5408576,1.,1.,1.5,0.5836800000000008,1.,1.4708576,1.,3.,1.6808576,0.,3.,1.6108576000000001,1.,0.,1.4708576,0.,0.,1.4008576,1.,2.,1.4708576,2.,1.,1.4008576000000001,2.,3.,1.5408575999999998,2.,0.,1.3308575999999999,2.,2.,1.4008576,3.,1.,1.3308576,3.,3.,1.4708576,3.,0.,1.2608576,3.]
08948         self.assertEqual(1,slice1.getMeshDimension());
08949         self.assertEqual(3,slice1.getSpaceDimension());
08950         self.assertEqual(57,slice1.getNumberOfNodes());
08951         self.assertEqual(25,slice1.getNumberOfCells());
08952         self.assertEqual(25,ids.getNumberOfTuples());
08953         self.assertEqual(75,slice1.getNodalConnectivity().getNumberOfTuples());
08954         self.assertEqual(26,slice1.getNodalConnectivityIndex().getNumberOfTuples());
08955         self.assertEqual(expected1,ids.getValues());
08956         self.assertEqual(expected2,slice1.getNodalConnectivity().getValues());
08957         self.assertEqual(expected3,slice1.getNodalConnectivityIndex().getValues());
08958         for i in xrange(171):
08959             self.assertAlmostEqual(expected4[i],slice1.getCoords().getIJ(0,i),12);
08960             pass
08961         #
08962         vec2=[0.,0.,1.]
08963         origin2=[2.5,1.,2.]
08964         slice1,ids=mesh2D.buildSlice3DSurf(origin2,vec2,1e-10);
08965         expected5=[32,32,32,32,33,34,35,36,37,38,39,40,41,42,43,43,43,43,43,43,44,44,44,44,45,46,47,47,47,47,48,49,50,51,52,53,53,53,53,53,53,54,54,54,54,55,56,57,59,60,61,62,63,64,65,66,67,68,71,72,74,75,76,77,78,81,82,83]
08966         expected6=[1,15,18,1,18,16,1,16,26,1,26,15,1,26,15,1,16,26,1,18,16,1,15,18,1,16,21,1,21,28,1,22,28,1,19,22,1,17,19,1,16,17,1,16,21,1,21,28,1,28,22,1,22,19,1,19,17,1,17,16,1,16,18,1,18,20,1,20,21,1,21,16,1,20,21,1,18,20,1,28,21,1,21,24,1,24,25,1,25,28,1,25,28,1,24,25,1,21,24,1,23,22,1,26,23,1,26,16,1,16,17,1,17,19,1,19,22,1,22,23,1,23,26,1,22,28,1,28,29,1,29,27,1,27,22,1,27,22,1,29,27,1,28,29,1,26,15,1,16,26,1,18,16,1,15,18,1,16,21,1,21,28,1,22,28,1,19,22,1,17,19,1,16,17,1,20,21,1,18,20,1,25,28,1,24,25,1,21,24,1,23,22,1,26,23,1,27,22,1,29,27,1,28,29]
08967         expected7=[0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99,102,105,108,111,114,117,120,123,126,129,132,135,138,141,144,147,150,153,156,159,162,165,168,171,174,177,180,183,186,189,192,195,198,201,204];
08968         expected8=[0.,0.,1.,1.,1.,1.,1.,1.25, 1.,1.,0.,1.,1.,1.5, 1.,2.,0.,1.,2.,1.,1.,1.,2.,1.,0.,2.,1.,3.,1.,1.,3.,2.,1.,0.,1.,1.,1.,3.,1.,2.,2.,1.,2.,3.,1.,0.,0.,2.,1.,1.,2.,1.,1.25, 2.,1.,0.,2.,1.,1.5, 2.,2.,0.,2.,2.,1.,2.,1.,2.,2.,0.,2.,2.,3.,1.,2.,3.,2.,2.,0.,1.,2.,1.,3.,2.,2.,2.,2.,2.,3.,2.,0.,0.,3.,1.,1.,3.,1.,1.25, 3.,1.,0.,3.,1.,1.5, 3.,2.,0.,3.,2.,1.,3.,1.,2.,3.,0.,2.,3.,3.,1.,3.,3.,2.,3.,0.,1.,3.,1.,3.,3.,2.,2.,3.,2.,3.,3.]
08969         self.assertEqual(1,slice1.getMeshDimension());
08970         self.assertEqual(3,slice1.getSpaceDimension());
08971         self.assertEqual(45,slice1.getNumberOfNodes());
08972         self.assertEqual(68,slice1.getNumberOfCells());
08973         self.assertEqual(68,ids.getNumberOfTuples());
08974         self.assertEqual(204,slice1.getNodalConnectivity().getNumberOfTuples());
08975         self.assertEqual(69,slice1.getNodalConnectivityIndex().getNumberOfTuples());
08976         self.assertEqual(expected5,ids.getValues());
08977         self.assertEqual(expected6,slice1.getNodalConnectivity().getValues());
08978         self.assertEqual(expected7,slice1.getNodalConnectivityIndex().getValues());
08979         for i in xrange(135):
08980             self.assertAlmostEqual(expected8[i],slice1.getCoords().getIJ(0,i),12);
08981             pass
08982         pass

Definition at line 655 of file MEDCouplingBasicsTest.py.

00655 
00656     def testBuildSubMeshData(self):
00657         targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1()
00658         #check buildSubMesh on field on cells
00659         fieldCells=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00660         fieldCells.setMesh(targetMesh);
00661         elts=[1,2,4]
00662         ret1,di=fieldCells.buildSubMeshData(elts);
00663         self.assertTrue(isinstance(ret1,MEDCouplingUMesh))
00664         self.assertEqual(3,ret1.getNumberOfCells());
00665         self.assertEqual(9,ret1.getNumberOfNodes());
00666         self.assertEqual(3,di.getNumberOfTuples());
00667         self.assertEqual(1,di.getNumberOfComponents());
00668         toCheck=di.getValues();
00669         self.assertTrue(elts,toCheck);
00670         #check buildSubMesh on field on nodes
00671         fieldNodes=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
00672         fieldNodes.setMesh(targetMesh);
00673         ret2,di=fieldNodes.buildSubMeshData(elts);
00674         self.assertTrue(isinstance(ret2,MEDCouplingUMesh))
00675         self.assertEqual(3,ret2.getNumberOfCells());
00676         self.assertEqual(6,ret2.getNumberOfNodes());
00677         self.assertEqual(6,di.getNumberOfTuples());
00678         self.assertEqual(1,di.getNumberOfComponents());
00679         toCheck=di.getValues();
00680         expected=[1,2,4,5,7,8]
00681         self.assertEqual(expected,list(toCheck));
00682         pass
    

Definition at line 3042 of file MEDCouplingBasicsTest.py.

03042 
03043     def testBuildSubPart1(self):
03044         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03045         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
03046         f1.setTime(2.3,5,6);
03047         f1.setMesh(mesh1);
03048         array=DataArrayDouble.New();
03049         arr1=[3.,103.,4.,104.,5.,105.,6.,106.,7.,107.]
03050         array.setValues(arr1,mesh1.getNumberOfCells(),2);
03051         f1.setArray(array);
03052         #
03053         part1=[2,1,4]
03054         f2=f1.buildSubPart(part1);
03055         f2.zipCoords()
03056         self.failUnlessEqual(3,f2.getNumberOfTuples());
03057         self.failUnlessEqual(2,f2.getNumberOfComponents());
03058         expected1=[5.,105.,4.,104.,7.,107.]
03059         for i in xrange(6):
03060             self.assertAlmostEqual(f2.getIJ(0,i),expected1[i],12);
03061             pass
03062         self.failUnlessEqual(3,f2.getMesh().getNumberOfCells());
03063         self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes());
03064         self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
03065         self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
03066         m2C=f2.getMesh();
03067         self.failUnlessEqual(13,m2C.getMeshLength());
03068         expected2=[0.2, -0.3, 0.7, -0.3, 0.2, 0.2, 0.7, 0.2, 0.2, 0.7, 0.7, 0.7]
03069         for i in xrange(12):
03070             self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
03071             pass
03072         expected3=[3,2,3,1,3,0,2,1,4,4,5,3,2]
03073         self.failUnlessEqual(expected3,list(m2C.getNodalConnectivity().getValues()));
03074         expected4=[0,4,8,13]
03075         self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues()));
03076         # Test with field on nodes.
03077         f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
03078         f1.setTime(2.3,5,6);
03079         f1.setMesh(mesh1);
03080         array=DataArrayDouble.New();
03081         arr2=[3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.]
03082         array.setValues(arr2,mesh1.getNumberOfNodes(),2);
03083         f1.setArray(array);
03084         part2=[1,2]
03085         f2=f1.buildSubPart(part2);
03086         self.failUnlessEqual(4,f2.getNumberOfTuples());
03087         self.failUnlessEqual(2,f2.getNumberOfComponents());
03088         expected5=[4.,104.,5.,105.,7.,107.,8.,108.]
03089         for i in xrange(8):
03090             self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12);
03091             pass
03092         self.failUnlessEqual(2,f2.getMesh().getNumberOfCells());
03093         self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes());
03094         self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
03095         self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
03096         m2C=f2.getMesh();
03097         self.failUnlessEqual(8,m2C.getMeshLength());
03098         for i in xrange(8):#8 is not an error
03099             self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
03100             pass
03101         self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:]);
03102         self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]);
03103         self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()));
03104         #idem previous because nodes of cell#4 are not fully present in part3
03105         part3=[1,2]
03106         arrr=DataArrayInt.New();
03107         arrr.setValues(part3,2,1);
03108         f2=f1.buildSubPart(arrr);
03109         self.failUnlessEqual(4,f2.getNumberOfTuples());
03110         self.failUnlessEqual(2,f2.getNumberOfComponents());
03111         for i in xrange(8):
03112             self.assertAlmostEqual(f2.getIJ(0,i),expected5[i],12);
03113             pass
03114         self.failUnlessEqual(2,f2.getMesh().getNumberOfCells());
03115         self.failUnlessEqual(4,f2.getMesh().getNumberOfNodes());
03116         self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
03117         self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
03118         m2C=f2.getMesh();
03119         self.failUnlessEqual(8,m2C.getMeshLength());
03120         for i in xrange(8):#8 is not an error
03121             self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
03122             pass
03123         self.failUnlessEqual(expected3[:4],list(m2C.getNodalConnectivity().getValues())[4:8]);
03124         self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[:4]);
03125         self.failUnlessEqual(expected4[:3],list(m2C.getNodalConnectivityIndex().getValues()));
03126         #
03127         part4=[1,2,4]
03128         f2=f1.buildSubPart(part4);
03129         self.failUnlessEqual(6,f2.getNumberOfTuples());
03130         self.failUnlessEqual(2,f2.getNumberOfComponents());
03131         expected6=[4.,104.,5.,105.,7.,107.,8.,108.,10.,110.,11.,111.]
03132         for i in xrange(12):
03133             self.assertAlmostEqual(f2.getIJ(0,i),expected6[i],12);
03134             pass
03135         self.failUnlessEqual(3,f2.getMesh().getNumberOfCells());
03136         self.failUnlessEqual(6,f2.getMesh().getNumberOfNodes());
03137         self.failUnlessEqual(2,f2.getMesh().getSpaceDimension());
03138         self.failUnlessEqual(2,f2.getMesh().getMeshDimension());
03139         m2C=f2.getMesh();
03140         self.failUnlessEqual(13,m2C.getMeshLength());
03141         for i in xrange(12):
03142             self.assertAlmostEqual(expected2[i],m2C.getCoords().getIJ(0,i),12);
03143             pass
03144         self.failUnlessEqual(expected3[0:4],list(m2C.getNodalConnectivity().getValues())[4:8]);
03145         self.failUnlessEqual(expected3[4:8],list(m2C.getNodalConnectivity().getValues())[0:4]);
03146         self.failUnlessEqual(expected3[8:13],list(m2C.getNodalConnectivity().getValues())[8:13]);
03147         self.failUnlessEqual(expected4,list(m2C.getNodalConnectivityIndex().getValues()));
03148         pass

Definition at line 4280 of file MEDCouplingBasicsTest.py.

04280 
04281     def testBuildUnstructuredCMesh1(self):
04282         m=MEDCouplingCMesh.New();
04283         da=DataArrayDouble.New();
04284         discX=[2.3,3.4,5.8,10.2]
04285         discY=[12.3,23.4,45.8]
04286         discZ=[-0.7,1.2,1.25,2.13,2.67]
04287         da.setValues(discX,4,1);
04288         m.setCoordsAt(0,da);
04289         m.checkCoherency();
04290         self.assertEqual(0,m.getCellContainingPoint([2.4],1e-12));
04291         self.assertEqual(1,m.getCellContainingPoint([3.7],1e-12));
04292         self.assertEqual(2,m.getCellContainingPoint([5.9],1e-12));
04293         self.assertEqual(-1,m.getCellContainingPoint([10.3],1e-12));
04294         self.assertEqual(-1,m.getCellContainingPoint([1.3],1e-12));
04295         #
04296         m2=m.buildUnstructured();
04297         m2.checkCoherency();
04298         f1=m.getMeasureField(False);
04299         f2=m2.getMeasureField(False);
04300         self.assertTrue(isinstance(f1.getMesh(),MEDCouplingCMesh))
04301         self.assertEqual(f1.getNumberOfTuples(),3);
04302         self.assertEqual(f2.getNumberOfTuples(),3);
04303         self.assertEqual(1,m2.getMeshDimension());
04304         self.assertEqual(1,m2.getSpaceDimension());
04305         for i in xrange(3):
04306             self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10);
04307             pass
04308         da=DataArrayDouble.New();
04309         da.setValues(discY,3,1);
04310         m.setCoordsAt(1,da);
04311         #
04312         m2=m.buildUnstructured();
04313         m2.checkCoherency();
04314         f1=m.getMeasureField(False);
04315         f2=m2.getMeasureField(False);
04316         self.assertEqual(f1.getNumberOfTuples(),6);
04317         self.assertEqual(f2.getNumberOfTuples(),6);
04318         self.assertEqual(2,m2.getMeshDimension());
04319         self.assertEqual(2,m2.getSpaceDimension());
04320         for i in xrange(6):
04321             self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10);
04322             pass
04323         #
04324         da=DataArrayDouble.New();
04325         da.setValues(discZ,5,1);
04326         m.setCoordsAt(2,da);
04327         m2=m.buildUnstructured();
04328         m2.checkCoherency();
04329         f1=m.getMeasureField(False);
04330         f2=m2.getMeasureField(False);
04331         self.assertEqual(f1.getNumberOfTuples(),24);
04332         self.assertEqual(f2.getNumberOfTuples(),24);
04333         self.assertEqual(3,m2.getMeshDimension());
04334         self.assertEqual(3,m2.getSpaceDimension());
04335         for i in xrange(24):
04336             self.assertAlmostEqual(f1.getIJ(i,0),f2.getIJ(i,0),10);
04337             pass
04338         #
04339         pos1=[5.,30.,2.]
04340         self.assertEqual(16,m.getCellContainingPoint(pos1,1e-12));
04341         #
04342         elems=m2.getCellsInBoundingBox([3.5,6.,12.2,25.,0.,1.5],1e-7)
04343         self.assertEqual([1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17],elems.getValues())
04344         #
04345         pt=[2.4,12.7,-3.4]
04346         m.scale(pt,3.7);
04347         m3=m.buildUnstructured();
04348         m2.scale(pt,3.7);
04349         self.assertTrue(m3.isEqual(m2,1e-12));
04350         pass

Definition at line 2077 of file MEDCouplingBasicsTest.py.

02077 
02078     def testCellOrientation1(self):
02079         m=MEDCouplingDataForTest.build2DTargetMesh_1();
02080         vec=[0.,0.,-1.]
02081         self.assertRaises(InterpKernelException,m.are2DCellsNotCorrectlyOriented,vec,False);
02082         m.changeSpaceDimension(3);
02083         res1=m.are2DCellsNotCorrectlyOriented(vec,False);
02084         self.assertTrue(len(res1)==0);
02085         vec[2]=1.;
02086         res1=m.are2DCellsNotCorrectlyOriented(vec,False);
02087         self.assertEqual(5,len(res1));
02088         #
02089         vec[2]=-1.;
02090         # connectivity inversion
02091         conn=m.getNodalConnectivity().getValues();
02092         tmp=conn[11];
02093         conn[11]=conn[12];
02094         conn[12]=tmp;
02095         m.getNodalConnectivity().setValues(conn,len(conn),1)
02096         res1=m.are2DCellsNotCorrectlyOriented(vec,False);
02097         self.assertEqual(1,len(res1));
02098         self.assertEqual(2,res1.getValues()[0]);
02099         m.orientCorrectly2DCells(vec,False);
02100         res1=m.are2DCellsNotCorrectlyOriented(vec,False);
02101         self.assertTrue(len(res1)==0);
02102         m2=MEDCouplingDataForTest.build2DTargetMesh_1();
02103         m2.changeSpaceDimension(3);
02104         self.assertTrue(m.isEqual(m2,1e-12));
02105         pass

Definition at line 2106 of file MEDCouplingBasicsTest.py.

02106 
02107     def testCellOrientation2(self):
02108         m2,m1=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
02109         res1=m2.arePolyhedronsNotCorrectlyOriented();
02110         self.assertEqual(6,len(res1));
02111         m2.orientCorrectlyPolyhedrons();
02112         res1=m2.arePolyhedronsNotCorrectlyOriented();
02113         self.assertTrue(len(res1)==0);
02114         m2.checkCoherency();
02115         self.assertEqual(18,m2.getNumberOfCells());
02116         cellIds2=[0,6,12]
02117         m2.convertToPolyTypes(cellIds2);
02118         m2.orientCorrectlyPolyhedrons();
02119         res1=m2.arePolyhedronsNotCorrectlyOriented();
02120         self.assertTrue(len(res1)==0);
02121         f2=m2.getMeasureField(False);
02122         f2Ptr=f2.getArray().getValues();
02123         #Test to check global reverse in MEDCouplingUMesh::tryToCorrectPolyhedronOrientation
02124         m3=MEDCouplingDataForTest.build2DTargetMesh_1();
02125         vec=[0.,0.,1.]
02126         m3.changeSpaceDimension(3);
02127         ids2=[0,1,2,3,4]
02128         m3.convertToPolyTypes(ids2);
02129         m3.orientCorrectly2DCells(vec,False);
02130         m4=MEDCouplingDataForTest.buildCU1DMesh_U();
02131         m4.changeSpaceDimension(3);
02132         center=[0.,0.,0.]
02133         vector=[0.,1.,0.]
02134         m4.rotate(center,vector,-pi/2.);
02135         m5=m3.buildExtrudedMesh(m4,0);
02136         res1=m5.arePolyhedronsNotCorrectlyOriented();
02137         self.assertEqual(15,len(res1));
02138         m5.orientCorrectlyPolyhedrons();
02139         res1=m5.arePolyhedronsNotCorrectlyOriented();
02140         self.assertTrue(len(res1)==0);
02141         f3=m5.getMeasureField(False);
02142         self.assertEqual(15,f3.getArray().getNumberOfTuples());
02143         self.assertEqual(1,f3.getNumberOfComponents());
02144         f3Ptr=f3.getArray().getValues();
02145         expected1=[0.075,0.0375,0.0375,0.075,0.075, 0.1125,0.05625,0.05625,0.1125,0.1125, 0.0625,0.03125,0.03125,0.0625,0.0625];
02146         for i in xrange(15):
02147             self.assertTrue(abs(expected1[i]-f3Ptr[i])<1e-12);
02148             pass
02149         f4=m5.getBarycenterAndOwner();
02150         self.assertEqual(15,f4.getNumberOfTuples());
02151         self.assertEqual(3,f4.getNumberOfComponents());
02152         f4Ptr=f4.getValues();
02153         expected2=[-0.05,-0.05,0.15, 0.3666666666666667,-0.13333333333333333,0.15, 0.53333333333333333,0.033333333333333333,0.15, -0.05,0.45,0.15, 0.45,0.45,0.15,-0.05,-0.05,0.525, 0.3666666666666667,-0.13333333333333333,0.525, 0.53333333333333333,0.033333333333333333,0.525, -0.05,0.45,0.525, 0.45,0.45,0.525,-0.05,-0.05,0.875, 0.3666666666666667,-0.13333333333333333,0.875, 0.53333333333333333,0.033333333333333333,0.875, -0.05,0.45,0.875, 0.45,0.45,0.875];
02154         for i in xrange(45):
02155             self.assertTrue(abs(expected2[i]-f4Ptr[i])<1e-12);
02156             pass
02157         pass

Definition at line 3491 of file MEDCouplingBasicsTest.py.

03491 
03492     def testChangeNbOfComponents(self):
03493         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03494         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03495         f1.setMesh(mesh1);
03496         array=DataArrayDouble.New();
03497         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4]
03498         array.setValues(arr1,mesh1.getNumberOfCells(),5);
03499         f1.setArray(array);
03500         f1.checkCoherency();
03501         #
03502         f1.changeNbOfComponents(3,7.77);
03503         f1.checkCoherency();
03504         self.assertEqual(3,f1.getNumberOfComponents());
03505         self.assertEqual(5,f1.getNumberOfTuples());
03506         expected1=[1.2,2.3,3.4, 1.2,3.4,4.5, 3.4,4.5,5.6, 5.6,1.2,2.3, 4.5,5.6,1.2]
03507         for i in xrange(15):
03508             self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),13);
03509             pass
03510         f1.changeNbOfComponents(4,7.77);
03511         f1.checkCoherency();
03512         self.assertEqual(4,f1.getNumberOfComponents());
03513         self.assertEqual(5,f1.getNumberOfTuples());
03514         expected2=[1.2,2.3,3.4,7.77, 1.2,3.4,4.5,7.77, 3.4,4.5,5.6,7.77, 5.6,1.2,2.3,7.77, 4.5,5.6,1.2,7.77]
03515         for i in xrange(20):
03516             self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),13);
03517             pass
03518         #
03519         pass

Here is the caller graph for this function:

Definition at line 4725 of file MEDCouplingBasicsTest.py.

04725 
04726     def testChangeNbOfComponents(self):
04727         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04728         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04729         f1.setMesh(mesh1);
04730         array=DataArrayDouble.New();
04731         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4]
04732         array.setValues(arr1,mesh1.getNumberOfCells(),5);
04733         f1.setArray(array);
04734         f1.checkCoherency();
04735         #
04736         f1.changeNbOfComponents(3,7.77);
04737         f1.checkCoherency();
04738         self.assertEqual(3,f1.getNumberOfComponents());
04739         self.assertEqual(5,f1.getNumberOfTuples());
04740         expected1=[1.2,2.3,3.4, 1.2,3.4,4.5, 3.4,4.5,5.6, 5.6,1.2,2.3, 4.5,5.6,1.2]
04741         for i in xrange(15):
04742             self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),13);
04743             pass
04744         f1.changeNbOfComponents(4,7.77);
04745         f1.checkCoherency();
04746         self.assertEqual(4,f1.getNumberOfComponents());
04747         self.assertEqual(5,f1.getNumberOfTuples());
04748         expected2=[1.2,2.3,3.4,7.77, 1.2,3.4,4.5,7.77, 3.4,4.5,5.6,7.77, 5.6,1.2,2.3,7.77, 4.5,5.6,1.2,7.77]
04749         for i in xrange(20):
04750             self.assertAlmostEqual(expected2[i],f1.getIJ(0,i),13);
04751             pass
04752         #
04753         pass

Here is the call graph for this function:

Definition at line 1954 of file MEDCouplingBasicsTest.py.

01954 
01955     def testChangeSpaceDimension(self):
01956         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
01957         m2=MEDCouplingDataForTest.build2DTargetMesh_1();
01958         #
01959         self.assertEqual(3,m1.getSpaceDimension());
01960         m1.changeSpaceDimension(2);
01961         self.assertEqual(2,m1.getSpaceDimension());
01962         m1.setName(m2.getName());
01963         self.assertTrue(m1.isEqual(m2,1e-12));
01964         m1.changeSpaceDimension(3);
01965         self.assertEqual(3,m1.getSpaceDimension());
01966         expected=[-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0.]
01967         val=m1.getCoords().getValues();
01968         for i in xrange(27):
01969             self.assertTrue(abs(expected[i]-val[i])<1e-14);
01970             pass
01971         pass

Definition at line 2829 of file MEDCouplingBasicsTest.py.

02829 
02830     def testChangeUnderlyingMesh1(self):
02831         mesh1=MEDCouplingDataForTest.build2DTargetMesh_3();
02832         mesh2=MEDCouplingDataForTest.build2DTargetMesh_3();
02833         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
02834         f1.setMesh(mesh1);
02835         array=DataArrayDouble.New();
02836         arr=[7., 107., 8., 108., 9., 109., 10., 110., 11., 111., 12., 112., 13., 113., 14., 114., 15., 115., 16., 116.]
02837         array.setValues(arr,mesh1.getNumberOfCells(),2);
02838         f1.setArray(array);
02839         #
02840         renum=[0,2,1,3,4,5,6,8,7,9]
02841         mesh2.renumberCells(renum,False);
02842         #self.assertTrue(f1.getMesh()==mesh1);
02843         f1.changeUnderlyingMesh(mesh1,10,1e-12);# nothing done only to check that nothing done.
02844         #self.assertTrue(f1.getMesh()==mesh1);
02845         f1.changeUnderlyingMesh(mesh2,10,1e-12);
02846         #self.assertTrue(f1.getMesh()==mesh2);
02847         expected1=[7.,107.,9.,109.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.]
02848         for i in xrange(20):
02849             self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
02850             pass
02851         #
02852         f1=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
02853         f1.setMesh(mesh1);
02854         array=DataArrayDouble.New();
02855         arr2=[7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.,17.,117.]
02856         array.setValues(arr2,mesh1.getNumberOfNodes(),2);
02857         f1.setArray(array);
02858         #
02859         renum2=[0,2,10,3,4,5,6,8,7,9,1]
02860         mesh2.renumberNodes(renum2,11);
02861         #self.assertTrue(f1.getMesh()==mesh1);
02862         f1.changeUnderlyingMesh(mesh2,10,1e-12);
02863         #self.assertTrue(f1.getMesh()==mesh2);
02864         expected2=[7.,107.,17.,117.,8.,108.,10.,110.,11.,111.,12.,112.,13.,113.,15.,115.,14.,114.,16.,116.,9.,109.]
02865         for i in xrange(22):
02866             self.assertAlmostEqual(expected2[i],f1.getArray().getIJ(0,i),12);
02867             pass
02868         pass

Definition at line 8386 of file MEDCouplingBasicsTest.py.

08386 
08387     def testChangeUnderlyingMeshWithCMesh1(self):
08388         mesh=MEDCouplingCMesh.New();
08389         coordsX=DataArrayDouble.New();
08390         arrX=[ -1., 1., 2., 4. ]
08391         coordsX.setValues(arrX,4,1);
08392         coordsY=DataArrayDouble.New();
08393         arrY=[ -2., 2., 4., 8. ]
08394         coordsY.setValues(arrY,4,1);
08395         coordsZ=DataArrayDouble.New();
08396         arrZ=[ -3., 3., 6., 12. ]
08397         coordsZ.setValues(arrZ,4,1);
08398         mesh.setCoords(coordsX,coordsY,coordsZ);
08399         f=mesh.getMeasureField(True)
08400         mesh2=mesh.deepCpy()
08401         for myId in [0,1,2,10,11,12,20,21,22]:
08402             f=mesh.getMeasureField(True)
08403             f.changeUnderlyingMesh(mesh2,myId,1e-12);
08404             pass
08405         mesh2.setName("uuuu")
08406         for myId in [1,2,10,11,12,20,21,22]:
08407             f=mesh.getMeasureField(True)
08408             f.changeUnderlyingMesh(mesh2,myId,1e-12);
08409             pass
08410         pass

Definition at line 866 of file MEDCouplingBasicsTest.py.

00866 
00867     def testCheckButterflyCells(self):
00868         sourceMesh=MEDCouplingDataForTest.build2DTargetMesh_1();
00869         cells=sourceMesh.checkButterflyCells();
00870         self.assertEqual(0,len(cells));
00871         conn=sourceMesh.getNodalConnectivity()
00872         tmp=conn.getIJ(15,0)
00873         conn.setIJ(15,0,conn.getIJ(16,0))
00874         conn.setIJ(16,0,tmp)
00875         cells=sourceMesh.checkButterflyCells();
00876         self.assertEqual(1,len(cells));
00877         self.assertEqual([3],cells.getValues());
00878         tmp=conn.getIJ(15,0)
00879         conn.setIJ(15,0,conn.getIJ(16,0))
00880         conn.setIJ(16,0,tmp)
00881         cells=sourceMesh.checkButterflyCells();
00882         self.assertEqual(0,len(cells));
00883         # 3D surf
00884         sourceMesh=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
00885         cells=sourceMesh.checkButterflyCells();
00886         self.assertEqual(0,len(cells));
00887         conn=sourceMesh.getNodalConnectivity()
00888         tmp=conn.getIJ(15,0)
00889         conn.setIJ(15,0,conn.getIJ(16,0))
00890         conn.setIJ(16,0,tmp)
00891         cells=sourceMesh.checkButterflyCells();
00892         self.assertEqual(1,len(cells));
00893         self.assertEqual([3],cells.getValues());
00894         tmp=conn.getIJ(15,0)
00895         conn.setIJ(15,0,conn.getIJ(16,0))
00896         conn.setIJ(16,0,tmp)
00897         cells=sourceMesh.checkButterflyCells();
00898         self.assertEqual(0,len(cells));
00899         pass

Definition at line 9757 of file MEDCouplingBasicsTest.py.

09757 
09758     def testCheckButterflyCellsBug1(self):
09759         mesh2DCoords=[323.85,120.983748908684,317.5,131.982271536747,336.55,120.983748908686,330.2,131.982271536751,323.85,142.98079416481]
09760         mesh2DConn=[4,1,0,2,3]
09761         mesh2D=MEDCouplingUMesh.New("mesh",2);
09762         mesh2D.allocateCells(1);
09763         mesh2D.insertNextCell(NORM_POLYGON,5,mesh2DConn[0:5])
09764         mesh2D.finishInsertingCells();
09765         myCoords=DataArrayDouble.New(mesh2DCoords,5,2);
09766         mesh2D.setCoords(myCoords);
09767         mesh2D.checkCoherency();
09768         #
09769         v=mesh2D.checkButterflyCells();
09770         self.assertTrue(v.empty());
09771         pass

Definition at line 7707 of file MEDCouplingBasicsTest.py.

07707 
07708     def testCheckCoherencyDeeper1(self):
07709         m=MEDCouplingDataForTest.build3DSourceMesh_1();
07710         m.checkCoherency();
07711         m.checkCoherency1();
07712         m.getNodalConnectivity().setIJ(8,0,-1);
07713         m.checkCoherency();
07714         self.assertRaises(InterpKernelException,m.checkCoherency1);
07715         m.getNodalConnectivity().setIJ(8,0,-6);
07716         m.checkCoherency();
07717         self.assertRaises(InterpKernelException,m.checkCoherency1);
07718         m.getNodalConnectivity().setIJ(8,0,9);#9>=NbOfNodes
07719         m.checkCoherency();
07720         self.assertRaises(InterpKernelException,m.checkCoherency1);
07721         m.getNodalConnectivity().setIJ(8,0,8);#OK
07722         m.checkCoherency();
07723         m.checkCoherency1();
07724         elts=[1,5]
07725         m.convertToPolyTypes(elts);
07726         m.checkCoherency();
07727         m.checkCoherency1();
07728         m.getNodalConnectivity().setIJ(2,0,9);#9>=NbOfNodes
07729         m.checkCoherency();
07730         self.assertRaises(InterpKernelException,m.checkCoherency1);
07731         m.getNodalConnectivity().setIJ(2,0,-3);
07732         m.checkCoherency();
07733         self.assertRaises(InterpKernelException,m.checkCoherency1);
07734         m.getNodalConnectivity().setIJ(2,0,-1);
07735         m.checkCoherency();
07736         self.assertRaises(InterpKernelException,m.checkCoherency1);#Throw because cell#0 is not a polyhedron
07737         m.getNodalConnectivity().setIJ(2,0,4);
07738         m.checkCoherency();
07739         m.checkCoherency1();
07740         m.getNodalConnectivity().setIJ(7,0,-1);
07741         m.checkCoherency();
07742         m.checkCoherency1();#OK because we are in polyhedron connec
07743         m.getNodalConnectivity().setIJ(36,0,14);
07744         m.checkCoherency();
07745         self.assertRaises(InterpKernelException,m.checkCoherency1);#Throw beacause now cell 5 is a TETRA4 (14) so mimatch of number index and static type.
07746         pass

Definition at line 1389 of file MEDCouplingBasicsTest.py.

01389 
01390     def testCheckConsecutiveCellTypes(self):
01391         sourceMesh=MEDCouplingDataForTest.build2DSourceMesh_1();
01392         targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1();
01393         self.assertTrue(sourceMesh.checkConsecutiveCellTypes());
01394         order1=[NORM_TRI3,NORM_QUAD4]
01395         order2=[NORM_QUAD4,NORM_TRI3]
01396         self.assertTrue(not targetMesh.checkConsecutiveCellTypes());
01397         self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order1));
01398         self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order2));
01399         da=targetMesh.getRenumArrForConsecutiveCellTypesSpec(order1);
01400         self.assertEqual(5,da.getNumberOfTuples());
01401         self.assertEqual(1,da.getNumberOfComponents());
01402         expected1=[2,0,1,3,4]
01403         self.assertTrue(expected1==list(da.getValues()));
01404         da=targetMesh.getRenumArrForConsecutiveCellTypesSpec(order2);
01405         self.assertEqual(5,da.getNumberOfTuples());
01406         self.assertEqual(1,da.getNumberOfComponents());
01407         expected2=[0,3,4,1,2]
01408         self.assertTrue(expected2==list(da.getValues()));
01409         renumber1=[4,0,1,2,3]
01410         targetMesh.renumberCells(renumber1,False);
01411         self.assertTrue(targetMesh.checkConsecutiveCellTypes());
01412         self.assertTrue(targetMesh.checkConsecutiveCellTypesAndOrder(order1));
01413         self.assertTrue(not targetMesh.checkConsecutiveCellTypesAndOrder(order2));
01414         pass

Definition at line 2619 of file MEDCouplingBasicsTest.py.

02619 
02620     def testCheckGeoEquivalWith(self):
02621         mesh1=MEDCouplingDataForTest.build2DTargetMesh_3();
02622         mesh2=MEDCouplingDataForTest.build2DTargetMesh_3();
02623         #First test mesh1
02624         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh1,0,1e-12);#deepEqual
02625         self.assertTrue(cellCor==None);
02626         self.assertTrue(nodeCor==None);
02627         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh1,1,1e-12);#fastEqual
02628         self.assertTrue(cellCor==None);
02629         self.assertTrue(nodeCor==None);
02630         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh1,10,1e-12);#deepEqual with geo permutations
02631         self.assertTrue(cellCor==None);
02632         self.assertTrue(nodeCor==None);
02633         #Second test mesh1 and mesh2 are 2 different meshes instance
02634         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,0,1e-12);#deepEqual
02635         self.assertTrue(cellCor==None);
02636         self.assertTrue(nodeCor==None);
02637         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual
02638         self.assertTrue(cellCor==None);
02639         self.assertTrue(nodeCor==None);
02640         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12);#deepEqual with geo permutations
02641         self.assertTrue(cellCor==None);
02642         self.assertTrue(nodeCor==None);
02643         #Third test : cell permutation by keeping the first the middle and the last as it is.
02644         renum=[0,2,1,3,4,5,6,8,7,9]
02645         mesh2.renumberCells(renum,False);
02646         self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails
02647         self.assertTrue(cellCor==None);
02648         self.assertTrue(nodeCor==None);
02649         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything
02650         self.assertTrue(cellCor==None);
02651         self.assertTrue(nodeCor==None);
02652         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12);#deepEqual with geo permutations
02653         self.assertTrue(cellCor);
02654         self.assertEqual(10,cellCor.getNumberOfTuples());
02655         self.assertEqual(1,cellCor.getNumberOfComponents());
02656         self.assertEqual(renum,list(cellCor.getValues()))
02657         self.assertTrue(nodeCor==None);
02658         cellCor=0;
02659         self.assertTrue(nodeCor==None);
02660         #4th test : cell and node permutation by keeping the first the middle and the last as it is.
02661         mesh2=MEDCouplingDataForTest.build2DTargetMesh_3();
02662         renum2=[0,2,1,3,4,5,6,8,7,9,10]
02663         mesh2.renumberCells(renum,False);
02664         mesh2.renumberNodes(renum2,11);
02665         cellCor=None
02666         nodeCor=None
02667         self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails
02668         self.assertTrue(cellCor==None);
02669         self.assertTrue(nodeCor==None);
02670         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything
02671         self.assertTrue(cellCor==None);
02672         self.assertTrue(nodeCor==None);
02673         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12);#deepEqual with geo permutations
02674         self.assertTrue(cellCor);
02675         self.assertEqual(10,cellCor.getNumberOfTuples());
02676         self.assertEqual(1,cellCor.getNumberOfComponents());
02677         self.assertEqual(renum,list(cellCor.getValues()))
02678         self.assertTrue(nodeCor);
02679         self.assertEqual(11,nodeCor.getNumberOfTuples());
02680         self.assertEqual(1,nodeCor.getNumberOfComponents());
02681         self.assertEqual(renum2,list(nodeCor.getValues()))
02682         cellCor=0;
02683         nodeCor=0;
02684         #5th test : modification of the last cell to check fastCheck detection.
02685         mesh2=MEDCouplingDataForTest.build2DTargetMesh_3();
02686         renum3=[0,2,1,3,4,5,6,8,9,7]
02687         mesh2.renumberCells(renum3,False);
02688         mesh2.renumberNodes(renum2,11);
02689         cellCor=None
02690         nodeCor=None
02691         self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12)
02692         self.assertTrue(cellCor==None);
02693         self.assertTrue(nodeCor==None);
02694         self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,1,1e-12)
02695         self.assertTrue(cellCor==None);
02696         self.assertTrue(nodeCor==None);
02697         cellCor,nodeCor=mesh2.checkGeoEquivalWith(mesh1,10,1e-12);#deepEqual with geo permutations
02698         self.assertTrue(cellCor!=None);
02699         self.assertEqual(10,cellCor.getNumberOfTuples());
02700         self.assertEqual(1,cellCor.getNumberOfComponents());
02701         self.assertEqual(renum3,list(cellCor.getValues()))
02702         self.assertTrue(nodeCor!=None);
02703         self.assertEqual(11,nodeCor.getNumberOfTuples());
02704         self.assertEqual(1,nodeCor.getNumberOfComponents());
02705         self.assertEqual(renum2,list(nodeCor.getValues()));
02706         pass

Definition at line 2707 of file MEDCouplingBasicsTest.py.

02707 
02708     def testCheckGeoEquivalWith2(self):
02709         mesh1=MEDCouplingDataForTest.build2DTargetMesh_4();
02710         mesh2=MEDCouplingDataForTest.build2DTargetMesh_1();
02711         cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,10,1e-12);
02712         self.assertEqual(None,cellCor);
02713         self.assertNotEqual(None,nodeCor);
02714         expected1=[0, 1, 3, 4, 5, 6, 7, 8, 9]
02715         for i in xrange(9):
02716             self.assertEqual(expected1[i],nodeCor.getIJ(i,0));
02717             pass
02718         pass

Definition at line 1654 of file MEDCouplingBasicsTest.py.

01654 
01655     def testCMesh0(self):
01656         mesh=MEDCouplingCMesh.New();
01657         meshEmpty=mesh.clone(True);
01658         self.assertTrue(meshEmpty.isEqual(mesh, 1e-12));
01659         
01660         coordsX=DataArrayDouble.New();
01661         arrX=[ -1., 1., 2., 4. ]
01662         coordsX.setValues(arrX, 4, 1);
01663         coordsY=DataArrayDouble.New();
01664         arrY=[ -2., 2., 4., 8. ]
01665         coordsY.setValues(arrY, 4, 1);
01666         coordsZ=DataArrayDouble.New();
01667         arrZ=[ -3., 3., 6., 12. ]
01668         coordsZ.setValues(arrZ, 4, 1);
01669         mesh.setCoords(coordsX, coordsY, coordsZ);
01670         #
01671         fieldOnNodes=mesh.fillFromAnalytic(ON_NODES, 1, "x+y/2.+z/3.");
01672         self.assertEqual(1, fieldOnNodes.getNumberOfComponents());
01673         self.assertEqual(64, fieldOnNodes.getNumberOfTuples());
01674         expected1=[-3., -1., 0., 2., -1., 1., 2., 4., 0., 2., 3., 5., 2., 4., 5., 7., -1., 1., 2.,
01675                     4., 1., 3., 4., 6., 2., 4., 5., 7., 4., 6., 7., 9., 0., 2., 3., 5., 2., 4., 5.,
01676                     7., 3., 5., 6., 8., 5., 7., 8., 10., 2., 4., 5.,
01677                     7., 4., 6., 7., 9., 5., 7., 8., 10., 7., 9., 10., 12.];
01678         
01679         val=fieldOnNodes.getArray().getValues();
01680         for i in xrange(64):
01681           self.assertAlmostEqual(expected1[i], val[i], 12)
01682         res=fieldOnNodes.getValueOnPos(1, 3, 2);
01683         self.assertAlmostEqual(7., res[0], 12);
01684         #
01685         fieldOnCells=mesh.fillFromAnalytic(ON_CELLS, 1, "x+y/2.+z/3.");
01686         self.assertEqual(1, fieldOnCells.getNumberOfComponents());
01687         self.assertEqual(27, fieldOnCells.getNumberOfTuples());
01688         val=fieldOnCells.getArray().getValues();
01689         expected2=[0, 1.5, 3, 1.5, 3, 4.5, 3, 4.5, 6, 1.5, 3, 4.5, 3, 4.5,
01690                     6, 4.5, 6, 7.5, 3, 4.5, 6, 4.5, 6, 7.5, 6, 7.5, 9];
01691         for i in xrange(27):
01692           self.assertAlmostEqual(expected2[i], val[i], 12);
01693         #res=fieldOnCells.getValueOnPos(1,2,1);
01694         #self.assertAlmostEqual(6.,res,12);
01695         #
01696         meshDeepCopy=mesh.deepCpy();
01697         meshClone=mesh.clone(False);
01698         
01699         meshEmpty.copyTinyStringsFrom(mesh);
01700         #no data in meshEmpty, expected False
01701         self.assertTrue(not meshEmpty.isEqual(mesh, 1e-12));
01702         
01703         self.assertTrue(meshDeepCopy.isEqual(mesh, 1e-12));
01704         meshDeepCopy.copyTinyStringsFrom(mesh);
01705         self.assertTrue(meshDeepCopy.isEqual(mesh, 1e-12));
01706         self.assertTrue(meshClone.isEqual(mesh, 1e-12));
01707         
01708         self.assertEqual(CARTESIAN, mesh.getType());
01709         self.assertEqual(CARTESIAN, meshEmpty.getType());
01710         self.assertEqual(CARTESIAN, meshDeepCopy.getType());
01711         self.assertEqual(CARTESIAN, meshClone.getType());
01712         pass

Definition at line 1713 of file MEDCouplingBasicsTest.py.

01713 
01714     def testCMesh1(self):
01715         mesh1=MEDCouplingCMesh.New();
01716         coordsX1=DataArrayDouble.New();
01717         arrX1=[ -1., 1., 2., 4. ]
01718         coordsX1.setValues(arrX1, 4, 1);
01719         coordsY1=DataArrayDouble.New();
01720         arrY1=[ -2., 2., 4., 8. ]
01721         coordsY1.setValues(arrY1, 4, 1);
01722         coordsZ1=DataArrayDouble.New();
01723         arrZ1=[ -3., 3., 6., 12. ]
01724         coordsZ1.setValues(arrZ1, 4, 1);
01725         mesh1.setCoords(coordsX1, coordsY1, coordsZ1);
01726         
01727         mesh2=MEDCouplingCMesh.New();
01728         coordsX2=DataArrayDouble.New();
01729         arrX2=[ -1., 1., 2., 4. ]
01730         coordsX2.setValues(arrX2, 4, 1);
01731         coordsY2=DataArrayDouble.New();
01732         arrY2=[ -2., 2., 4., 8. ]
01733         coordsY2.setValues(arrY2, 4, 1);
01734         coordsZ2=DataArrayDouble.New();
01735         arrZ2=[ -3., 3., 6., 12.+1e-6 ]
01736         coordsZ2.setValues(arrZ2, 4, 1);
01737         mesh2.setCoords(coordsX2, coordsY2, coordsZ2);
01738         
01739         mesh3=MEDCouplingCMesh.New();
01740         coordsX3=DataArrayDouble.New();
01741         arrX3=[-1.]
01742         coordsX3.setValues(arrX3, 1, 1);
01743         coordsY3=DataArrayDouble.New();
01744         arrY3=[-2.]
01745         coordsY3.setValues(arrY3, 1, 1);
01746         coordsZ3=DataArrayDouble.New();
01747         arrZ3=[-3.]
01748         coordsZ3.setValues(arrZ3, 1, 1);
01749         mesh3.setCoords(coordsX3, coordsY3, coordsZ3);
01750         
01751         self.assertEqual(3, mesh1.getSpaceDimension());
01752         self.assertEqual(3, mesh1.getMeshDimension());
01753         
01754         self.assertTrue(not mesh1.isEqual(mesh2, 1e-12));
01755         self.assertTrue(not mesh2.isEqual(mesh1, 1e-12));
01756         self.assertTrue(not mesh2.isEqualWithoutConsideringStr(mesh1, 1e-12));
01757         self.assertTrue(mesh1.isEqual(mesh2, 1e-5));
01758         self.assertTrue(not mesh1.isEqual(mesh2, 1e-7));
01759         
01760         self.assertRaises(InterpKernelException, mesh3.checkCoherency1, 1e-12);
01761         mesh1.checkCoherency2(1e-12);
01762         self.assertEqual(NORM_HEXA8, mesh1.getTypeOfCell(1));
01763         
01764         self.assertEqual(NORM_HEXA8, mesh1.getAllGeoTypes()[0]);
01765         self.assertEqual(27, mesh1.getNumberOfCellsWithType(NORM_HEXA8));
01766         self.assertRaises(InterpKernelException, mesh1.getNumberOfCellsWithType, NORM_QUAD4);
01767         
01768         coo=mesh1.getCoordinatesOfNode(0);
01769         self.assertEqual(3, len(coo));
01770         self.assertAlmostEqual(-1., coo[0], 14);
01771         self.assertAlmostEqual(-2., coo[1], 14);
01772         self.assertAlmostEqual(-3., coo[2], 14);
01773         coo=mesh1.getCoordinatesOfNode(63);
01774         self.assertEqual(3, len(coo));
01775         self.assertAlmostEqual(4., coo[0], 14);
01776         self.assertAlmostEqual(8., coo[1], 14);
01777         self.assertAlmostEqual(12., coo[2], 14);
01778         
01779         a=str(mesh1)
01780         repr=mesh1.simpleRepr();
01781         repr=mesh1.advancedRepr();
01782         self.assertTrue("Cartesian" in repr);
01783         self.assertTrue("Number of components : 1" in repr);
01784         self.assertTrue("Number of tuples : 4" in repr);
01785         self.assertTrue("Z Array :" in repr);
01786         pass

Definition at line 1787 of file MEDCouplingBasicsTest.py.

01787 
01788     def testCMesh2(self):
01789         mesh1=MEDCouplingCMesh.New();
01790         coordsX1=DataArrayDouble.New();
01791         arrX1=[ -1., 1., 2., 4. ]
01792         coordsX1.setValues(arrX1, 4, 1);
01793         coordsY1=DataArrayDouble.New();
01794         arrY1=[ -2., 2., 4., 8. ]
01795         coordsY1.setValues(arrY1, 4, 1);
01796         coordsZ1=DataArrayDouble.New();
01797         arrZ1=[ -3., 3., 6., 12. ]
01798         coordsZ1.setValues(arrZ1, 4, 1);
01799         mesh1.setCoords(coordsX1, coordsY1, coordsZ1);
01800         
01801         dis=mesh1.getDistributionOfTypes();
01802         self.assertEqual(3, len(dis));
01803         self.assertEqual(NORM_HEXA8, dis[0]);
01804         self.assertEqual(27, dis[1]);
01805         self.assertEqual(0, dis[2]);
01806         
01807         idsPerType=[]
01808         self.assertRaises(InterpKernelException, mesh1.checkTypeConsistencyAndContig, dis, idsPerType);
01809         dis[2]=-1;
01810         idsPerType=[]
01811         self.assertTrue(not mesh1.checkTypeConsistencyAndContig(dis, idsPerType));
01812         dis[0]=NORM_QUAD4;
01813         self.assertRaises(InterpKernelException, mesh1.checkTypeConsistencyAndContig, dis, idsPerType);
01814         
01815         dis[0]=NORM_HEXA8;
01816         dis[2]=0;
01817         ids=DataArrayInt.New();
01818         ids.alloc(10, 1);
01819         ids.fillWithValue(111);
01820         idsPerType=[ids];
01821         check=mesh1.checkTypeConsistencyAndContig(dis, idsPerType);
01822         self.assertTrue(check);
01823         self.assertTrue(check.isEqual(ids));
01824         
01825         code, idsInPflPerType, pfls=mesh1.splitProfilePerType(ids);
01826         self.assertEqual(3, len(code));
01827         self.assertEqual(NORM_HEXA8, code[0]);
01828         self.assertEqual(27, code[1]);
01829         self.assertEqual(0, code[2]);
01830         self.assertEqual(1, len(idsInPflPerType));
01831         self.assertEqual(1, len(pfls));
01832         self.assertTrue(idsInPflPerType[0].isEqual(ids));
01833         self.assertTrue(pfls[0].isEqual(ids));
01834         
01835         cells1=[0, 1, 25, 26]
01836         partMesh1=mesh1.buildPart(cells1)
01837         self.assertTrue(isinstance(partMesh1,MEDCouplingMesh))
01838         self.assertEqual(4, partMesh1.getNumberOfCellsWithType(NORM_HEXA8));
01839         self.assertEqual(64, mesh1.getNumberOfNodes());
01840         self.assertEqual(64, partMesh1.getNumberOfNodes());
01841         
01842         cells2=[25, 26]
01843         partMesh2, arr1=mesh1.buildPartAndReduceNodes(cells2)
01844         self.assertTrue(isinstance(partMesh2,MEDCouplingUMesh))
01845         self.assertEqual(2,partMesh2.getNumberOfCellsWithType(NORM_HEXA8));
01846         self.assertEqual(12,partMesh2.getNumberOfNodes());
01847         
01848         cells3=[2, 3]
01849         partMesh3, arr2=partMesh1.buildPartAndReduceNodes(cells3)
01850         self.assertTrue(isinstance(partMesh3,MEDCouplingUMesh))
01851         self.assertEqual(2, partMesh3.getNumberOfCellsWithType(NORM_HEXA8));
01852         self.assertEqual(12, partMesh3.getNumberOfNodes());
01853         
01854         self.assertRaises(InterpKernelException, mesh1.simplexize, 0);
01855         self.assertRaises(InterpKernelException, mesh1.getMeasureFieldOnNode, True);
01856         
01857         #double bbox1[6];
01858         #double bbox2[6];
01859         bbox1=mesh1.getBoundingBox(); #[(-1.0, 4.0), (-2.0, 8.0), (-3.0, 12.0)]
01860         bbox2=partMesh1.getBoundingBox();
01861         self.assertTrue(bbox1==bbox2);
01862         bbox1=partMesh3.getBoundingBox();
01863         bbox2=partMesh2.getBoundingBox();
01864         self.assertTrue(bbox1==bbox2);
01865         
01866         self.assertRaises(InterpKernelException, mesh1.buildOrthogonalField);
01867         mesh2d=MEDCouplingCMesh.New();
01868         mesh2d.setCoords(coordsX1, coordsY1);
01869         f1=mesh2d.buildOrthogonalField();
01870         
01871         pass

Definition at line 9746 of file MEDCouplingBasicsTest.py.

09746 
09747     def testComputeNeighborsOfCells1(self):
09748         m=MEDCouplingDataForTest.build2DTargetMesh_1();
09749         d1,d2=m.computeNeighborsOfCells();
09750         self.assertEqual(6,d2.getNumberOfTuples());
09751         self.assertEqual(10,d1.getNumberOfTuples());
09752         expected1=[0,2,4,6,8,10]
09753         expected2=[3,1,0,2,4,1,4,0,2,3]
09754         self.assertEqual(expected1,d2.getValues());
09755         self.assertEqual(expected2,d1.getValues());
09756         pass

Definition at line 5274 of file MEDCouplingBasicsTest.py.

05274 
05275     def testConvertDegeneratedCells1(self):
05276         mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
05277         conn=[0,1,3,3,9,10,12,12, 0,1,3,4,9,9,9,9, 1,1,1,1,10,12,9,10, 10,11,12,9,1,1,1,1]
05278         mesh.allocateCells(4);
05279         mesh.insertNextCell(NORM_HEXA8,8,conn[0:8])
05280         mesh.insertNextCell(NORM_HEXA8,8,conn[8:16])
05281         mesh.insertNextCell(NORM_HEXA8,8,conn[16:24])
05282         mesh.insertNextCell(NORM_HEXA8,8,conn[24:32])
05283         mesh.finishInsertingCells();
05284         mesh.checkCoherency();
05285         self.assertEqual(4,mesh.getNumberOfCells());
05286         self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(0));
05287         self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(1));
05288         self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(2));
05289         self.assertEqual(NORM_HEXA8,mesh.getTypeOfCell(3));
05290         f1=mesh.getMeasureField(True);
05291         mesh.convertDegeneratedCells();
05292         mesh.checkCoherency();
05293         f2=mesh.getMeasureField(True);
05294         self.assertEqual(4,mesh.getNumberOfCells());
05295         self.assertEqual(NORM_PENTA6,mesh.getTypeOfCell(0));
05296         self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(1));
05297         self.assertEqual(NORM_TETRA4,mesh.getTypeOfCell(2));
05298         self.assertEqual(NORM_PYRA5,mesh.getTypeOfCell(3));
05299         for i in xrange(4):
05300             self.assertAlmostEqual(f1.getArray().getIJ(0,i),f2.getArray().getIJ(0,i),5);
05301             pass
05302         pass

Definition at line 8301 of file MEDCouplingBasicsTest.py.

08301 
08302     def testConvertExtrudedPolyhedra1(self):
08303         conn=[1,2,3,4, 5,6,7,8,9,10,11,12, 13,14,15,16, 17,18,19,20,21,22, 23,24,25,26,27,28, 29,30,31,32,33,34,35,36,37,38, 39,40,41,42,43,44,45,46, 47,48,49,50,51,52,53,54,55,56,57,58, 59,60,61,62,63,64,65,66,67,68,69,70,71,72]
08304         m=MEDCouplingUMesh.New("Example",3);
08305         coo=DataArrayDouble.New();
08306         coo.alloc(73,3);
08307         coo.rearrange(1); coo.iota(0); coo.rearrange(3);
08308         m.setCoords(coo);
08309         m.allocateCells(9);
08310         m.insertNextCell(NORM_TETRA4,4,conn[0:4])
08311         m.insertNextCell(NORM_HEXA8,8,conn[4:12])
08312         m.insertNextCell(NORM_TETRA4,4,conn[12:16])
08313         m.insertNextCell(NORM_POLYHED,6,conn[16:22])
08314         m.insertNextCell(NORM_PENTA6,6,conn[22:28])
08315         m.insertNextCell(NORM_POLYHED,10,conn[28:38])
08316         m.insertNextCell(NORM_HEXA8,8,conn[38:46])
08317         m.insertNextCell(NORM_HEXGP12,12,conn[46:58])
08318         m.insertNextCell(NORM_POLYHED,14,conn[58:72])
08319         m.finishInsertingCells();
08320         #
08321         m.convertExtrudedPolyhedra();
08322         da=m.getNodalConnectivity();
08323         dai=m.getNodalConnectivityIndex();
08324         self.assertEqual(10,dai.getNbOfElems());
08325         self.assertEqual(159,da.getNbOfElems());
08326         #
08327         expected1=[14, 1, 2, 3, 4,
08328                    18, 5, 6, 7, 8, 9, 10, 11, 12,
08329                    14, 13, 14, 15, 16,
08330                    31, 17, 18, 19, -1, 20, 22, 21, -1, 17, 18, 21, 20, -1, 18, 19, 22, 21, -1, 19, 17, 20, 22,
08331                    16, 23, 24, 25, 26, 27, 28,
08332                    31, 29, 30, 31, 32, 33, -1, 34, 38, 37, 36, 35, -1, 29, 30, 35, 34, -1, 30, 31, 36, 35, -1, 31, 32, 37, 36, -1, 32, 33, 38, 37, -1, 33, 29, 34, 38,
08333                    18, 39, 40, 41, 42, 43, 44, 45, 46,
08334                    22, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
08335                    31, 59, 60, 61, 62, 63, 64, 65, -1, 66, 72, 71, 70, 69, 68, 67, -1, 59, 60, 67, 66, -1, 60, 61, 68, 67, -1, 61, 62, 69, 68, -1, 62, 63, 70, 69, -1, 63, 64, 71, 70, -1, 64, 65, 72, 71, -1, 65, 59, 66, 72];
08336         expected2=[0,5,14,19,42,49,86,95,108,159]
08337         self.assertEqual(expected1,da.getValues());
08338         self.assertEqual(expected2,dai.getValues());
08339         m.checkCoherency2()
08340         pass

Definition at line 2591 of file MEDCouplingBasicsTest.py.

02591 
02592     def testConvertQuadraticCellsToLinear(self):
02593         mesh=MEDCouplingDataForTest.build2DTargetMesh_3();
02594         mesh.checkCoherency();
02595         types=mesh.getAllTypes();
02596         types.sort()
02597         self.assertEqual(5,len(types));
02598         expected1=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4, NORM_TRI6, NORM_QUAD8]
02599         expected1.sort()
02600         self.assertEqual(expected1,types);
02601         self.assertTrue(mesh.isPresenceOfQuadratic());
02602         self.assertEqual(62,mesh.getMeshLength());
02603         f1=mesh.getMeasureField(False);
02604         #
02605         mesh.convertQuadraticCellsToLinear();
02606         self.assertTrue(not mesh.isPresenceOfQuadratic());
02607         #
02608         mesh.checkCoherency();
02609         f2=mesh.getMeasureField(False);
02610         self.assertTrue(f1.getArray().isEqual(f2.getArray(),1e-12));
02611         self.assertEqual(48,mesh.getMeshLength());
02612         types2=mesh.getAllTypes();
02613         types2.sort()
02614         self.assertEqual(3,len(types2));
02615         expected2=[NORM_POLYGON, NORM_TRI3, NORM_QUAD4]
02616         expected2.sort()
02617         self.assertEqual(expected2,types2);
02618         pass

Definition at line 209 of file MEDCouplingBasicsTest.py.

00209 
00210     def testConvertToPolyTypes(self):
00211         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
00212         elts=[1,3];
00213         mesh.convertToPolyTypes(elts);
00214         mesh.checkCoherency();
00215         self.assertEqual(5,mesh.getNumberOfCells());
00216         self.assertEqual(23,mesh.getNodalConnectivity().getNumberOfTuples());
00217         expected1=[4, 0, 3, 4, 1, 5, 1, 4, 2, 3, 4, 5, 2, 5, 6, 7, 4, 3, 4, 7, 8, 5, 4]
00218         self.assertEqual(expected1,list(mesh.getNodalConnectivity().getValues()));
00219         #
00220         mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
00221         mesh.convertToPolyTypes(elts);
00222         mesh.checkCoherency();
00223         self.assertEqual(8,mesh.getNumberOfCells());
00224         self.assertEqual(114,mesh.getNodalConnectivity().getNumberOfTuples());
00225         mesh.convertToPolyTypes(elts);
00226         mesh.checkCoherency();
00227         self.assertEqual(8,mesh.getNumberOfCells());
00228         self.assertEqual(114,mesh.getNodalConnectivity().getNumberOfTuples());
00229         pass

Definition at line 2719 of file MEDCouplingBasicsTest.py.

02719 
02720     def testCopyTinyStringsFromOnFields(self):
02721         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
02722         nbOfCells=m.getNumberOfCells();
02723         f=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
02724         f.setMesh(m);
02725         self.assertEqual(5,f.getNumberOfMeshPlacesExpected());
02726         f.setName("a");
02727         f.setDescription("b");
02728         a1=DataArrayDouble.New();
02729         a1.alloc(nbOfCells,2);
02730         a1.fillWithZero();
02731         a1.setInfoOnComponent(0,"c");
02732         a1.setInfoOnComponent(1,"d");
02733         a2=a1.deepCpy();
02734         a2.setInfoOnComponent(0,"e");
02735         a2.setInfoOnComponent(1,"f");
02736         f.setArray(a1);
02737         f.setEndArray(a2);
02738         f.setEndTime(3.,3,4);
02739         m.setName("g");
02740         m.getCoords().setInfoOnComponent(0,"h");
02741         m.getCoords().setInfoOnComponent(1,"i");
02742         m.getCoords().setInfoOnComponent(2,"j");
02743         #
02744         f.checkCoherency();
02745         f2=f.clone(True);
02746         self.assertTrue(f2.isEqual(f,1e-12,1e-12));
02747         f2.setName("smth");
02748         self.assertTrue(not f2.isEqual(f,1e-12,1e-12));
02749         f2.copyTinyStringsFrom(f);
02750         self.assertTrue(f2.isEqual(f,1e-12,1e-12));
02751         f2.setDescription("GGG");
02752         self.assertTrue(not f2.isEqual(f,1e-12,1e-12));
02753         f2.copyTinyStringsFrom(f);
02754         self.assertTrue(f2.isEqual(f,1e-12,1e-12));
02755         f2.getArray().setInfoOnComponent(0,"mmmm");
02756         self.assertTrue(not f2.isEqual(f,1e-12,1e-12));
02757         f2.copyTinyStringsFrom(f);
02758         self.assertTrue(f2.isEqual(f,1e-12,1e-12));
02759         f2.getEndArray().setInfoOnComponent(1,"mmmm");
02760         self.assertTrue(not f2.isEqual(f,1e-12,1e-12));
02761         f2.copyTinyStringsFrom(f);
02762         self.assertTrue(f2.isEqual(f,1e-12,1e-12));
02763         m2=m.clone(True);
02764         self.assertTrue(m2.isEqual(m,1e-12));
02765         m2.setName("123");
02766         self.assertTrue(not m2.isEqual(m,1e-12));
02767         m2.copyTinyStringsFrom(m);
02768         self.assertTrue(m2.isEqual(m,1e-12));
02769         m2.getCoords().setInfoOnComponent(1,"eee");
02770         self.assertTrue(not m2.isEqual(m,1e-12));
02771         m2.copyTinyStringsFrom(m);
02772         self.assertTrue(m2.isEqual(m,1e-12));
02773         pass

Definition at line 8469 of file MEDCouplingBasicsTest.py.

08469 
08470     def testDABack1(self):
08471         da=DataArrayDouble.New();
08472         array1=[2.3,1.2,1.3,2.3,2.301,0.8]
08473         da.setValues(array1,6,1);
08474         self.assertAlmostEqual(0.8,da.back(),14);
08475         da.rearrange(2);
08476         self.assertRaises(InterpKernelException,da.back);
08477         da.alloc(0,1);
08478         self.assertRaises(InterpKernelException,da.back);
08479         #
08480         da=DataArrayInt.New();
08481         array2=[4,7,8,2]
08482         da.setValues(array2,4,1);
08483         self.assertEqual(2,da.back());
08484         da.rearrange(2);
08485         self.assertRaises(InterpKernelException,da.back);
08486         da.alloc(0,1);
08487         self.assertRaises(InterpKernelException,da.back);
08488         pass

Definition at line 7772 of file MEDCouplingBasicsTest.py.

07772 
07773     def testDACpyFrom1(self):
07774         d=DataArrayDouble.New();
07775         d.alloc(12,1);
07776         d.iota(14.);
07777         d.rearrange(3);
07778         d.setName("Toto");
07779         d.setInfoOnComponent(0,"X [m]");
07780         d.setInfoOnComponent(1,"Y [m]");
07781         d.setInfoOnComponent(2,"Z [m]");
07782         #
07783         d1=DataArrayDouble.New();
07784         self.assertTrue(not d.isEqual(d1,1e-12));
07785         d1.cpyFrom(d);
07786         self.assertTrue(d.isEqual(d1,1e-12));
07787         d1.cpyFrom(d);
07788         self.assertTrue(d.isEqual(d1,1e-12));
07789         d1.rearrange(2);
07790         self.assertTrue(not d.isEqual(d1,1e-12));
07791         d1.cpyFrom(d);
07792         self.assertTrue(d.isEqual(d1,1e-12));
07793         #
07794         d2=d.convertToIntArr();
07795         d4=DataArrayInt.New();
07796         self.assertTrue(not d2.isEqual(d4));
07797         d4.cpyFrom(d2);
07798         self.assertTrue(d2.isEqual(d4));
07799         d4.cpyFrom(d2);
07800         self.assertTrue(d2.isEqual(d4));
07801         d4.rearrange(2);
07802         self.assertTrue(not d2.isEqual(d4));
07803         d4.cpyFrom(d2);
07804         self.assertTrue(d2.isEqual(d4));
07805         pass

Definition at line 7692 of file MEDCouplingBasicsTest.py.

07692 
07693     def testDADCheckIsMonotonic(self):
07694         da=DataArrayDouble.New();
07695         da.setValues([-1.,1.01,2.03,6.],2,2);
07696         self.assertRaises(InterpKernelException,da.isMonotonic,True,1e-12);
07697         da.rearrange(1);
07698         self.assertTrue(da.isMonotonic(True,1e-12));
07699         da.checkMonotonic(True,1e-12);
07700         da.setIJ(2,0,6.1);
07701         self.assertTrue(not da.isMonotonic(True,1e-12));
07702         self.assertRaises(InterpKernelException,da.checkMonotonic,True,1e-12);
07703         da.setIJ(2,0,5.99);
07704         self.assertTrue(da.isMonotonic(True,1e-12));
07705         self.assertTrue(not da.isMonotonic(True,1e-1));
07706         pass

Definition at line 8411 of file MEDCouplingBasicsTest.py.

08411 
08412     def testDADFindCommonTuples1(self):
08413         da=DataArrayDouble.New();
08414         # nbOftuples=1
08415         array1=[2.3,1.2,1.3,2.3,2.301,0.8]
08416         da.setValues(array1,6,1)
08417         c,cI=da.findCommonTuples(1e-2);
08418         expected1=[0,3,4]
08419         expected2=[0,3]
08420         self.assertEqual(3,c.getNbOfElems());
08421         self.assertEqual(2,cI.getNbOfElems());
08422         self.assertEqual(expected1,c.getValues())
08423         self.assertEqual(expected2,cI.getValues())
08424         c,cI=da.findCommonTuples(2e-1)
08425         expected3=[0,3,4,1,2]
08426         expected4=[0,3,5]
08427         self.assertEqual(5,c.getNbOfElems());
08428         self.assertEqual(3,cI.getNbOfElems());
08429         self.assertEqual(expected3,c.getValues())
08430         self.assertEqual(expected4,cI.getValues())
08431         # nbOftuples=2
08432         array2=[2.3,2.3,1.2,1.2,1.3,1.3,2.3,2.3,2.301,2.301,0.8,0.8]
08433         da.setValues(array2,6,2)
08434         c,cI=da.findCommonTuples(1e-2);
08435         self.assertEqual(3,c.getNbOfElems());
08436         self.assertEqual(2,cI.getNbOfElems());
08437         self.assertEqual(expected1,c.getValues())
08438         self.assertEqual(expected2,cI.getValues())
08439         c,cI=da.findCommonTuples(2e-1)
08440         self.assertEqual(5,c.getNbOfElems());
08441         self.assertEqual(3,cI.getNbOfElems());
08442         self.assertEqual(expected3,c.getValues())
08443         self.assertEqual(expected4,cI.getValues())
08444         # nbOftuples=3
08445         array3=[2.3,2.3,2.3,1.2,1.2,1.2,1.3,1.3,1.3,2.3,2.3,2.3,2.301,2.301,2.301,0.8,0.8,0.8]
08446         da.setValues(array3,6,3)
08447         c,cI=da.findCommonTuples(1e-2);
08448         self.assertEqual(3,c.getNbOfElems());
08449         self.assertEqual(2,cI.getNbOfElems());
08450         self.assertEqual(expected1,c.getValues())
08451         self.assertEqual(expected2,cI.getValues())
08452         c,cI=da.findCommonTuples(2e-1)
08453         self.assertEqual(5,c.getNbOfElems());
08454         self.assertEqual(3,cI.getNbOfElems());
08455         self.assertEqual(expected3,c.getValues())
08456         self.assertEqual(expected4,cI.getValues())
08457         # nbOftuples=1, no common groups
08458         array11=[2.3,1.2,1.3,2.4,2.5,0.8]
08459         da.setValues(array11,6,1)
08460         c,cI=da.findCommonTuples(1e-2);
08461         self.assertEqual(0,c.getNbOfElems());
08462         self.assertEqual(1,cI.getNbOfElems());
08463         self.assertEqual([0],cI.getValues())
08464         
08465         array12=[0.]*(6*4)
08466         da.setValues(array12,6,4) #bad NumberOfComponents
08467         self.assertRaises(InterpKernelException, da.findCommonTuples, 1e-2);
08468         pass

Definition at line 5211 of file MEDCouplingBasicsTest.py.

05211 
05212     def testDADFromCylToCart1(self):
05213         tab1=[2.,0.2,4.,2.5,0.7,9.]
05214         da=DataArrayDouble.New();
05215         da.setValues(tab1,2,3);
05216         da2=da.fromCylToCart();
05217         expected1=[1.9601331556824833,0.39733866159012243,4., 1.9121054682112213,1.6105442180942275,9.]
05218         for i in xrange(6):
05219             self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13);
05220             pass
05221         pass
    

Definition at line 5200 of file MEDCouplingBasicsTest.py.

05200 
05201     def testDADFromPolarToCart1(self):
05202         tab1=[2.,0.2,2.5,0.7]
05203         da=DataArrayDouble.New();
05204         da.setValues(tab1,2,2);
05205         da2=da.fromPolarToCart();
05206         expected1=[1.9601331556824833,0.39733866159012243, 1.9121054682112213,1.6105442180942275]
05207         for i in xrange(4):
05208             self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13);
05209             pass
05210         pass
    

Definition at line 5222 of file MEDCouplingBasicsTest.py.

05222 
05223     def testDADFromSpherToCart1(self):
05224         tab1=[2.,0.2,0.3,2.5,0.7,0.8]
05225         da=DataArrayDouble.New();
05226         da.setValues(tab1,2,3);
05227         da2=da.fromSpherToCart();
05228         expected1=[0.37959212195737485,0.11742160338765303,1.9601331556824833, 1.1220769624465328,1.1553337045129035,1.9121054682112213]
05229         for i in xrange(6):
05230             self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),13);
05231             pass
05232         pass

Definition at line 8489 of file MEDCouplingBasicsTest.py.

08489 
08490     def testDADGetDifferentValues1(self):
08491         da=DataArrayDouble.New();
08492         array1=[2.3,1.2,1.3,2.3,2.301,0.8]
08493         da.setValues(array1,6,1)
08494         #
08495         expected1=[2.301,1.2,1.3,0.8]
08496         dv=da.getDifferentValues(1e-2);
08497         self.assertEqual(4,dv.getNbOfElems());
08498         for i in xrange(4):
08499             self.assertAlmostEqual(expected1[i],dv.getIJ(i,0),14);
08500             pass
08501         #
08502         dv=da.getDifferentValues(2e-1);
08503         expected2=[2.301,1.3,0.8]
08504         self.assertEqual(3,dv.getNbOfElems());
08505         for i in xrange(3):
08506             self.assertAlmostEqual(expected2[i],dv.getIJ(i,0),14);
08507             pass
08508         pass

Definition at line 8524 of file MEDCouplingBasicsTest.py.

08524 
08525     def testDADIReverse1(self):
08526         arr=[0,3,5,7,9,2]
08527         a=DataArrayInt.New();
08528         a.setValues(arr,6,1);
08529         self.assertEqual(2,a.back());
08530         a.reverse();
08531         for i in xrange(6):
08532             self.assertEqual(arr[5-i],a.getIJ(i,0));
08533             pass
08534         a.setValues(arr[:-1],5,1);
08535         a.reverse();
08536         for i in xrange(5):
08537             self.assertEqual(arr[4-i],a.getIJ(i,0));
08538             pass
08539         #
08540         arr2=[0.,3.,5.,7.,9.,2.]
08541         b=DataArrayDouble.New();
08542         b.setValues(arr2,6,1);
08543         b.reverse();
08544         for i in xrange(6):
08545             self.assertAlmostEqual(arr2[5-i],b.getIJ(i,0),14);
08546             pass
08547         b.setValues(arr2,5,1);
08548         self.assertAlmostEqual(9.,b.back(),14)
08549         b.reverse();
08550         for i in xrange(5):
08551             self.assertAlmostEqual(arr2[4-i],b.getIJ(i,0),14);
08552             pass
08553         pass

Definition at line 4214 of file MEDCouplingBasicsTest.py.

04214 
04215     def testDaDoubleGetMinMaxValues1(self):
04216         a=DataArrayDouble.New();
04217         arr1=[2.34,4.56,-6.77,4.55,4.56,2.24,2.34,1.02,4.56]
04218         a.setValues(arr1,9,1);
04219         m,where=a.getMaxValue();
04220         self.assertEqual(1,where);
04221         self.assertAlmostEqual(4.56,m,12);
04222         m,ws=a.getMaxValue2();
04223         self.assertAlmostEqual(4.56,m,12);
04224         self.assertEqual(3,ws.getNumberOfTuples());
04225         self.assertEqual(1,ws.getNumberOfComponents());
04226         expected1=[1,4,8]
04227         for i in xrange(3):
04228             self.assertEqual(expected1[i],ws.getIJ(i,0));
04229             pass
04230         a=DataArrayDouble.New();
04231         arr2=[-2.34,-4.56,6.77,-4.55,-4.56,-2.24,-2.34,-1.02,-4.56]
04232         a.setValues(arr2,9,1);
04233         m,where=a.getMinValue();
04234         self.assertEqual(1,where);
04235         self.assertAlmostEqual(-4.56,m,12);
04236         m,ws=a.getMinValue2();
04237         self.assertAlmostEqual(-4.56,m,12);
04238         self.assertEqual(3,ws.getNumberOfTuples());
04239         self.assertEqual(1,ws.getNumberOfComponents());
04240         for i in xrange(3):
04241             self.assertEqual(expected1[i],ws.getIJ(i,0));
04242             pass
04243         pass

Definition at line 4026 of file MEDCouplingBasicsTest.py.

04026 
04027     def testDaDoubleRenumber1(self):
04028         a=DataArrayDouble.New();
04029         arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
04030         a.setValues(arr1,7,2);
04031         a.setInfoOnComponent(0,"toto");
04032         a.setInfoOnComponent(1,"tata");
04033         #
04034         arr2=[3,1,0,6,5,4,2]
04035         b=a.renumber(arr2);
04036         self.assertEqual(7,b.getNumberOfTuples());
04037         self.assertEqual(2,b.getNumberOfComponents());
04038         self.assertTrue(b.getInfoOnComponent(0)=="toto");
04039         self.assertTrue(b.getInfoOnComponent(1)=="tata");
04040         expected1=[3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1]
04041         for i in xrange(14):
04042             self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
04043             pass
04044         #
04045         c=DataArrayInt.New();
04046         arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
04047         c.setValues(arr3,7,2);
04048         c.setInfoOnComponent(0,"toto");
04049         c.setInfoOnComponent(1,"tata");
04050         d=c.renumber(arr2);
04051         self.assertEqual(7,d.getNumberOfTuples());
04052         self.assertEqual(2,d.getNumberOfComponents());
04053         self.assertTrue(d.getInfoOnComponent(0)=="toto");
04054         self.assertTrue(d.getInfoOnComponent(1)=="tata");
04055         expected2=[3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14]
04056         for i in xrange(14):
04057             self.assertEqual(expected2[i],d.getIJ(0,i));
04058             pass
04059         pass

Definition at line 4060 of file MEDCouplingBasicsTest.py.

04060 
04061     def testDaDoubleRenumberAndReduce1(self):
04062         a=DataArrayDouble.New();
04063         arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
04064         a.setValues(arr1,7,2);
04065         a.setInfoOnComponent(0,"toto");
04066         a.setInfoOnComponent(1,"tata");
04067         #
04068         arr2=[2,-1,1,-1,0,4,3]
04069         b=a.renumberAndReduce(arr2,5);
04070         self.assertEqual(5,b.getNumberOfTuples());
04071         self.assertEqual(2,b.getNumberOfComponents());
04072         self.assertTrue(b.getInfoOnComponent(0)=="toto");
04073         self.assertTrue(b.getInfoOnComponent(1)=="tata");
04074         expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
04075         for i in xrange(10):
04076             self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
04077             pass
04078         #
04079         c=DataArrayInt.New();
04080         arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
04081         c.setValues(arr3,7,2);
04082         c.setInfoOnComponent(0,"toto");
04083         c.setInfoOnComponent(1,"tata");
04084         d=c.renumberAndReduce(arr2,5);
04085         self.assertEqual(5,d.getNumberOfTuples());
04086         self.assertEqual(2,d.getNumberOfComponents());
04087         self.assertTrue(d.getInfoOnComponent(0)=="toto");
04088         self.assertTrue(d.getInfoOnComponent(1)=="tata");
04089         expected2=[5,15,3,13,1,11,7,17,6,16]
04090         for i in xrange(10):
04091             self.assertEqual(expected2[i],d.getIJ(0,i));
04092             pass
04093         pass

Definition at line 4094 of file MEDCouplingBasicsTest.py.

04094 
04095     def testDaDoubleRenumberInPlace1(self):
04096         a=DataArrayDouble.New();
04097         arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
04098         a.setValues(arr1,7,2);
04099         #
04100         arr2=[3,1,0,6,5,4,2]
04101         a.renumberInPlace(arr2);
04102         self.assertEqual(7,a.getNumberOfTuples());
04103         self.assertEqual(2,a.getNumberOfComponents());
04104         expected1=[3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1]
04105         for i in xrange(14):
04106             self.assertAlmostEqual(expected1[i],a.getIJ(0,i),14);
04107             pass
04108         #
04109         c=DataArrayInt.New();
04110         arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
04111         c.setValues(arr3,7,2);
04112         c.renumberInPlace(arr2);
04113         self.assertEqual(7,c.getNumberOfTuples());
04114         self.assertEqual(2,c.getNumberOfComponents());
04115         expected2=[3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14]
04116         for i in xrange(14):
04117             self.assertEqual(expected2[i],c.getIJ(0,i));
04118             pass
04119         pass

Definition at line 4154 of file MEDCouplingBasicsTest.py.

04154 
04155     def testDaDoubleRenumberInPlaceR1(self):
04156         a=DataArrayDouble.New();
04157         arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
04158         a.setValues(arr1,7,2);
04159         #
04160         arr2=[3,1,0,6,5,4,2]
04161         a.renumberInPlaceR(arr2);
04162         self.assertEqual(7,a.getNumberOfTuples());
04163         self.assertEqual(2,a.getNumberOfComponents());
04164         expected1=[4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1]
04165         for i in xrange(14):
04166             self.assertAlmostEqual(expected1[i],a.getIJ(0,i),14);
04167             pass
04168         #
04169         c=DataArrayInt.New();
04170         arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
04171         c.setValues(arr3,7,2);
04172         c.renumberInPlaceR(arr2);
04173         self.assertEqual(7,c.getNumberOfTuples());
04174         self.assertEqual(2,c.getNumberOfComponents());
04175         expected2=[4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13]
04176         for i in xrange(14):
04177             self.assertEqual(expected2[i],c.getIJ(0,i));
04178             pass
04179         pass

Definition at line 4120 of file MEDCouplingBasicsTest.py.

04120 
04121     def testDaDoubleRenumberR1(self):
04122         a=DataArrayDouble.New();
04123         arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
04124         a.setValues(arr1,7,2);
04125         a.setInfoOnComponent(0,"toto");
04126         a.setInfoOnComponent(1,"tata");
04127         #
04128         arr2=[3,1,0,6,5,4,2]
04129         b=a.renumberR(arr2);
04130         self.assertEqual(7,b.getNumberOfTuples());
04131         self.assertEqual(2,b.getNumberOfComponents());
04132         self.assertTrue(b.getInfoOnComponent(0)=="toto");
04133         self.assertTrue(b.getInfoOnComponent(1)=="tata");
04134         expected1=[4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1]
04135         for i in xrange(14):
04136             self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
04137             pass
04138         #
04139         c=DataArrayInt.New();
04140         arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
04141         c.setValues(arr3,7,2);
04142         c.setInfoOnComponent(0,"toto");
04143         c.setInfoOnComponent(1,"tata");
04144         d=c.renumberR(arr2);
04145         self.assertEqual(7,d.getNumberOfTuples());
04146         self.assertEqual(2,d.getNumberOfComponents());
04147         self.assertTrue(d.getInfoOnComponent(0)=="toto");
04148         self.assertTrue(d.getInfoOnComponent(1)=="tata");
04149         expected2=[4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13]
04150         for i in xrange(14):
04151             self.assertEqual(expected2[i],d.getIJ(0,i));
04152             pass
04153         pass

Definition at line 4180 of file MEDCouplingBasicsTest.py.

04180 
04181     def testDaDoubleSelectByTupleId1(self):
04182         a=DataArrayDouble.New();
04183         arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
04184         a.setValues(arr1,7,2);
04185         a.setInfoOnComponent(0,"toto");
04186         a.setInfoOnComponent(1,"tata");
04187         #
04188         arr2=[4,2,0,6,5]
04189         b=a.selectByTupleId(arr2);
04190         self.assertEqual(5,b.getNumberOfTuples());
04191         self.assertEqual(2,b.getNumberOfComponents());
04192         self.assertTrue(b.getInfoOnComponent(0)=="toto");
04193         self.assertTrue(b.getInfoOnComponent(1)=="tata");
04194         expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
04195         for i in xrange(10):
04196             self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
04197             pass
04198         #
04199         c=DataArrayInt.New();
04200         arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
04201         c.setValues(arr3,7,2);
04202         c.setInfoOnComponent(0,"toto");
04203         c.setInfoOnComponent(1,"tata");
04204         d=c.selectByTupleId(arr2);
04205         self.assertEqual(5,d.getNumberOfTuples());
04206         self.assertEqual(2,d.getNumberOfComponents());
04207         self.assertTrue(d.getInfoOnComponent(0)=="toto");
04208         self.assertTrue(d.getInfoOnComponent(1)=="tata");
04209         expected2=[5,15,3,13,1,11,7,17,6,16]
04210         for i in xrange(10):
04211             self.assertEqual(expected2[i],d.getIJ(0,i));
04212             pass
04213         pass

Definition at line 5852 of file MEDCouplingBasicsTest.py.

05852 
05853     def testDaDoubleSelectByTupleIdSafe1(self):
05854         a=DataArrayDouble.New();
05855         arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
05856         a.setValues(arr1,7,2);
05857         a.setInfoOnComponent(0,"toto");
05858         a.setInfoOnComponent(1,"tata");
05859         #
05860         arr2=[4,2,0,6,5]
05861         b=a.selectByTupleIdSafe(arr2);
05862         self.assertEqual(5,b.getNumberOfTuples());
05863         self.assertEqual(2,b.getNumberOfComponents());
05864         self.assertTrue(b.getInfoOnComponent(0)=="toto");
05865         self.assertTrue(b.getInfoOnComponent(1)=="tata");
05866         expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
05867         for i in xrange(10):
05868             self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
05869             pass
05870         arr4=[4,-1,0,6,5]
05871         self.assertRaises(InterpKernelException,a.selectByTupleIdSafe,arr4);
05872         arr5=[4,2,0,6,7]
05873         self.assertRaises(InterpKernelException,a.selectByTupleIdSafe,arr5);
05874         #
05875         c=DataArrayInt.New();
05876         arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
05877         c.setValues(arr3,7,2);
05878         c.setInfoOnComponent(0,"toto");
05879         c.setInfoOnComponent(1,"tata");
05880         d=c.selectByTupleIdSafe(arr2);
05881         self.assertEqual(5,d.getNumberOfTuples());
05882         self.assertEqual(2,d.getNumberOfComponents());
05883         self.assertTrue(d.getInfoOnComponent(0)=="toto");
05884         self.assertTrue(d.getInfoOnComponent(1)=="tata");
05885         expected2=[5,15,3,13,1,11,7,17,6,16]
05886         for i in xrange(10):
05887             self.assertEqual(expected2[i],d.getIJ(0,i));
05888             pass
05889         self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr4);
05890         self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr5);
05891         pass

Definition at line 8351 of file MEDCouplingBasicsTest.py.

08351 
08352     def testDaDSetPartOfValuesAdv1(self):
08353         tab1=[3.,4.,5., 13.,14.,15., 23.,24.,25., 33.,34.,35., 43.,44.,45., 53.,54.,55.]
08354         tab2=[6.,7.,8., 16.,17.,18., 26.,27.,28.]
08355         tab3=[4,1, 2,2, 3,0]
08356         a=DataArrayDouble.New();
08357         a.setValues(tab1,6,3);
08358         b=DataArrayDouble.New();
08359         b.setValues(tab2,3,3);
08360         c=DataArrayInt.New();
08361         c.setValues(tab3,3,2);
08362         #
08363         a.setPartOfValuesAdv(b,c);
08364         expected1=[3.,4.,5., 13.,14.,15., 26.,27.,28., 6.,7.,8., 16.,17.,18., 53.,54.,55.]
08365         self.assertEqual(expected1,a.getValues());
08366         pass

Definition at line 5147 of file MEDCouplingBasicsTest.py.

05147 
05148     def testDAFromNoInterlace1(self):
05149         tab1=[1,11,21,31,41,2,12,22,32,42,3,13,23,33,43]
05150         da=DataArrayInt.New();
05151         da.setValues(tab1,5,3);
05152         da2=da.fromNoInterlace();
05153         expected1=[1,2,3,11,12,13,21,22,23,31,32,33,41,42,43]
05154         self.assertEqual(5,da2.getNumberOfTuples());
05155         self.assertEqual(3,da2.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components !
05156         self.assertEqual(expected1,da2.getValues());
05157         da3=da.convertToDblArr();
05158         da4=da3.fromNoInterlace();
05159         self.assertEqual(5,da4.getNumberOfTuples());
05160         self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components !
05161         for i in xrange(15):
05162             self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14);
05163             pass
05164         pass
    

Definition at line 6919 of file MEDCouplingBasicsTest.py.

06919 
06920     def testDAIAggregateMulti1(self):
06921         a=DataArrayInt.New()
06922         a.setValues(range(4),2,2)
06923         a.setName("aa")
06924         b=DataArrayInt.New()
06925         b.setValues(range(6),3,2)
06926         c=DataArrayInt.Aggregate([a,b])
06927         self.assertEqual(range(4)+range(6),c.getValues())
06928         self.assertEqual("aa",c.getName())
06929         self.assertEqual(5,c.getNumberOfTuples())
06930         self.assertEqual(2,c.getNumberOfComponents())
06931         pass

Definition at line 5780 of file MEDCouplingBasicsTest.py.

05780 
05781     def testDAIBuildComplement1(self):
05782         a=DataArrayInt.New();
05783         tab=[3,1,7,8]
05784         a.setValues(tab,4,1);
05785         b=a.buildComplement(12);
05786         self.assertEqual(8,b.getNumberOfTuples());
05787         self.assertEqual(1,b.getNumberOfComponents());
05788         expected1=[0,2,4,5,6,9,10,11]
05789         for i in xrange(8):
05790             self.assertEqual(expected1[i],b.getIJ(0,i));
05791             pass
05792         pass

Definition at line 8178 of file MEDCouplingBasicsTest.py.

08178 
08179     def testDAIBuildExplicitArrByRanges1(self):
08180         d=DataArrayInt.New();
08181         vals1=[0,2,3]
08182         d.setValues(vals1,3,1);
08183         e=DataArrayInt.New();
08184         vals2=[0,3,6,10,14,20]
08185         e.setValues(vals2,6,1);
08186         #
08187         f=d.buildExplicitArrByRanges(e);
08188         self.assertEqual(11,f.getNumberOfTuples());
08189         self.assertEqual(1,f.getNumberOfComponents());
08190         expected1=[0,1,2,6,7,8,9,10,11,12,13]
08191         for i in xrange(11):
08192             self.assertEqual(expected1[i],f.getIJ(i,0));
08193             pass
08194         pass

Definition at line 5816 of file MEDCouplingBasicsTest.py.

05816 
05817     def testDAIBuildIntersection1(self):
05818         a=DataArrayInt.New();
05819         tab1=[3,1,7,8]
05820         a.setValues(tab1,4,1);
05821         c=DataArrayInt.New();
05822         tab2=[5,3,0,18,8]
05823         c.setValues(tab2,5,1);
05824         b=a.buildIntersection(c);
05825         self.assertEqual(2,b.getNumberOfTuples());
05826         self.assertEqual(1,b.getNumberOfComponents());
05827         expected1=[3,8]
05828         for i in xrange(2):
05829             self.assertEqual(expected1[i],b.getIJ(0,i));
05830             pass
05831         b=DataArrayInt.BuildIntersection([a,c]);
05832         self.assertEqual(2,b.getNumberOfTuples());
05833         self.assertEqual(1,b.getNumberOfComponents());
05834         expected1=[3,8]
05835         for i in xrange(2):
05836             self.assertEqual(expected1[i],b.getIJ(0,i));
05837             pass
05838         pass

Definition at line 8509 of file MEDCouplingBasicsTest.py.

08509 
08510     def testDAIBuildOld2NewArrayFromSurjectiveFormat2(self):
08511         arr=[0,3, 5,7,9]
08512         arrI=[0,2,5]
08513         a=DataArrayInt.New();
08514         a.setValues(arr,5,1);
08515         b=DataArrayInt.New();
08516         b.setValues(arrI,3,1);
08517         ret,newNbTuple=DataArrayInt.BuildOld2NewArrayFromSurjectiveFormat2(10,a,b);
08518         expected=[0,1,2,0,3,4,5,4,6,4]
08519         self.assertEqual(10,ret.getNbOfElems());
08520         self.assertEqual(7,newNbTuple);
08521         self.assertEqual(1,ret.getNumberOfComponents());
08522         self.assertEqual(expected,ret.getValues());
08523         pass

Definition at line 7832 of file MEDCouplingBasicsTest.py.

07832 
07833     def testDAIBuildPermArrPerLevel1(self):
07834         arr=[2,0,1,1,0,1,2,0,1,1,0,0]
07835         expected1=[10,0,5,6,1,7,11,2,8,9,3,4]
07836         da=DataArrayInt.New();
07837         da.setValues(arr,12,1);
07838         da2=da.buildPermArrPerLevel();
07839         self.assertEqual(12,da2.getNumberOfTuples());
07840         self.assertEqual(1,da2.getNumberOfComponents());
07841         for i in xrange(12):
07842             self.assertEqual(expected1[i],da2.getIJ(i,0));
07843             pass
07844         pass

Definition at line 6146 of file MEDCouplingBasicsTest.py.

06146 
06147     def testDAIBuildPermutationArr1(self):
06148         a=DataArrayInt.New()
06149         a.setValues([4,5,6,7,8],5,1)
06150         b=DataArrayInt.New()
06151         b.setValues([5,4,8,6,7],5,1)
06152         c=a.buildPermutationArr(b)
06153         self.assertEqual([1,0,4,2,3],c.getValues())
06154         self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b))
06155         b.setIJ(0,0,9)
06156         self.assertTrue(not a.isEqualWithoutConsideringStrAndOrder(b))
06157         self.assertRaises(InterpKernelException,a.buildPermutationArr,b)
06158         a.setIJ(3,0,4)
06159         b.setIJ(0,0,5)
06160         b.setIJ(4,0,4)#a==[4,5,6,4,8] and b==[5,4,8,6,4]
06161         self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b))
06162         c=a.buildPermutationArr(b)
06163         self.assertEqual([1,3,4,2,3],c.getValues())
06164         d=b.convertToDblArr()
06165         expect3=[4,4,5,6,8]
06166         b.sort()
06167         self.assertEqual(expect3,b.getValues())
06168         d.sort()
06169         self.assertEqual(5,d.getNumberOfTuples());
06170         self.assertEqual(1,d.getNumberOfComponents());
06171         for i in xrange(5):
06172             self.assertAlmostEqual(float(expect3[i]),d.getIJ(i,0),14);
06173             pass
06174         pass

Definition at line 5923 of file MEDCouplingBasicsTest.py.

05923 
05924     def testDAIBuildSubstraction1(self):
05925         a=DataArrayInt.New()
05926         aa=[2,3,6,8,9]
05927         a.setValues(aa,5,1)
05928         b=DataArrayInt.New()
05929         bb=[1,3,5,9,11]
05930         b.setValues(bb,5,1)
05931         self.assertEqual([2,6,8],a.buildSubstraction(b).getValues())
05932         pass

Definition at line 5793 of file MEDCouplingBasicsTest.py.

05793 
05794     def testDAIBuildUnion1(self):
05795         a=DataArrayInt.New();
05796         tab1=[3,1,7,8]
05797         a.setValues(tab1,4,1);
05798         c=DataArrayInt.New();
05799         tab2=[5,3,0,18,8]
05800         c.setValues(tab2,5,1);
05801         b=a.buildUnion(c);
05802         self.assertEqual(7,b.getNumberOfTuples());
05803         self.assertEqual(1,b.getNumberOfComponents());
05804         expected1=[0,1,3,5,7,8,18]
05805         for i in xrange(7):
05806             self.assertEqual(expected1[i],b.getIJ(0,i));
05807             pass
05808         b=DataArrayInt.BuildUnion([a,c]);
05809         self.assertEqual(7,b.getNumberOfTuples());
05810         self.assertEqual(1,b.getNumberOfComponents());
05811         expected1=[0,1,3,5,7,8,18]
05812         for i in xrange(7):
05813             self.assertEqual(expected1[i],b.getIJ(0,i));
05814             pass
05815         pass

Definition at line 7128 of file MEDCouplingBasicsTest.py.

07128 
07129     def testDAIChangeSurjectiveFormat1(self):
07130         vals1=[0,3,2,3,2,2,1,2]
07131         expected1=[0,1,2,6,8]
07132         expected2=[0,  6,  2,4,5,7,  1,3]
07133         da=DataArrayInt.New();
07134         da.setValues(vals1,8,1);
07135         #
07136         da2,da2I=da.changeSurjectiveFormat(4);
07137         self.assertEqual(5,da2I.getNumberOfTuples());
07138         self.assertEqual(8,da2.getNumberOfTuples());
07139         self.assertEqual(expected1,da2I.getValues());
07140         self.assertEqual(expected2,da2.getValues());
07141         #
07142         self.assertRaises(InterpKernelException,da.changeSurjectiveFormat,3);
07143         #
07144         pass

Definition at line 7101 of file MEDCouplingBasicsTest.py.

07101 
07102     def testDAICheckAndPreparePermutation1(self):
07103         vals1=[9,10,0,6,4,11,3,7];
07104         expect1=[5,6,0,3,2,7,1,4];
07105         vals2=[9,10,0,6,10,11,3,7];
07106         da=DataArrayInt.New();
07107         da.setValues(vals1,8,1);
07108         da2=da.checkAndPreparePermutation();
07109         self.assertEqual(8,da2.getNumberOfTuples());
07110         self.assertEqual(1,da2.getNumberOfComponents());
07111         for i in xrange(8):
07112             self.assertEqual(expect1[i],da2.getIJ(i,0));
07113             pass
07114         #
07115         da=DataArrayInt.New();
07116         da.alloc(8,1);
07117         da.iota(0);
07118         da2=da.checkAndPreparePermutation();
07119         self.assertEqual(8,da2.getNumberOfTuples());
07120         self.assertEqual(1,da2.getNumberOfComponents());
07121         self.assertTrue(da2.isIdentity());
07122         #
07123         da=DataArrayInt.New();
07124         da.alloc(8,1);
07125         da.setValues(vals2,8,1);
07126         self.assertRaises(InterpKernelException,da.checkAndPreparePermutation);
07127         pass

Definition at line 7632 of file MEDCouplingBasicsTest.py.

07632 
07633     def testDAIComputeOffsets1(self):
07634         d=DataArrayInt.New();
07635         vals1=[3,5,1,2,0,8]
07636         expected1=[0,3,8,9,11,11]
07637         d.setValues(vals1,6,1);
07638         d.computeOffsets();
07639         self.assertEqual(6,d.getNumberOfTuples());
07640         self.assertEqual(1,d.getNumberOfComponents());
07641         for i in xrange(6):
07642             self.assertEqual(expected1[i],d.getIJ(0,i));
07643             pass
07644         pass

Definition at line 8195 of file MEDCouplingBasicsTest.py.

08195 
08196     def testDAIComputeOffsets2(self):
08197         d=DataArrayInt.New();
08198         vals1=[3,5,1,2,0,8]
08199         expected1=[0,3,8,9,11,11,19]
08200         d.setValues(vals1,6,1);
08201         d.computeOffsets2();
08202         self.assertEqual(7,d.getNumberOfTuples());
08203         self.assertEqual(1,d.getNumberOfComponents());
08204         for i in xrange(7):
08205             self.assertEqual(expected1[i],d.getIJ(0,i));
08206             pass
08207         pass

Definition at line 5839 of file MEDCouplingBasicsTest.py.

05839 
05840     def testDAIDeltaShiftIndex1(self):
05841         a=DataArrayInt.New();
05842         tab=[1,3,6,7,7,9,15]
05843         a.setValues(tab,7,1);
05844         b=a.deltaShiftIndex();
05845         self.assertEqual(6,b.getNumberOfTuples());
05846         self.assertEqual(1,b.getNumberOfComponents());
05847         expected1=[2,3,1,0,2,6]
05848         for i in xrange(6):
05849             self.assertEqual(expected1[i],b.getIJ(0,i));
05850             pass
05851         pass

Definition at line 5125 of file MEDCouplingBasicsTest.py.

05125 
05126     def testDAIGetIdsEqual1(self):
05127         tab1=[5,-2,-4,-2,3,2,-2];
05128         da=DataArrayInt.New();
05129         da.setValues(tab1,7,1);
05130         da2=da.getIdsEqual(-2);
05131         self.assertEqual(3,da2.getNumberOfTuples());
05132         self.assertEqual(1,da2.getNumberOfComponents());
05133         expected1=[1,3,6];
05134         self.assertEqual(expected1,da2.getValues());
05135         pass

Definition at line 5136 of file MEDCouplingBasicsTest.py.

05136 
05137     def testDAIGetIdsEqualList1(self):
05138         tab1=[5,-2,-4,-2,3,2,-2];
05139         da=DataArrayInt.New();
05140         da.setValues(tab1,7,1);
05141         da2=da.getIdsEqualList([3,-2,0]);
05142         self.assertEqual(4,da2.getNumberOfTuples());
05143         self.assertEqual(1,da2.getNumberOfComponents());
05144         expected1=[1,3,4,6];
05145         self.assertEqual(expected1,da2.getValues());
05146         pass

Definition at line 7607 of file MEDCouplingBasicsTest.py.

07607 
07608     def testDAIGetIdsNotEqual1(self):
07609         d=DataArrayInt.New();
07610         vals1=[2,3,5,6,8,5,5,6,1,-5]
07611         d.setValues(vals1,10,1);
07612         d2=d.getIdsNotEqual(5);
07613         self.assertEqual(7,d2.getNumberOfTuples());
07614         self.assertEqual(1,d2.getNumberOfComponents());
07615         expected1=[0,1,3,4,7,8,9]
07616         for i in xrange(7):
07617             self.assertEqual(expected1[i],d2.getIJ(0,i));
07618             pass
07619         d.rearrange(2);
07620         self.assertRaises(InterpKernelException,d.getIdsNotEqual,5);
07621         vals2=[-4,5,6]
07622         vals3=vals2;
07623         d.rearrange(1);
07624         d3=d.getIdsNotEqualList(vals3);
07625         self.assertEqual(5,d3.getNumberOfTuples());
07626         self.assertEqual(1,d3.getNumberOfComponents());
07627         expected2=[0,1,4,8,9]
07628         for i in xrange(5):
07629             self.assertEqual(expected2[i],d3.getIJ(0,i));
07630             pass
07631         pass

Definition at line 7845 of file MEDCouplingBasicsTest.py.

07845 
07846     def testDAIOperations1(self):
07847         arr1=[-1,-2,4,7,3,2,6,6,4,3,0,1]
07848         da=DataArrayInt.New();
07849         da.setValues(arr1,4,3);
07850         da1=DataArrayInt.New();
07851         da1.alloc(12,1);
07852         da1.iota(2);
07853         self.assertRaises(InterpKernelException,DataArrayInt.Add,da,da1);#not same number of tuples/Components
07854         da1.rearrange(3);
07855         da2=DataArrayInt.Add(da,da1);
07856         self.assertEqual(4,da2.getNumberOfTuples());
07857         self.assertEqual(3,da2.getNumberOfComponents());
07858         expected1=[1,1,8,12,9,9,14,15,14,14,12,14]
07859         for i in xrange(12):
07860             self.assertEqual(expected1[i],da2.getIJ(0,i));
07861             pass
07862         da1.substractEqual(da);
07863         expected2=[3,5,0,-2,3,5,2,3,6,8,12,12]
07864         for i in xrange(12):
07865             self.assertEqual(expected2[i],da1.getIJ(0,i));
07866             pass
07867         da1.rearrange(1); da1.iota(2); da1.rearrange(3);
07868         da1.addEqual(da);
07869         for i in xrange(12):
07870             self.assertEqual(expected1[i],da1.getIJ(0,i));
07871             pass
07872         da1.rearrange(1); da1.iota(2); da1.rearrange(3);
07873         da2=DataArrayInt.Multiply(da,da1);
07874         self.assertEqual(4,da2.getNumberOfTuples());
07875         self.assertEqual(3,da2.getNumberOfComponents());
07876         expected3=[-2,-6,16,35,18,14,48,54,40,33,0,13]
07877         for i in xrange(12):
07878             self.assertEqual(expected3[i],da2.getIJ(0,i));
07879             pass
07880         da.divideEqual(da1);
07881         self.assertEqual(4,da.getNumberOfTuples());
07882         self.assertEqual(3,da.getNumberOfComponents());
07883         expected4=[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
07884         for i in xrange(12):
07885             self.assertEqual(expected4[i],da.getIJ(0,i));
07886             pass
07887         da.setValues(arr1,4,3);
07888         da1.multiplyEqual(da);
07889         self.assertEqual(4,da1.getNumberOfTuples());
07890         self.assertEqual(3,da1.getNumberOfComponents());
07891         for i in xrange(12):
07892             self.assertEqual(expected3[i],da1.getIJ(0,i));
07893             pass
07894         da1.rearrange(1); da1.iota(2); da1.rearrange(3);
07895         da2=DataArrayInt.Divide(da,da1);
07896         self.assertEqual(4,da2.getNumberOfTuples());
07897         self.assertEqual(3,da2.getNumberOfComponents());
07898         for i in xrange(12):
07899             self.assertEqual(expected4[i],da2.getIJ(0,i));
07900             pass
07901         da1.applyInv(321);
07902         self.assertEqual(4,da1.getNumberOfTuples());
07903         self.assertEqual(3,da1.getNumberOfComponents());
07904         expected5=[160,107,80,64,53,45,40,35,32,29,26,24]
07905         for i in xrange(12):
07906             self.assertEqual(expected5[i],da1.getIJ(0,i));
07907             pass
07908         da1.applyDivideBy(2);
07909         self.assertEqual(4,da1.getNumberOfTuples());
07910         self.assertEqual(3,da1.getNumberOfComponents());
07911         expected6=[80,53,40,32,26,22,20,17,16,14,13,12]
07912         for i in xrange(12):
07913             self.assertEqual(expected6[i],da1.getIJ(0,i));
07914             pass
07915         expected7=[3,4,5,4,5,1,6,3,2,0,6,5]
07916         da1.applyModulus(7);
07917         for i in xrange(12):
07918             self.assertEqual(expected7[i],da1.getIJ(0,i));
07919             pass
07920         da1.applyLin(1,1);
07921         expected8=[3,3,3,3,3,1,3,3,0,0,3,3]
07922         da1.applyRModulus(3);
07923         for i in xrange(12):
07924             self.assertEqual(expected8[i],da1.getIJ(0,i));
07925             pass
07926         pass

Definition at line 8054 of file MEDCouplingBasicsTest.py.

08054 
08055     def testDAISplitByValueRange1(self):
08056         val1=[6,5,0,3,2,7,8,1,4]
08057         val2=[0,4,9]
08058         d=DataArrayInt.New();
08059         d.setValues(val1,9,1);
08060         e,f,g=d.splitByValueRange(val2);
08061         self.assertEqual(9,e.getNumberOfTuples());
08062         self.assertEqual(1,e.getNumberOfComponents());
08063         self.assertEqual(9,f.getNumberOfTuples());
08064         self.assertEqual(1,f.getNumberOfComponents());
08065         self.assertEqual(2,g.getNumberOfTuples());
08066         self.assertEqual(1,g.getNumberOfComponents());
08067         #
08068         expected1=[1,1,0,0,0,1,1,0,1]
08069         expected2=[2,1,0,3,2,3,4,1,0]
08070         for i in xrange(9):
08071             self.assertEqual(expected1[i],e.getIJ(i,0));
08072             self.assertEqual(expected2[i],f.getIJ(i,0));
08073             pass
08074         self.assertEqual(0,g.getIJ(0,0));
08075         self.assertEqual(1,g.getIJ(1,0));
08076         #
08077         d.setIJ(6,0,9);
08078         self.assertRaises(InterpKernelException,d.splitByValueRange,val2);
08079         pass

Definition at line 5183 of file MEDCouplingBasicsTest.py.

05183 
05184     def testDAIsUniform1(self):
05185         tab1=[1,1,1,1,1]
05186         da=DataArrayInt.New();
05187         da.setValues(tab1,5,1);
05188         self.assertTrue(da.isUniform(1));
05189         da.setIJ(2,0,2);
05190         self.assertTrue(not da.isUniform(1));
05191         da.setIJ(2,0,1);
05192         self.assertTrue(da.isUniform(1));
05193         da2=da.convertToDblArr();
05194         self.assertTrue(da2.isUniform(1.,1.e-12));
05195         da2.setIJ(1,0,1.+1.e-13);
05196         self.assertTrue(da2.isUniform(1.,1.e-12));
05197         da2.setIJ(1,0,1.+1.e-11);
05198         self.assertTrue(not da2.isUniform(1.,1.e-12));
05199         pass
    

Definition at line 7806 of file MEDCouplingBasicsTest.py.

07806 
07807     def testDAITransformWithIndArr1(self):
07808         tab1=[17,18,22,19]
07809         tab2=[0,1,1,3,3,0,1,3,2,2,3,0]
07810         expected=[17,18,18,19,19,17,18,19,22,22,19,17]
07811         d=DataArrayInt.New();
07812         d.setValues(tab1,4,1);
07813         d1=DataArrayInt.New();
07814         d1.setValues(tab2,12,1);
07815         d2=d1[:]
07816         #
07817         d1.transformWithIndArr(d);
07818         self.assertEqual(12,d1.getNumberOfTuples());
07819         self.assertEqual(1,d1.getNumberOfComponents());
07820         for i in xrange(12):
07821             self.assertEqual(expected[i],d1.getIJ(i,0));
07822             pass
07823         #
07824         d1=d2
07825         d1.transformWithIndArr(tab1)
07826         self.assertEqual(12,d1.getNumberOfTuples());
07827         self.assertEqual(1,d1.getNumberOfComponents());
07828         for i in xrange(12):
07829             self.assertEqual(expected[i],d1.getIJ(i,0));
07830             pass
07831         pass

Definition at line 8028 of file MEDCouplingBasicsTest.py.

08028 
08029     def testDAITransformWithIndArrR1(self):
08030         tab1=[2,4,5,3,6,7]
08031         tab2=[-1,-1,0,1,2,3,4,5,-1,-1,-1,-1]
08032         expected=[0,3,1,2,4,5]
08033         d=DataArrayInt.New();
08034         d.setValues(tab1,6,1);
08035         d1=DataArrayInt.New();
08036         d1.setValues(tab2,12,1);
08037         d2=d1[:]
08038         #
08039         d3=d.transformWithIndArrR(d1);
08040         self.assertEqual(6,d3.getNumberOfTuples());
08041         self.assertEqual(1,d3.getNumberOfComponents());
08042         for i in xrange(6):
08043             self.assertEqual(expected[i],d3.getIJ(i,0));
08044             pass
08045         #
08046         d1=d2
08047         d3=d.transformWithIndArrR(tab2)
08048         self.assertEqual(6,d3.getNumberOfTuples());
08049         self.assertEqual(1,d3.getNumberOfComponents());
08050         for i in xrange(6):
08051             self.assertEqual(expected[i],d3.getIJ(i,0));
08052             pass
08053         pass

Definition at line 5607 of file MEDCouplingBasicsTest.py.

05607 
05608     def testDAMeld1(self):
05609         da1=DataArrayDouble.New();
05610         da1.alloc(7,2);
05611         da2=DataArrayDouble.New();
05612         da2.alloc(7,1);
05613         #
05614         da1.fillWithValue(7.);
05615         da2.iota(0.);
05616         da3=da2.applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
05617         #
05618         da1.setInfoOnComponent(0,"c0da1");
05619         da1.setInfoOnComponent(1,"c1da1");
05620         da3.setInfoOnComponent(0,"c0da3");
05621         da3.setInfoOnComponent(1,"c1da3");
05622         da3.setInfoOnComponent(2,"c2da3");
05623         #
05624         da1C=da1.deepCpy();
05625         da1.meldWith(da3);
05626         self.assertEqual(5,da1.getNumberOfComponents());
05627         self.assertEqual(7,da1.getNumberOfTuples());
05628         self.assertTrue(da1.getInfoOnComponent(0)=="c0da1");
05629         self.assertTrue(da1.getInfoOnComponent(1)=="c1da1");
05630         self.assertTrue(da1.getInfoOnComponent(2)=="c0da3");
05631         self.assertTrue(da1.getInfoOnComponent(3)=="c1da3");
05632         self.assertTrue(da1.getInfoOnComponent(4)=="c2da3");
05633         #
05634         expected1=[7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.]
05635         for i in xrange(35):
05636             self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),10);
05637             pass
05638         #
05639         dai1=da1C.convertToIntArr();
05640         dai3=da3.convertToIntArr();
05641         dai1.meldWith(dai3);
05642         self.assertEqual(5,dai1.getNumberOfComponents());
05643         self.assertEqual(7,dai1.getNumberOfTuples());
05644         self.assertTrue(dai1.getInfoOnComponent(0)=="c0da1");
05645         self.assertTrue(dai1.getInfoOnComponent(1)=="c1da1");
05646         self.assertTrue(dai1.getInfoOnComponent(2)=="c0da3");
05647         self.assertTrue(dai1.getInfoOnComponent(3)=="c1da3");
05648         self.assertTrue(dai1.getInfoOnComponent(4)=="c2da3");
05649         for i in xrange(35):
05650             self.assertEqual(int(expected1[i]),dai1.getIJ(0,i));
05651             pass
05652         # test of static method DataArrayDouble::meld
05653         da4=DataArrayDouble.Meld(da1C,da3);
05654         tmp=DataArrayDouble.Meld([da1C,da3]);
05655         self.assertTrue(da4.isEqual(tmp,1e-10))
05656         self.assertEqual(5,da4.getNumberOfComponents());
05657         self.assertEqual(7,da4.getNumberOfTuples());
05658         self.assertTrue(da4.getInfoOnComponent(0)=="c0da1");
05659         self.assertTrue(da4.getInfoOnComponent(1)=="c1da1");
05660         self.assertTrue(da4.getInfoOnComponent(2)=="c0da3");
05661         self.assertTrue(da4.getInfoOnComponent(3)=="c1da3");
05662         self.assertTrue(da4.getInfoOnComponent(4)=="c2da3");
05663         for i in xrange(35):
05664             self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),10);
05665             pass
05666         # test of static method DataArrayInt::meld
05667         dai1=da1C.convertToIntArr();
05668         dai4=DataArrayInt.Meld(dai1,dai3);
05669         tmp=DataArrayInt.Meld([dai1,dai3]);
05670         self.assertTrue(dai4.isEqual(tmp))
05671         self.assertEqual(5,dai4.getNumberOfComponents());
05672         self.assertEqual(7,dai4.getNumberOfTuples());
05673         self.assertTrue(dai4.getInfoOnComponent(0)=="c0da1");
05674         self.assertTrue(dai4.getInfoOnComponent(1)=="c1da1");
05675         self.assertTrue(dai4.getInfoOnComponent(2)=="c0da3");
05676         self.assertTrue(dai4.getInfoOnComponent(3)=="c1da3");
05677         self.assertTrue(dai4.getInfoOnComponent(4)=="c2da3");
05678         for i in xrange(35):
05679             self.assertEqual(int(expected1[i]),dai4.getIJ(0,i));
05680             pass
05681         pass

Definition at line 6030 of file MEDCouplingBasicsTest.py.

06030 
06031     def testDARearrange1(self):
06032         da1=DataArrayInt.New();
06033         da1.alloc(12,1);
06034         da1.iota(0);
06035         #
06036         self.assertEqual(12,da1.getNbOfElems());
06037         self.assertEqual(1,da1.getNumberOfComponents());
06038         self.assertEqual(12,da1.getNumberOfTuples());
06039         da1.rearrange(4);
06040         self.assertEqual(12,da1.getNbOfElems());
06041         self.assertEqual(4,da1.getNumberOfComponents());
06042         self.assertEqual(3,da1.getNumberOfTuples());
06043         for i in xrange(12):
06044             self.assertEqual(i,da1.getIJ(0,i));
06045         #
06046         da1.rearrange(6);
06047         self.assertEqual(12,da1.getNbOfElems());
06048         self.assertEqual(6,da1.getNumberOfComponents());
06049         self.assertEqual(2,da1.getNumberOfTuples());
06050         for i in xrange(12):
06051             self.assertEqual(i,da1.getIJ(0,i));
06052         #
06053         self.assertRaises(da1.rearrange(7),InterpKernelException);
06054         #
06055         da1.rearrange(12);
06056         self.assertEqual(12,da1.getNbOfElems());
06057         self.assertEqual(12,da1.getNumberOfComponents());
06058         self.assertEqual(1,da1.getNumberOfTuples());
06059         for i in xrange(12):
06060             self.assertEqual(i,da1.getIJ(0,i));
06061         #
06062         da1.rearrange(3);
06063         self.assertEqual(12,da1.getNbOfElems());
06064         self.assertEqual(3,da1.getNumberOfComponents());
06065         self.assertEqual(4,da1.getNumberOfTuples());
06066         for i in xrange(12):
06067             self.assertEqual(i,da1.getIJ(0,i));
06068         #double
06069         da2=da1.convertToDblArr();
06070         #
06071         self.assertEqual(12,da2.getNbOfElems());
06072         self.assertEqual(3,da2.getNumberOfComponents());
06073         self.assertEqual(4,da2.getNumberOfTuples());
06074         da2.rearrange(4);
06075         self.assertEqual(12,da2.getNbOfElems());
06076         self.assertEqual(4,da2.getNumberOfComponents());
06077         self.assertEqual(3,da2.getNumberOfTuples());
06078         for i in xrange(12):
06079             self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
06080         #
06081         da2.rearrange(6);
06082         self.assertEqual(12,da2.getNbOfElems());
06083         self.assertEqual(6,da2.getNumberOfComponents());
06084         self.assertEqual(2,da2.getNumberOfTuples());
06085         for i in xrange(12):
06086             self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
06087         #
06088         self.assertRaises(da2.rearrange(7),InterpKernelException);
06089         #
06090         da2.rearrange(1);
06091         self.assertTrue(ptr2==da2.getConstPointer());
06092         self.assertEqual(12,da2.getNbOfElems());
06093         self.assertEqual(1,da2.getNumberOfComponents());
06094         self.assertEqual(12,da2.getNumberOfTuples());
06095         for i in xrange(12):
06096             self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
06097         #
06098         da2.rearrange(3);
06099         self.assertEqual(12,da2.getNbOfElems());
06100         self.assertEqual(3,da2.getNumberOfComponents());
06101         self.assertEqual(4,da2.getNumberOfTuples());
06102         for i in xrange(12):
06103             self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
06104         pass

Here is the caller graph for this function:

Definition at line 6105 of file MEDCouplingBasicsTest.py.

06105 
06106     def testDARearrange1(self):
06107         da1=DataArrayInt.New();
06108         arr=[1,2,3,2,2,3,5,1,5,5,2,2]
06109         da1.setValues(arr,4,3);
06110         s=da1.getDifferentValues(True);# API different from C++ because SWIG complains...
06111         expected1=[1,2,3,5]
06112         self.assertEqual(expected1,s);
06113         pass

Here is the call graph for this function:

Definition at line 9200 of file MEDCouplingBasicsTest.py.

09200 
09201     def testDataArrayAbs1(self):
09202         d1=DataArrayDouble.New();
09203         val1=[2.,-3.,-5.,6.,-7.,-8.,9.,10.,-11.,-12.,-13.,-15.]
09204         expected1=[2.,3.,5.,6.,7.,8.,9.,10.,11.,12.,13.,15.]
09205         d1.setValues(val1,6,2);
09206         d2=d1.convertToIntArr();
09207         #
09208         d1.abs();
09209         for i in xrange(12):
09210             self.assertAlmostEqual(expected1[i],d1.getIJ(0,i),14);
09211             pass
09212         #
09213         expected2=[2,3,5,6,7,8,9,10,11,12,13,15]
09214         d2.abs();
09215         for i in xrange(12):
09216             self.assertEqual(expected2[i],d2.getIJ(0,i));
09217             pass
09218         #
09219         pass

Definition at line 8983 of file MEDCouplingBasicsTest.py.

08983 
08984     def testDataArrayDoubleAdvSetting1(self):
08985         data1=[1.,11.,2.,12.,3.,13.,4.,14.,5.,15.,6.,16.,7.,17.]
08986         data2=[8.,38.,9.,39.,0.,30.,11.,41.,12.,42.]
08987         compsCpp=["comp1","comp2"]
08988         da=DataArrayDouble.New();
08989         da.setInfoAndChangeNbOfCompo(compsCpp);
08990         da.setName("da");
08991         da.alloc(7,2);
08992         compsCpp=compsCpp[:-1]
08993         self.assertRaises(InterpKernelException,da.setInfoAndChangeNbOfCompo,compsCpp);
08994         da.setValues(data1,7,2)
08995         #
08996         p=[(0,3),(3,5),(5,7)]
08997         tmp=da.selectByTupleRanges(p);
08998         self.assertTrue(tmp.isEqual(da,1e-14));
08999         p=[(0,2),(3,4),(5,7)]
09000         tmp=da.selectByTupleRanges(p);
09001         expected1=[1.,11.,2.,12.,4.,14.,6.,16.,7.,17.]
09002         self.assertEqual(5,tmp.getNumberOfTuples());
09003         self.assertEqual(2,tmp.getNumberOfComponents());
09004         for i in xrange(10):
09005             self.assertAlmostEqual(expected1[i],tmp.getIJ(0,i),14);
09006             pass
09007         p=[(0,2),(0,2),(5,6)]
09008         tmp=da.selectByTupleRanges(p);
09009         expected2=[1.,11.,2.,12.,1.,11.,2.,12.,6.,16.]
09010         self.assertEqual(5,tmp.getNumberOfTuples());
09011         self.assertEqual(2,tmp.getNumberOfComponents());
09012         for i in xrange(10):
09013             self.assertAlmostEqual(expected2[i],tmp.getIJ(0,i),14);
09014             pass
09015         p=[(0,2),(-1,2),(5,6)]
09016         self.assertRaises(InterpKernelException,da.selectByTupleRanges,p);
09017         p=[(0,2),(0,2),(5,8)]
09018         self.assertRaises(InterpKernelException,da.selectByTupleRanges,p);
09019         #
09020         da2=DataArrayDouble.New();
09021         da2.setValues(data2,5,2);
09022         #
09023         dac=da.deepCpy();
09024         dac.setContigPartOfSelectedValues2(1,da2,2,4,1);
09025         expected3=[1.,11.,0.,30.,11.,41.,4.,14.,5.,15.,6.,16.,7.,17.]
09026         for i in xrange(14):
09027             self.assertAlmostEqual(expected3[i],dac.getIJ(0,i),14);
09028             pass
09029         #
09030         dac=da.deepCpy();
09031         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues2,3,da2,0,5,1);
09032         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues2,0,da2,4,6,1);
09033         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues2,3,da2,5,0,1);
09034         dac.setContigPartOfSelectedValues2(3,da2,1,5,1);
09035         expected4=[1.,11.,2.,12.,3.,13.,9.,39.,0.,30.,11.,41.,12.,42.]
09036         for i in xrange(14):
09037             self.assertAlmostEqual(expected4[i],dac.getIJ(0,i),14);
09038             pass
09039         #
09040         ids=DataArrayInt.New();
09041         ids.alloc(3,1);
09042         dac=da.deepCpy();
09043         ids.setIJ(0,0,2); ids.setIJ(1,0,0); ids.setIJ(2,0,4);
09044         dac.setContigPartOfSelectedValues(2,da2,ids);
09045         expected5=[1.,11.,2.,12.,0.,30.,8.,38.,12.,42.,6.,16.,7.,17.]
09046         for i in xrange(14):
09047             self.assertAlmostEqual(expected5[i],dac.getIJ(0,i),14);
09048             pass
09049         #
09050         dac=da.deepCpy();
09051         ids.setIJ(0,0,2); ids.setIJ(1,0,5); ids.setIJ(2,0,4);
09052         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues,1,da2,ids);
09053         ids.setIJ(0,0,2); ids.setIJ(1,0,2); ids.setIJ(2,0,-1);
09054         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues,1,da2,ids);
09055         ids.setIJ(0,0,2); ids.setIJ(1,0,2); ids.setIJ(2,0,1);
09056         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues,5,da2,ids);
09057         #
09058         ids.setIJ(0,0,2); ids.setIJ(1,0,2); ids.setIJ(2,0,1);
09059         dac=da.deepCpy();
09060         dac.setContigPartOfSelectedValues(4,da2,ids);
09061         expected6=[1.,11.,2.,12.,3.,13.,4.,14.,0.,30.,0.,30.,9.,39.]
09062         for i in xrange(14):
09063             self.assertAlmostEqual(expected6[i],dac.getIJ(0,i),14);
09064             pass
09065         pass

Definition at line 9931 of file MEDCouplingBasicsTest.py.

09931 
09932     def testDataArrayDoubleGetMinMaxPerComponent1(self):
09933         values1=[1.,2.,3.,-0.9,2.1,3.,1.3,1.7,3.,1.,1.8,3.]
09934         d1=DataArrayDouble.New();
09935         self.assertRaises(InterpKernelException,d1.getMinMaxPerComponent)
09936         d1=DataArrayDouble.New(values1,4,3);
09937         res=d1.getMinMaxPerComponent();
09938         self.assertTrue(isinstance(res,list))
09939         self.assertEqual(3,len(res))
09940         for i in xrange(3):
09941             self.assertTrue(isinstance(res[i],tuple))
09942             self.assertEqual(2,len(res[i]))
09943             pass
09944         expected1=[-0.9,1.3,1.7,2.1,3.,3.]
09945         for i in xrange(6):
09946             self.assertAlmostEqual(expected1[i],res[i/2][i%2],14)
09947             pass
09948         #
09949         d1.rearrange(2);
09950         res=d1.getMinMaxPerComponent();
09951         self.assertTrue(isinstance(res,list))
09952         self.assertEqual(2,len(res))
09953         for i in xrange(2):
09954             self.assertTrue(isinstance(res[i],tuple))
09955             self.assertEqual(2,len(res[i]))
09956             pass
09957         expected2=[1.,3.,-0.9,3.]
09958         for i in xrange(4):
09959             self.assertAlmostEqual(expected2[i],res[i/2][i%2],14)
09960             pass
09961         #
09962         d1.rearrange(1);
09963         res=d1.getMinMaxPerComponent();
09964         self.assertTrue(isinstance(res,list))
09965         self.assertEqual(1,len(res))
09966         for i in xrange(1):
09967             self.assertTrue(isinstance(res[i],tuple))
09968             self.assertEqual(2,len(res[i]))
09969             pass
09970         expected3=[-0.9,3.]
09971         for i in xrange(2):
09972             self.assertAlmostEqual(expected3[i],res[i/2][i%2],14)
09973             pass
09974         pass

Definition at line 9066 of file MEDCouplingBasicsTest.py.

09066 
09067     def testDataArrayIntAdvSetting1(self):
09068         data1=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
09069         data2=[8,38,9,39,0,30,11,41,12,42]
09070         compsCpp=["comp1","comp2"]
09071         da=DataArrayInt.New();
09072         da.setInfoAndChangeNbOfCompo(compsCpp);
09073         da.setName("da");
09074         da.alloc(7,2);
09075         compsCpp=compsCpp[:-1]
09076         self.assertRaises(InterpKernelException,da.setInfoAndChangeNbOfCompo,compsCpp);
09077         da.setValues(data1,7,2)
09078         #
09079         p=[(0,3),(3,5),(5,7)]
09080         tmp=da.selectByTupleRanges(p);
09081         self.assertTrue(tmp.isEqual(da));
09082         p=[(0,2),(3,4),(5,7)]
09083         tmp=da.selectByTupleRanges(p);
09084         expected1=[1,11,2,12,4,14,6,16,7,17]
09085         self.assertEqual(5,tmp.getNumberOfTuples());
09086         self.assertEqual(2,tmp.getNumberOfComponents());
09087         for i in xrange(10):
09088             self.assertEqual(expected1[i],tmp.getIJ(0,i));
09089             pass
09090         p=[(0,2),(0,2),(5,6)]
09091         tmp=da.selectByTupleRanges(p);
09092         expected2=[1,11,2,12,1,11,2,12,6,16]
09093         self.assertEqual(5,tmp.getNumberOfTuples());
09094         self.assertEqual(2,tmp.getNumberOfComponents());
09095         for i in xrange(10):
09096             self.assertEqual(expected2[i],tmp.getIJ(0,i));
09097             pass
09098         p=[(0,2),(-1,2),(5,6)]
09099         self.assertRaises(InterpKernelException,da.selectByTupleRanges,p);
09100         p=[(0,2),(0,2),(5,8)]
09101         self.assertRaises(InterpKernelException,da.selectByTupleRanges,p);
09102         #
09103         da2=DataArrayInt.New();
09104         da2.setValues(data2,5,2);
09105         #
09106         dac=da.deepCpy();
09107         dac.setContigPartOfSelectedValues2(1,da2,2,4,1);
09108         expected3=[1,11,0,30,11,41,4,14,5,15,6,16,7,17]
09109         for i in xrange(14):
09110             self.assertEqual(expected3[i],dac.getIJ(0,i));
09111             pass
09112         #
09113         dac=da.deepCpy();
09114         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues2,3,da2,0,5,1);
09115         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues2,0,da2,4,6,1);
09116         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues2,3,da2,5,0,1);
09117         dac.setContigPartOfSelectedValues2(3,da2,1,5,1);
09118         expected4=[1,11,2,12,3,13,9,39,0,30,11,41,12,42]
09119         for i in xrange(14):
09120             self.assertEqual(expected4[i],dac.getIJ(0,i));
09121             pass
09122         #
09123         ids=DataArrayInt.New();
09124         ids.alloc(3,1);
09125         dac=da.deepCpy();
09126         ids.setIJ(0,0,2); ids.setIJ(1,0,0); ids.setIJ(2,0,4);
09127         dac.setContigPartOfSelectedValues(2,da2,ids);
09128         expected5=[1,11,2,12,0,30,8,38,12,42,6,16,7,17]
09129         for i in xrange(14):
09130             self.assertEqual(expected5[i],dac.getIJ(0,i));
09131             pass
09132         #
09133         dac=da.deepCpy();
09134         ids.setIJ(0,0,2); ids.setIJ(1,0,5); ids.setIJ(2,0,4);
09135         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues,1,da2,ids);
09136         ids.setIJ(0,0,2); ids.setIJ(1,0,2); ids.setIJ(2,0,-1);
09137         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues,1,da2,ids);
09138         ids.setIJ(0,0,2); ids.setIJ(1,0,2); ids.setIJ(2,0,1);
09139         self.assertRaises(InterpKernelException,dac.setContigPartOfSelectedValues,5,da2,ids);
09140         #
09141         ids.setIJ(0,0,2); ids.setIJ(1,0,2); ids.setIJ(2,0,1);
09142         dac=da.deepCpy();
09143         dac.setContigPartOfSelectedValues(4,da2,ids);
09144         expected6=[1,11,2,12,3,13,4,14,0,30,0,30,9,39]
09145         for i in xrange(14):
09146             self.assertEqual(expected6[i],dac.getIJ(0,i));
09147             pass
09148         pass

Definition at line 9975 of file MEDCouplingBasicsTest.py.

09975 
09976     def testDataArrayIntGetHashCode1(self):
09977         d1=DataArrayInt.New(range(3545))
09978         d2=DataArrayInt.New(range(3545))
09979         self.assertEqual(d2.getHashCode(),d1.getHashCode())
09980         self.assertEqual(232341068,d1.getHashCode())
09981         d1[886]=6
09982         self.assertEqual(232340188,d1.getHashCode())
09983         pass

Definition at line 4351 of file MEDCouplingBasicsTest.py.

04351 
04352     def testDataArrayIntInvertO2NNO21(self):
04353         arr1=[2,0,4,1,5,3]
04354         da=DataArrayInt.New();
04355         da.setValues(arr1,6,1);
04356         da2=da.invertArrayO2N2N2O(6);
04357         self.assertEqual(6,da2.getNumberOfTuples());
04358         self.assertEqual(1,da2.getNumberOfComponents());
04359         expected1=[1,3,0,5,2,4]
04360         for i in xrange(6):
04361             self.assertEqual(expected1[i],da2.getIJ(i,0));
04362             pass
04363         da3=da2.invertArrayN2O2O2N(6);
04364         for i in xrange(6):
04365             self.assertEqual(arr1[i],da3.getIJ(i,0));
04366             pass
04367         #
04368         arr2=[3,-1,5,4,-1,0,-1,1,2,-1]
04369         da=DataArrayInt.New();
04370         da.setValues(arr2,10,1);
04371         da2=da.invertArrayO2N2N2O(6);
04372         self.assertEqual(6,da2.getNumberOfTuples());
04373         self.assertEqual(1,da2.getNumberOfComponents());
04374         expected2=[5,7,8,0,3,2]
04375         for i in xrange(6):
04376             self.assertEqual(expected2[i],da2.getIJ(i,0));
04377             pass
04378         da3=da2.invertArrayN2O2O2N(10);
04379         for i in xrange(10):
04380             self.assertEqual(arr2[i],da3.getIJ(i,0));
04381             pass
04382         pass

Definition at line 9772 of file MEDCouplingBasicsTest.py.

09772 
09773     def testDataArrayIntRange1(self):
09774         d=DataArrayInt.Range(2,17,7);
09775         expected1=[2,9,16]
09776         self.assertEqual(3,d.getNumberOfTuples());
09777         self.assertEqual(1,d.getNumberOfComponents());
09778         self.assertEqual(expected1,d.getValues());
09779         #
09780         d=DataArrayInt.Range(2,23,7);
09781         self.assertEqual(3,d.getNumberOfTuples());
09782         self.assertEqual(1,d.getNumberOfComponents());
09783         self.assertEqual(expected1,d.getValues());
09784         #
09785         d=DataArrayInt.Range(2,24,7);
09786         expected2=[2,9,16,23]
09787         self.assertEqual(4,d.getNumberOfTuples());
09788         self.assertEqual(1,d.getNumberOfComponents());
09789         self.assertEqual(expected2,d.getValues());
09790         #
09791         d=DataArrayInt.Range(24,2,-7);
09792         expected3=[24,17,10,3]
09793         self.assertEqual(4,d.getNumberOfTuples());
09794         self.assertEqual(1,d.getNumberOfComponents());
09795         self.assertEqual(expected3,d.getValues());
09796         #
09797         d=DataArrayInt.Range(23,2,-7);
09798         expected4=[23,16,9]
09799         self.assertEqual(3,d.getNumberOfTuples());
09800         self.assertEqual(1,d.getNumberOfComponents());
09801         self.assertEqual(expected4,d.getValues());
09802         #
09803         d=DataArrayInt.Range(23,22,-7);
09804         self.assertEqual(1,d.getNumberOfTuples());
09805         self.assertEqual(1,d.getNumberOfComponents());
09806         self.assertEqual(23,d.getIJ(0,0));
09807         #
09808         d=DataArrayInt.Range(22,23,7);
09809         self.assertEqual(1,d.getNumberOfTuples());
09810         self.assertEqual(1,d.getNumberOfComponents());
09811         self.assertEqual(22,d.getIJ(0,0));
09812         #
09813         d=DataArrayInt.Range(22,22,7);
09814         self.assertEqual(0,d.getNumberOfTuples());
09815         self.assertEqual(1,d.getNumberOfComponents());
09816         #
09817         d=DataArrayInt.Range(22,22,-7);
09818         self.assertEqual(0,d.getNumberOfTuples());
09819         self.assertEqual(1,d.getNumberOfComponents());
09820         #
09821         self.assertRaises(InterpKernelException,DataArrayInt.Range,22,23,-7);
09822         self.assertRaises(InterpKernelException,DataArrayInt.Range,23,22,7);
09823         self.assertRaises(InterpKernelException,DataArrayInt.Range,23,22,0);
09824         self.assertRaises(InterpKernelException,DataArrayInt.Range,22,23,0);
09825         pass

Definition at line 5165 of file MEDCouplingBasicsTest.py.

05165 
05166     def testDAToNoInterlace1(self):
05167         tab1=[1,2,3,11,12,13,21,22,23,31,32,33,41,42,43]
05168         da=DataArrayInt.New();
05169         da.setValues(tab1,5,3);
05170         da2=da.toNoInterlace();
05171         expected1=[1,11,21,31,41,2,12,22,32,42,3,13,23,33,43]
05172         self.assertEqual(5,da2.getNumberOfTuples());
05173         self.assertEqual(3,da2.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components !
05174         self.assertEqual(expected1,da2.getValues());
05175         da3=da.convertToDblArr();
05176         da4=da3.toNoInterlace();
05177         self.assertEqual(5,da4.getNumberOfTuples());
05178         self.assertEqual(3,da4.getNumberOfComponents());# it's not a bug. Avoid to have 1 million components !
05179         for i in xrange(15):
05180             self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),14);
05181             pass
05182         pass
    

Definition at line 7329 of file MEDCouplingBasicsTest.py.

07329 
07330     def testDAUnitVar1(self):
07331         da=DataArrayDouble.New();
07332         da.alloc(1,3);
07333         da.setInfoOnComponent(0,"XPS [m]");
07334         st1=da.getVarOnComponent(0);
07335         self.assertTrue(st1=="XPS");
07336         st2=da.getUnitOnComponent(0);
07337         self.assertTrue(st2=="m");
07338         #
07339         da.setInfoOnComponent(0,"XPS         [m]");
07340         st1=da.getVarOnComponent(0);
07341         self.assertTrue(st1=="XPS");
07342         st2=da.getUnitOnComponent(0);
07343         self.assertTrue(st2=="m");
07344         #
07345         da.setInfoOnComponent(0,"XPP         [m]");
07346         st1=da.getVarOnComponent(0);
07347         self.assertTrue(st1=="XPP");
07348         st2=da.getUnitOnComponent(0);
07349         self.assertTrue(st2=="m");
07350         #
07351         da.setInfoOnComponent(0,"XPP kdep  kefer   [ m  ]");
07352         st1=da.getVarOnComponent(0);
07353         self.assertTrue(st1=="XPP kdep  kefer");
07354         st2=da.getUnitOnComponent(0);
07355         self.assertTrue(st2==" m  ");
07356         #
07357         da.setInfoOnComponent(0,"     XPP k[  dep  k]efer   [ m^ 2/s^3*kJ  ]");
07358         st1=da.getVarOnComponent(0);
07359         self.assertTrue(st1=="     XPP k[  dep  k]efer");
07360         st2=da.getUnitOnComponent(0);
07361         self.assertTrue(st2==" m^ 2/s^3*kJ  ");
07362         #
07363         da.setInfoOnComponent(0,"     XPP kefer   ");
07364         st1=da.getVarOnComponent(0);
07365         self.assertTrue(st1=="     XPP kefer   ");
07366         st2=da.getUnitOnComponent(0);
07367         self.assertTrue(st2=="");
07368         #
07369         da.setInfoOnComponent(0,"temperature( bof)");
07370         st1=da.getVarOnComponent(0);
07371         self.assertTrue(st1=="temperature( bof)");
07372         st2=da.getUnitOnComponent(0);
07373         self.assertTrue(st2=="");
07374         #
07375         da.setInfoOnComponent(0,"kkk [m]");
07376         da.setInfoOnComponent(1,"ppp   [m^2/kJ]");
07377         da.setInfoOnComponent(2,"abcde   [MW/s]");
07378         #
07379         vs=da.getVarsOnComponent();
07380         self.assertEqual(3,len(vs));
07381         self.assertTrue(vs[0]=="kkk");
07382         self.assertTrue(vs[1]=="ppp");
07383         self.assertTrue(vs[2]=="abcde");
07384         vs=da.getUnitsOnComponent();
07385         self.assertEqual(3,len(vs));
07386         self.assertTrue(vs[0]=="m");
07387         self.assertTrue(vs[1]=="m^2/kJ");
07388         self.assertTrue(vs[2]=="MW/s");
07389         pass

Definition at line 184 of file MEDCouplingBasicsTest.py.

00184 
00185     def testDeepCopy(self):
00186         array=DataArrayDouble.New();
00187         array.setValues(5*3*[7.],5,3);
00188         self.assertEqual(array.getIJ(3,2),7.);
00189         array2=array.deepCpy();
00190         self.assertEqual(array2.getIJ(3,2),7.)
00191         #
00192         array3=DataArrayInt.New();
00193         array3.setValues(5*3*[17],5,3);
00194         self.assertEqual(array3.getIJ(3,2),17);
00195         array4=array3.deepCpy();
00196         self.assertEqual(array4.getIJ(3,2),17);
00197         pass
    

Definition at line 230 of file MEDCouplingBasicsTest.py.

00230 
00231     def testDescConn2D(self):
00232         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
00233         desc=DataArrayInt.New();
00234         descIndx=DataArrayInt.New();
00235         revDesc=DataArrayInt.New();
00236         revDescIndx=DataArrayInt.New();
00237         mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
00238         mesh2.checkCoherency();
00239         self.assertEqual(1,mesh2.getMeshDimension());
00240         self.assertEqual(13,mesh2.getNumberOfCells());
00241         self.assertEqual(14,revDescIndx.getNbOfElems()); self.assertEqual(14,revDescIndx.getNumberOfTuples());
00242         self.assertEqual(6,descIndx.getNbOfElems()); self.assertEqual(6,descIndx.getNumberOfTuples());
00243         self.assertEqual(18,desc.getNbOfElems()); self.assertEqual(18,desc.getNumberOfTuples());
00244         self.assertEqual(18,revDesc.getNbOfElems()); self.assertEqual(18,revDesc.getNumberOfTuples());
00245         expected1=[0,1,2,3, 2,4,5, 6,7,4, 8,9,1,10, 11,12,6,9];
00246         self.assertEqual(expected1,list(desc.getValues()));
00247         expected2=[0,4,7,10,14,18];
00248         self.assertEqual(expected2,list(descIndx.getValues()));
00249         expected3=[0,1,3,5,6,8,9,11,12,13,15,16,17,18];
00250         self.assertEqual(expected3,list(revDescIndx.getValues()));
00251         expected4=[0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4];
00252         self.assertEqual(expected4,list(revDesc.getValues()));
00253         conn=mesh2.getNodalConnectivity();
00254         connIndex=mesh2.getNodalConnectivityIndex();
00255         expected5=[0,3,6,9,12,15,18,21,24,27,30,33,36,39];
00256         self.assertEqual(expected5,list(connIndex.getValues()));
00257         expected6=[1, 0, 3, 1, 3, 4, 1, 4, 1, 1, 1, 0, 1, 4, 2, 1, 2, 1, 1, 4, 5, 1, 5, 2, 1, 6, 7, 1, 7, 4, 1, 3, 6, 1, 7, 8, 1, 8, 5];
00258         self.assertEqual(expected6,list(conn.getValues()));
00259         #
00260         eltsV=[1,3];
00261         mesh.convertToPolyTypes(eltsV);
00262         mesh.checkCoherency();
00263         #
00264         desc=DataArrayInt.New();
00265         descIndx=DataArrayInt.New();
00266         revDesc=DataArrayInt.New();
00267         revDescIndx=DataArrayInt.New();
00268         #
00269         mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
00270         mesh2.checkCoherency();
00271         self.assertEqual(1,mesh2.getMeshDimension());
00272         self.assertEqual(13,mesh2.getNumberOfCells());
00273         self.assertEqual(14,revDescIndx.getNbOfElems()); self.assertEqual(14,revDescIndx.getNumberOfTuples());
00274         self.assertEqual(6,descIndx.getNbOfElems()); self.assertEqual(6,descIndx.getNumberOfTuples());
00275         self.assertEqual(18,desc.getNbOfElems()); self.assertEqual(18,desc.getNumberOfTuples());
00276         self.assertEqual(18,revDesc.getNbOfElems()); self.assertEqual(18,revDesc.getNumberOfTuples());
00277         self.assertEqual(expected1,list(desc.getValues()));
00278         self.assertEqual(expected2,list(descIndx.getValues()));
00279         self.assertEqual(expected3,list(revDescIndx.getValues()));
00280         self.assertEqual(expected4,list(revDesc.getValues()));
00281         conn=mesh2.getNodalConnectivity();
00282         connIndex=mesh2.getNodalConnectivityIndex();
00283         self.assertEqual(expected5,list(connIndex.getValues()));
00284         self.assertEqual(expected6,list(conn.getValues()));
00285         pass
    

Definition at line 286 of file MEDCouplingBasicsTest.py.

00286 
00287     def testDescConn3D(self):
00288         mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
00289         desc=DataArrayInt.New();
00290         descIndx=DataArrayInt.New();
00291         revDesc=DataArrayInt.New();
00292         revDescIndx=DataArrayInt.New();
00293         #
00294         mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
00295         mesh2.checkCoherency();
00296         self.assertEqual(2,mesh2.getMeshDimension());
00297         self.assertEqual(36,mesh2.getNumberOfCells());
00298         self.assertEqual(37,revDescIndx.getNbOfElems()); self.assertEqual(37,revDescIndx.getNumberOfTuples());
00299         self.assertEqual(9,descIndx.getNbOfElems()); self.assertEqual(9,descIndx.getNumberOfTuples());
00300         self.assertEqual(48,desc.getNbOfElems()); self.assertEqual(48,desc.getNumberOfTuples());
00301         self.assertEqual(48,revDesc.getNbOfElems()); self.assertEqual(48,revDesc.getNumberOfTuples());
00302         expected1=[0, 6, 12, 18, 24, 30, 36, 42, 48]
00303         expected2=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 11, 12, 4, 13, 14, 15, 16, 17, 10, 18, 19, 13, 1, 20, 21, 22, 23, 24, 7, 25, 26, 27, 28, 22, 12, 29, 23, 30, 31, 32, 17, 33, 28, 34, 35, 30]
00304         expected3=[0, 1, 3, 4, 6, 8, 9, 10, 12, 13, 14, 16, 17, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 32, 34, 35, 36, 37, 38, 40, 41, 43, 44, 45, 46, 47, 48]
00305         expected4=[0, 0, 4, 0, 0, 1, 0, 2, 0, 1, 1, 5, 1, 1, 1, 3, 2, 2, 6, 2, 3, 2, 2, 3, 3, 7, 3, 3, 4, 4, 4, 5, 4, 6, 4, 5, 5, 5, 5, 7, 6, 6, 7, 6, 6, 7, 7, 7]
00306         expected5=[0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180]
00307         expected6=[4, 0, 1, 4, 3, 4, 9, 12, 13, 10, 4, 0, 9, 10, 1, 4, 1, 10, 13, 4, 4, 4, 13, 12, 3, 4, 3, 12, 9, 0, 4, 1, 2, 5, 4, 4, 10, 13, 14, 11, 4, 1, 10, 11, 2, 4, 2, 11, 14,
00308                    5, 4, 5, 14, 13, 4, 4, 3, 4, 7, 6, 4, 12, 15, 16, 13, 4, 4, 13, 16, 7, 4, 7, 16, 15, 6, 4, 6, 15, 12, 3, 4, 4, 5, 8, 7, 4, 13, 16, 17, 14, 4, 5, 14, 17, 8, 4, 8,
00309                    17, 16, 7, 4, 18, 21, 22, 19, 4, 9, 18, 19, 10, 4, 10, 19, 22, 13, 4, 13, 22, 21, 12, 4, 12, 21, 18, 9, 4, 19, 22, 23, 20, 4, 10, 19, 20, 11, 4, 11, 20, 23, 14, 4,
00310                    14, 23, 22, 13, 4, 21, 24, 25, 22, 4, 13, 22, 25, 16, 4, 16, 25, 24, 15, 4, 15, 24, 21, 12, 4, 22, 25, 26, 23, 4, 14, 23, 26, 17, 4, 17, 26, 25, 16]
00311         expected7=[4, 0, 1, 4, 3, 4, 9, 12, 13, 10, 4, 0, 9, 10, 1, 4, 1, 10, 13, 4, 4, 4, 13, 12, 3, 4, 3, 12, 9, 0, 5, 1, 2, 5, 4, 5, 10, 13, 14, 11, 5, 1, 10, 11, 2, 5, 2, 11, 14,
00312                    5, 5, 5, 14, 13, 4, 4, 3, 4, 7, 6, 4, 12, 15, 16, 13, 4, 4, 13, 16, 7, 4, 7, 16, 15, 6, 4, 6, 15, 12, 3, 5, 4, 5, 8, 7, 5, 13, 16, 17, 14, 5, 5, 14, 17, 8, 5, 8,
00313                    17, 16, 7, 4, 18, 21, 22, 19, 4, 9, 18, 19, 10, 4, 10, 19, 22, 13, 4, 13, 22, 21, 12, 4, 12, 21, 18, 9, 4, 19, 22, 23, 20, 4, 10, 19, 20, 11, 4, 11, 20, 23, 14, 4,
00314                    14, 23, 22, 13, 4, 21, 24, 25, 22, 4, 13, 22, 25, 16, 4, 16, 25, 24, 15, 4, 15, 24, 21, 12, 4, 22, 25, 26, 23, 4, 14, 23, 26, 17, 4, 17, 26, 25, 16]
00315         
00316         self.assertEqual(expected1,list(descIndx.getValues()));
00317         self.assertEqual(expected2,list(desc.getValues()));
00318         self.assertEqual(expected3,list(revDescIndx.getValues()));
00319         self.assertEqual(expected4,list(revDesc.getValues()));
00320         self.assertEqual(expected5,list(mesh2.getNodalConnectivityIndex().getValues()));
00321         self.assertEqual(expected6,list(mesh2.getNodalConnectivity().getValues()));
00322         #
00323         eltsV=[1,3]
00324         mesh.convertToPolyTypes(eltsV);
00325         mesh.checkCoherency();
00326         desc=DataArrayInt.New();
00327         descIndx=DataArrayInt.New();
00328         revDesc=DataArrayInt.New();
00329         revDescIndx=DataArrayInt.New();
00330         mesh2=mesh.buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
00331         mesh2.checkCoherency();
00332         self.assertEqual(2,mesh2.getMeshDimension());
00333         self.assertEqual(36,mesh2.getNumberOfCells());
00334         self.assertEqual(37,revDescIndx.getNbOfElems()); self.assertEqual(37,revDescIndx.getNumberOfTuples());
00335         self.assertEqual(9,descIndx.getNbOfElems()); self.assertEqual(9,descIndx.getNumberOfTuples());
00336         self.assertEqual(48,desc.getNbOfElems()); self.assertEqual(48,desc.getNumberOfTuples());
00337         self.assertEqual(48,revDesc.getNbOfElems()); self.assertEqual(48,revDesc.getNumberOfTuples());
00338         self.assertEqual(expected1,list(descIndx.getValues()));
00339         self.assertEqual(expected2,list(desc.getValues()));
00340         self.assertEqual(expected3,list(revDescIndx.getValues()));
00341         self.assertEqual(expected4,list(revDesc.getValues()));
00342         self.assertEqual(expected5,list(mesh2.getNodalConnectivityIndex().getValues()));
00343         self.assertEqual(expected7,list(mesh2.getNodalConnectivity().getValues()));
00344         pass

Definition at line 6995 of file MEDCouplingBasicsTest.py.

06995 
06996     def testDescriptionInMeshTimeUnit1(self):
06997         text1="totoTTEDD";
06998         m=MEDCouplingDataForTest.build2DTargetMesh_1();
06999         m.setDescription(text1);
07000         self.assertEqual(m.getDescription(),text1);
07001         m2=m.deepCpy();
07002         self.assertTrue(m.isEqual(m2,1e-12));
07003         self.assertEqual(m2.getDescription(),text1);
07004         m2.setDescription("ggg");
07005         self.assertTrue(not m.isEqual(m2,1e-12));
07006         #
07007         f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
07008         f.setTimeUnit(text1);
07009         self.assertEqual(f.getTimeUnit(),text1);
07010         f2=f.deepCpy();
07011         self.assertEqual(f2.getTimeUnit(),text1);
07012         #
07013         pass

Definition at line 3169 of file MEDCouplingBasicsTest.py.

03169 
03170     def testDeterminant1(self):
03171         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03172         f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
03173         f1.setTime(2.3,5,6);
03174         f1.setEndTime(3.8,7,3);
03175         f1.setMesh(mesh1);
03176         array=DataArrayDouble.New();
03177         arr1=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5]
03178         array.setValues(arr1,mesh1.getNumberOfCells(),4);
03179         f1.setArray(array);
03180         #4 components
03181         f1.checkCoherency();
03182         f2=f1.determinant();
03183         f2.checkCoherency();
03184         self.assertEqual(CONST_ON_TIME_INTERVAL,f2.getTimeDiscretization());
03185         self.assertEqual(1,f2.getNumberOfComponents());
03186         self.assertEqual(5,f2.getNumberOfValues());
03187         for i in xrange(5):
03188             self.assertAlmostEqual(-2.42,f2.getIJ(i,0),13);
03189             pass
03190         #6 components multi arrays with end array not defined
03191         f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME);
03192         f1.setTime(2.3,5,6);
03193         f1.setEndTime(3.8,7,3);
03194         f1.setMesh(mesh1);
03195         array=DataArrayDouble.New();
03196         arr2=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7,
03197               1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
03198         array.setValues(arr2,mesh1.getNumberOfNodes(),6);
03199         f1.setArray(array);
03200         self.assertRaises(InterpKernelException,f1.checkCoherency);#no end array specified !
03201         #
03202         f2=f1.determinant();
03203         self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization());
03204         self.assertEqual(1,f2.getArray().getNumberOfComponents());
03205         self.assertEqual(9,f2.getNumberOfTuples());
03206         for i in xrange(9):
03207             self.assertAlmostEqual(137.335,f2.getIJ(i,0),10);
03208             pass
03209         #6 components multi arrays with end array defined
03210         array=DataArrayDouble.New();
03211         arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5,
03212               7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5]
03213         array.setValues(arr3,mesh1.getNumberOfNodes(),6);
03214         f1.setEndArray(array);
03215         f1.checkCoherency();
03216         f2=f1.determinant();
03217         f2.checkCoherency();
03218         self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization());
03219         self.assertEqual(1,f2.getNumberOfComponents());
03220         self.assertEqual(9,f2.getNumberOfTuples());
03221         time2,it,order=f2.getTime()
03222         self.assertAlmostEqual(2.3,time2,12);
03223         self.assertEqual(5,it);
03224         self.assertEqual(6,order);
03225         time2,it,order=f2.getEndTime()
03226         self.assertAlmostEqual(3.8,time2,12);
03227         self.assertEqual(7,it);
03228         self.assertEqual(3,order);
03229         for i in xrange(9):
03230             self.assertAlmostEqual(137.335,f2.getIJ(i,0),10);
03231             self.assertAlmostEqual(1289.685,f2.getEndArray().getIJ(i,0),9);
03232             pass
03233         #9 components
03234         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
03235         f1.setTime(7.8,10,2);
03236         f1.setMesh(mesh1);
03237         array=DataArrayDouble.New();
03238         arr4=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1]
03239         array.setValues(arr4,mesh1.getNumberOfCells(),9);
03240         f1.setArray(array);
03241         #
03242         f1.checkCoherency();
03243         f2=f1.determinant();
03244         f2.checkCoherency();
03245         self.assertEqual(ONE_TIME,f2.getTimeDiscretization());
03246         self.assertEqual(1,f2.getNumberOfComponents());
03247         self.assertEqual(5,f2.getNumberOfTuples());
03248         time2,it,order=f2.getTime()
03249         self.assertAlmostEqual(7.8,time2,12);
03250         self.assertEqual(10,it);
03251         self.assertEqual(2,order);
03252         for i in xrange(5):
03253             self.assertAlmostEqual(3.267,f2.getIJ(i,0),13);
03254             pass
03255         pass

Here is the caller graph for this function:

Definition at line 4403 of file MEDCouplingBasicsTest.py.

04403 
04404     def testDeterminant1(self):
04405         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04406         f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
04407         f1.setTime(2.3,5,6);
04408         f1.setEndTime(3.8,7,3);
04409         f1.setMesh(mesh1);
04410         array=DataArrayDouble.New();
04411         arr1=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5]
04412         array.setValues(arr1,mesh1.getNumberOfCells(),4);
04413         f1.setArray(array);
04414         #4 components
04415         f1.checkCoherency();
04416         f2=f1.determinant();
04417         f2.checkCoherency();
04418         self.assertEqual(CONST_ON_TIME_INTERVAL,f2.getTimeDiscretization());
04419         self.assertEqual(1,f2.getNumberOfComponents());
04420         self.assertEqual(5,f2.getNumberOfValues());
04421         for i in xrange(5):
04422             self.assertAlmostEqual(-2.42,f2.getIJ(i,0),13);
04423             pass
04424         #6 components multi arrays with end array not defined
04425         f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME);
04426         f1.setTime(2.3,5,6);
04427         f1.setEndTime(3.8,7,3);
04428         f1.setMesh(mesh1);
04429         array=DataArrayDouble.New();
04430         arr2=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7,
04431               1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
04432         array.setValues(arr2,mesh1.getNumberOfNodes(),6);
04433         f1.setArray(array);
04434         self.assertRaises(InterpKernelException,f1.checkCoherency);#no end array specified !
04435         #
04436         f2=f1.determinant();
04437         self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization());
04438         self.assertEqual(1,f2.getArray().getNumberOfComponents());
04439         self.assertEqual(9,f2.getNumberOfTuples());
04440         for i in xrange(9):
04441             self.assertAlmostEqual(137.335,f2.getIJ(i,0),10);
04442             pass
04443         #6 components multi arrays with end array defined
04444         array=DataArrayDouble.New();
04445         arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5,
04446               7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5]
04447         array.setValues(arr3,mesh1.getNumberOfNodes(),6);
04448         f1.setEndArray(array);
04449         f1.checkCoherency();
04450         f2=f1.determinant();
04451         f2.checkCoherency();
04452         self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization());
04453         self.assertEqual(1,f2.getNumberOfComponents());
04454         self.assertEqual(9,f2.getNumberOfTuples());
04455         time2,it,order=f2.getTime()
04456         self.assertAlmostEqual(2.3,time2,12);
04457         self.assertEqual(5,it);
04458         self.assertEqual(6,order);
04459         time2,it,order=f2.getEndTime()
04460         self.assertAlmostEqual(3.8,time2,12);
04461         self.assertEqual(7,it);
04462         self.assertEqual(3,order);
04463         for i in xrange(9):
04464             self.assertAlmostEqual(137.335,f2.getIJ(i,0),10);
04465             self.assertAlmostEqual(1289.685,f2.getEndArray().getIJ(i,0),9);
04466             pass
04467         #9 components
04468         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
04469         f1.setTime(7.8,10,2);
04470         f1.setMesh(mesh1);
04471         array=DataArrayDouble.New();
04472         arr4=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1]
04473         array.setValues(arr4,mesh1.getNumberOfCells(),9);
04474         f1.setArray(array);
04475         #
04476         f1.checkCoherency();
04477         f2=f1.determinant();
04478         f2.checkCoherency();
04479         self.assertEqual(ONE_TIME,f2.getTimeDiscretization());
04480         self.assertEqual(1,f2.getNumberOfComponents());
04481         self.assertEqual(5,f2.getNumberOfTuples());
04482         time2,it,order=f2.getTime()
04483         self.assertAlmostEqual(7.8,time2,12);
04484         self.assertEqual(10,it);
04485         self.assertEqual(2,order);
04486         for i in xrange(5):
04487             self.assertAlmostEqual(3.267,f2.getIJ(i,0),13);
04488             pass
04489         pass

Here is the call graph for this function:

Definition at line 3425 of file MEDCouplingBasicsTest.py.

03425 
03426     def testDeviator1(self):
03427         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03428         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03429         f1.setMesh(mesh1);
03430         array=DataArrayDouble.New();
03431         arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
03432         array.setValues(arr1,mesh1.getNumberOfCells(),6);
03433         f1.setArray(array);
03434         f1.checkCoherency();
03435         #
03436         f2=f1.deviator();
03437         f2.checkCoherency();
03438         self.assertEqual(6,f2.getNumberOfComponents());
03439         self.assertEqual(5,f2.getNumberOfTuples());
03440         expected1=[-1.1,0.,1.1,4.5,5.6,6.7]
03441         for i in xrange(5):
03442             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
03443             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
03444             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
03445             self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13);
03446             self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13);
03447             self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13);
03448             pass
03449         #
03450         pass

Here is the caller graph for this function:

Definition at line 4659 of file MEDCouplingBasicsTest.py.

04659 
04660     def testDeviator1(self):
04661         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04662         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04663         f1.setMesh(mesh1);
04664         array=DataArrayDouble.New();
04665         arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
04666         array.setValues(arr1,mesh1.getNumberOfCells(),6);
04667         f1.setArray(array);
04668         f1.checkCoherency();
04669         #
04670         f2=f1.deviator();
04671         f2.checkCoherency();
04672         self.assertEqual(6,f2.getNumberOfComponents());
04673         self.assertEqual(5,f2.getNumberOfTuples());
04674         expected1=[-1.1,0.,1.1,4.5,5.6,6.7]
04675         for i in xrange(5):
04676             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
04677             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
04678             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
04679             self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13);
04680             self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13);
04681             self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13);
04682             pass
04683         #
04684         pass

Here is the call graph for this function:

Definition at line 2926 of file MEDCouplingBasicsTest.py.

02926 
02927     def testDotCrossProduct1(self):
02928         mesh1=MEDCouplingDataForTest.build2DTargetMesh_3();
02929         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
02930         f1.setTime(2.3,5,6);
02931         f1.setMesh(mesh1);
02932         array=DataArrayDouble.New();
02933         arr1=[7.,107.,207.,8.,108.,208.,9.,109.,209.,10.,110.,210.,11.,111.,211.,12.,112.,212.,13.,113.,213.,14.,114.,214.,15.,115.,215.,16.,116.,216.]
02934         array.setValues(arr1,mesh1.getNumberOfCells(),3);
02935         f1.setArray(array);
02936         f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
02937         f2.setTime(7.8,4,5);
02938         f2.setMesh(mesh1);
02939         array=DataArrayDouble.New();
02940         arr2=[1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.,26.,27.,28.,29.,30.]
02941         array.setValues(arr2,mesh1.getNumberOfCells(),3);
02942         f2.setArray(array);
02943         #
02944         f3=f1.dot(f2);
02945         expected1=[842.,1820.,2816.,3830.,4862.,5912.,6980.,8066.,9170.,10292.]
02946         for i in xrange(10):
02947             self.assertAlmostEqual(expected1[i],f3.getIJ(i,0),9);
02948             pass
02949         #
02950         f4=f1.crossProduct(f2);
02951         expected2=[-93., 186., -93., -392., 784., -392., -691., 1382., -691., -990., 1980., -990., -1289., 2578., -1289., -1588., 3176., -1588., -1887., 3774., -1887., -2186., 4372., -2186., -2485., 4970., -2485., -2784., 5568., -2784.]
02952         for i in xrange(30):
02953             self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9);
02954             pass
02955         pass

Definition at line 3149 of file MEDCouplingBasicsTest.py.

03149 
03150     def testDoublyContractedProduct1(self):
03151         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03152         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03153         f1.setMesh(mesh1);
03154         array=DataArrayDouble.New();
03155         arr1=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5]
03156         array.setValues(arr1,mesh1.getNumberOfCells(),6);
03157         f1.setArray(array);
03158         f1.checkCoherency();
03159         #
03160         f2=f1.doublyContractedProduct();
03161         f2.checkCoherency();
03162         self.assertEqual(1,f2.getNumberOfComponents());
03163         self.assertEqual(5,f2.getNumberOfTuples());
03164         for i in xrange(5):
03165             self.assertAlmostEqual(3906.56,f2.getIJ(i,0),9);
03166             pass
03167         #
03168         pass

Here is the caller graph for this function:

Definition at line 4383 of file MEDCouplingBasicsTest.py.

04383 
04384     def testDoublyContractedProduct1(self):
04385         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04386         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04387         f1.setMesh(mesh1);
04388         array=DataArrayDouble.New();
04389         arr1=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5]
04390         array.setValues(arr1,mesh1.getNumberOfCells(),6);
04391         f1.setArray(array);
04392         f1.checkCoherency();
04393         #
04394         f2=f1.doublyContractedProduct();
04395         f2.checkCoherency();
04396         self.assertEqual(1,f2.getNumberOfComponents());
04397         self.assertEqual(5,f2.getNumberOfTuples());
04398         for i in xrange(5):
04399             self.assertAlmostEqual(3906.56,f2.getIJ(i,0),9);
04400             pass
04401         #
04402         pass

Here is the call graph for this function:

Definition at line 3256 of file MEDCouplingBasicsTest.py.

03256 
03257     def testEigenValues1(self):
03258         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03259         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03260         f1.setMesh(mesh1);
03261         array=DataArrayDouble.New();
03262         arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
03263         array.setValues(arr1,mesh1.getNumberOfCells(),6);
03264         f1.setArray(array);
03265         f1.checkCoherency();
03266         #
03267         f2=f1.eigenValues();
03268         f2.checkCoherency();
03269         self.assertEqual(3,f2.getNumberOfComponents());
03270         self.assertEqual(5,f2.getNumberOfTuples());
03271         expected1=[13.638813677891717,-4.502313844635971,-2.2364998332557486]
03272         for i in xrange(5):
03273             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
03274             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
03275             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
03276             pass
03277         pass

Here is the caller graph for this function:

Definition at line 4490 of file MEDCouplingBasicsTest.py.

04490 
04491     def testEigenValues1(self):
04492         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04493         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04494         f1.setMesh(mesh1);
04495         array=DataArrayDouble.New();
04496         arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
04497         array.setValues(arr1,mesh1.getNumberOfCells(),6);
04498         f1.setArray(array);
04499         f1.checkCoherency();
04500         #
04501         f2=f1.eigenValues();
04502         f2.checkCoherency();
04503         self.assertEqual(3,f2.getNumberOfComponents());
04504         self.assertEqual(5,f2.getNumberOfTuples());
04505         expected1=[13.638813677891717,-4.502313844635971,-2.2364998332557486]
04506         for i in xrange(5):
04507             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
04508             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
04509             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
04510             pass
04511         pass

Here is the call graph for this function:

Definition at line 3278 of file MEDCouplingBasicsTest.py.

03278 
03279     def testEigenVectors1(self):
03280         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03281         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03282         f1.setMesh(mesh1);
03283         array=DataArrayDouble.New();
03284         arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
03285         array.setValues(arr1,mesh1.getNumberOfCells(),6);
03286         f1.setArray(array);
03287         f1.checkCoherency();
03288         #
03289         f2=f1.eigenVectors();
03290         f2.checkCoherency();
03291         self.assertEqual(9,f2.getNumberOfComponents());
03292         self.assertEqual(5,f2.getNumberOfTuples());
03293         expected1=[0.5424262364180696, 0.5351201064614425, 0.6476266283176001,#eigenvect 0
03294                    0.7381111277307373, 0.06458838384003074, -0.6715804522117897,#eigenvect 1
03295                    -0.4012053603397987, 0.8423032781211455, -0.3599436712889738#eigenvect 2
03296                    ]
03297         for i in xrange(5):
03298             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
03299             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
03300             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
03301             self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13);
03302             self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13);
03303             self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13);
03304             self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13);
03305             self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13);
03306             self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13);
03307             pass
03308         #
03309         pass

Here is the caller graph for this function:

Definition at line 4512 of file MEDCouplingBasicsTest.py.

04512 
04513     def testEigenVectors1(self):
04514         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04515         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04516         f1.setMesh(mesh1);
04517         array=DataArrayDouble.New();
04518         arr1=[1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
04519         array.setValues(arr1,mesh1.getNumberOfCells(),6);
04520         f1.setArray(array);
04521         f1.checkCoherency();
04522         #
04523         f2=f1.eigenVectors();
04524         f2.checkCoherency();
04525         self.assertEqual(9,f2.getNumberOfComponents());
04526         self.assertEqual(5,f2.getNumberOfTuples());
04527         expected1=[0.5424262364180696, 0.5351201064614425, 0.6476266283176001,#eigenvect 0
04528                    0.7381111277307373, 0.06458838384003074, -0.6715804522117897,#eigenvect 1
04529                    -0.4012053603397987, 0.8423032781211455, -0.3599436712889738#eigenvect 2
04530                    ]
04531         for i in xrange(5):
04532             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
04533             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
04534             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
04535             self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13);
04536             self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13);
04537             self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13);
04538             self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13);
04539             self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13);
04540             self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13);
04541             pass
04542         #
04543         pass

Here is the call graph for this function:

Definition at line 4942 of file MEDCouplingBasicsTest.py.

04942 
04943     def testElementaryDAThrowAndSpecialCases(self):
04944         da=DataArrayInt.New();
04945         self.assertRaises(InterpKernelException, da.checkAllocated);
04946         self.assertRaises(InterpKernelException, da.fillWithValue, 1);
04947         self.assertRaises(InterpKernelException, da.iota, 1);
04948         da.alloc(7,1);
04949         da.fillWithValue(11); #11,11,11,11...
04950         da.iota(10); #10,11,12,13...
04951         
04952         db=DataArrayInt.New();
04953         db.alloc(7,2);
04954         
04955         dbl2=DataArrayDouble.New();
04956         dbl2.alloc(7,2);
04957         self.assertRaises(InterpKernelException, dbl2.isUniform, 10., 1e-15);
04958         self.assertRaises(InterpKernelException, dbl2.sort);
04959         self.assertRaises(InterpKernelException, dbl2.reverse);
04960         self.assertRaises(InterpKernelException, dbl2.iota, 10.);
04961         
04962         dbl=DataArrayDouble.New();
04963         #DataArrayDouble not allocated yet
04964         self.assertRaises(InterpKernelException, dbl.iota, 10.);
04965         self.assertRaises(InterpKernelException, dbl.isUniform, 10., 1e-15);
04966         self.assertRaises(InterpKernelException, dbl.sort);
04967         self.assertRaises(InterpKernelException, dbl.reverse);
04968         self.assertRaises(InterpKernelException, dbl.fromNoInterlace);
04969         self.assertRaises(InterpKernelException, dbl.toNoInterlace);
04970         
04971         dbl.alloc(7,1);
04972         dbl.iota(10.);
04973         self.assertTrue(not dbl.isUniform(10.,1e-15));
04974         dbl.sort();
04975         self.assertTrue(dbl.isMonotonic(True, .99));
04976         self.assertTrue(dbl.isMonotonic(True, -.99));
04977         self.assertTrue(not dbl.isMonotonic(True, 1.1));
04978         self.assertTrue(not dbl.isMonotonic(True, -1.1));
04979         dbl.reverse();
04980         self.assertTrue(dbl.isMonotonic(False, .99));
04981         self.assertTrue(not dbl.isMonotonic(False, 1.1));
04982         self.assertTrue(not dbl.isMonotonic(False, -1.1));
04983         
04984         dc=DataArrayInt.New();
04985         dc.alloc(14,1);
04986         
04987         dd=DataArrayDouble.New();
04988         self.assertRaises(InterpKernelException, dd.checkAllocated);
04989         self.assertRaises(InterpKernelException, dd.fillWithValue, 1.);
04990         self.assertRaises(InterpKernelException, dd.iota, 1.);
04991         self.assertTrue(not ((dd.repr().find("No data"))==-1));
04992         
04993         dd.alloc(0,1); #Allocated but nbOfElements==0!
04994         self.assertTrue(not ((dd.repr().find("Number of tuples : 0"))==-1));
04995         self.assertTrue(not ((dd.repr().find("Empty Data"))==-1));
04996         dd.fillWithValue(11); #?!...ok
04997         dd.iota(10); #?!...ok
04998         self.assertTrue(dd.isMonotonic(True, 1.));  #nothing is monotonic
04999         self.assertTrue(dd.isMonotonic(False, 1.));
05000         
05001         self.assertRaises(InterpKernelException, db.copyStringInfoFrom, da);
05002         self.assertRaises(InterpKernelException, db.copyStringInfoFrom, da);
05003         cIds=[2,2]
05004         self.assertRaises(InterpKernelException, da.copyPartOfStringInfoFrom, db, cIds);
05005         cIds[0]=1;
05006         cIds[0]=-1;
05007         self.assertRaises(InterpKernelException, da.copyPartOfStringInfoFrom, db, cIds);
05008         
05009         info=["infoOfOneComponent"]*2;
05010         self.assertRaises(InterpKernelException, da.setInfoOnComponents, info);
05011         self.assertRaises(InterpKernelException, da.setInfoOnComponent, 1, info[0]);
05012         db.setInfoOnComponents(info);
05013         
05014         self.assertRaises(InterpKernelException, da.getInfoOnComponent, -1);
05015         self.assertRaises(InterpKernelException, da.getInfoOnComponent, 2);
05016         self.assertTrue(db.getInfoOnComponent(1)==db.getInfoOnComponent(0));
05017         self.assertRaises(InterpKernelException, db.getVarOnComponent, -1);
05018         self.assertRaises(InterpKernelException, db.getVarOnComponent, 2);
05019         self.assertRaises(InterpKernelException, db.getUnitOnComponent, -1);
05020         self.assertRaises(InterpKernelException, db.getUnitOnComponent, 2);
05021         
05022         self.assertTrue(da.GetVarNameFromInfo("varname unit ")=="varname unit ");
05023         self.assertTrue(da.GetVarNameFromInfo("varname]unit[")=="varname]unit[");
05024         self.assertTrue(da.GetVarNameFromInfo("[unit]")=="");
05025         self.assertTrue(da.GetVarNameFromInfo("varname [unit]")=="varname");
05026         
05027         self.assertTrue(da.GetUnitFromInfo("varname unit ")=="");
05028         self.assertTrue(da.GetUnitFromInfo("varname]unit[")=="");
05029         self.assertTrue(da.GetUnitFromInfo("[unit]")=="unit");
05030         self.assertTrue(da.GetUnitFromInfo("varname [unit]")=="unit");
05031         
05032         self.assertRaises(InterpKernelException, da.checkNbOfTuplesAndComp, db, "theMessageInThrow");
05033         self.assertRaises(InterpKernelException, da.checkNbOfTuplesAndComp, dc, "theMessageInThrow");
05034         self.assertRaises(InterpKernelException, db.checkNbOfTuplesAndComp, dc, "theMessageInThrow");
05035         
05036         self.assertRaises(InterpKernelException, da.checkNbOfTuplesAndComp, 7, 2, "theMessageInThrow");
05037         da.checkNbOfTuplesAndComp(7,1,"theMessageInThrow");
05038         
05039         self.assertRaises(InterpKernelException, db.checkNbOfElems, 7*2+1, "theMessageInThrow");
05040         db.checkNbOfElems(7*2,"theMessageInThrow");
05041         
05042         self.assertRaises(InterpKernelException, db.GetNumberOfItemGivenBES, 10, 9, 1, "theMessageInThrow");
05043         self.assertRaises(InterpKernelException, db.GetNumberOfItemGivenBES, 0, 1, -1, "theMessageInThrow");
05044         self.assertEqual(10,db.GetNumberOfItemGivenBES(0,10,1,"theMessageInThrow"));
05045         self.assertEqual(5,db.GetNumberOfItemGivenBES(0,10,2,"theMessageInThrow"));
05046         self.assertEqual(6,db.GetNumberOfItemGivenBES(0,11,2,"theMessageInThrow"));
05047         
05048         self.assertTrue(not ((da.repr().find("Number of components : 1"))==-1));
05049         self.assertTrue(not ((dd.repr().find("Number of components : 1"))==-1));
05050         self.assertTrue(not ((dbl.repr().find("Number of components : 1"))==-1));
05051         
05052         self.assertTrue(not ((da.reprZip().find("Number of components : 1"))==-1));
05053         self.assertTrue(not ((dd.reprZip().find("Number of components : 1"))==-1));
05054         self.assertTrue(not ((dbl.reprZip().find("Number of components : 1"))==-1));
05055         
05056         self.assertRaises(InterpKernelException, dbl.selectByTupleId2, 0, 1, -1);
05057         self.assertRaises(InterpKernelException, dbl.substr, -1, 1);
05058         self.assertRaises(InterpKernelException, dbl.substr, 8, 1);
05059         self.assertRaises(InterpKernelException, dbl.substr, 0, 8);
05060         self.assertRaises(InterpKernelException, dbl.meldWith, dd);
05061         
05062         self.assertRaises(InterpKernelException, dbl.setPartOfValuesAdv, dbl2, da); #dbl dbl2 not have the same number of components
05063         self.assertRaises(InterpKernelException, dbl.setPartOfValuesAdv, dd, da);  #da tuple selector DataArrayInt instance not have exactly 2 components
05064         
05065         dbl3=DataArrayDouble.New();
05066         dbl3.alloc(6,2);
05067         dbl3.fillWithValue(11.);
05068         #bad number of components
05069         self.assertRaises(InterpKernelException, dbl3.getMaxValue);
05070         self.assertRaises(InterpKernelException, dd.getMaxValue);
05071         self.assertRaises(InterpKernelException, dbl3.getMinValue);
05072         self.assertRaises(InterpKernelException, dd.getMinValue);
05073         self.assertRaises(InterpKernelException, dbl3.getAverageValue);
05074         self.assertRaises(InterpKernelException, dd.getAverageValue);
05075         self.assertRaises(InterpKernelException, dd.accumulate, 100);
05076         self.assertRaises(InterpKernelException, dbl.fromPolarToCart);
05077         self.assertRaises(InterpKernelException, dbl3.fromCylToCart);
05078         self.assertRaises(InterpKernelException, dbl3.fromSpherToCart);
05079         self.assertRaises(InterpKernelException, dbl3.doublyContractedProduct);
05080         self.assertRaises(InterpKernelException, dbl3.determinant);
05081         self.assertRaises(InterpKernelException, dbl3.eigenValues);
05082         self.assertRaises(InterpKernelException, dbl3.eigenVectors);
05083         self.assertRaises(InterpKernelException, dbl3.inverse);
05084         self.assertRaises(InterpKernelException, dbl3.trace);
05085         self.assertRaises(InterpKernelException, dbl3.deviator);
05086         
05087         dbl3.setIJ(5,1,12.);
05088         self.assertTrue(dbl3.getMaxValueInArray()==12.);
05089         self.assertTrue(dbl3.getMinValueInArray()==11.);
05090         
05091         db.fillWithValue(100); #bad Ids
05092         self.assertRaises(InterpKernelException, dbl3.setPartOfValuesAdv, dbl2, db);
05093         db.fillWithValue(-1); #bad Ids
05094         self.assertRaises(InterpKernelException, dbl3.setPartOfValuesAdv, dbl2, db);
05095         db.fillWithValue(6); #bad Ids for dbl3
05096         self.assertRaises(InterpKernelException, dbl3.setPartOfValuesAdv, dbl2, db);
05097         
05098         dbl3.checkNoNullValues();
05099         dbl3.setIJ(5,0,0.);
05100         self.assertRaises(InterpKernelException, dbl3.checkNoNullValues);
05101         self.assertRaises(InterpKernelException, dbl3.applyInv, 1.);  #div by zero
05102         self.assertRaises(InterpKernelException, dbl2.getIdsInRange, 1., 2.);
05103         a=[]
05104         self.assertRaises(InterpKernelException, DataArrayDouble_Aggregate, a);
05105         self.assertRaises(InterpKernelException, DataArrayDouble_Meld, a);
05106         
05107         a=[dbl2,dbl]; #Nb of components mismatch
05108         self.assertRaises(InterpKernelException, DataArrayDouble_Aggregate, a);
05109         
05110         self.assertRaises(InterpKernelException, DataArrayDouble_Dot, dbl2, dbl);
05111         
05112         self.assertRaises(InterpKernelException, DataArrayDouble_CrossProduct, dbl2, dbl); #Nb of components mismatch
05113         self.assertRaises(InterpKernelException, DataArrayDouble_CrossProduct, dbl2, dbl2); #Nb of components must be equal to 3
05114         dbl4=DataArrayDouble.New();
05115         dbl4.alloc(6,3);
05116         dbl5=DataArrayDouble.New();
05117         dbl5.alloc(7,3);
05118         self.assertRaises(InterpKernelException, DataArrayDouble_CrossProduct, dbl4, dbl5); #Nb of tuples mismatch
05119         
05120         a[0]=dbl4; #Nb of tuple mismatch
05121         a[1]=dbl5; #Nb of tuple mismatch
05122         self.assertRaises(InterpKernelException, DataArrayDouble_Meld, a);
05123         self.assertRaises(InterpKernelException, DataArrayDouble_Dot, dbl4, dbl5);
05124         pass

Definition at line 7927 of file MEDCouplingBasicsTest.py.

07927 
07928     def testEmulateMEDMEMBDC1(self):
07929         m,m1=MEDCouplingDataForTest.buildPointe_1();
07930         m2,da1,da2,da3,da4,da5,da0=m.emulateMEDMEMBDC(m1)
07931         expected0=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46]
07932         expected1=[1,32,29,23,41,36]
07933         self.assertEqual(47,da0.getNumberOfTuples());
07934         self.assertEqual(1,da0.getNumberOfComponents());
07935         for i in xrange(47):
07936             self.assertEqual(expected0[i],da0.getIJ(0,i));
07937             pass
07938         self.assertEqual(6,da5.getNumberOfTuples());
07939         self.assertEqual(1,da5.getNumberOfComponents());
07940         for i in xrange(6):
07941             self.assertEqual(expected1[i],da5.getIJ(0,i));
07942             pass
07943         expected2=[0,1,2,3,4,0,5,6,7,4,8,9,1,7,10,11,12,13,14,5,15,16,17,8,18,19,20,10,21,22,23,2,13,24,25,21,16,26,27,12,19,28,29,15,22,30,31,18,36,26,28,30,24,37,32,33,34,35,38,36,39,40,41,42,37,38,43,44,45,46]
07944         self.assertEqual(70,da1.getNumberOfTuples());
07945         self.assertEqual(1,da1.getNumberOfComponents());
07946         for i in xrange(70):
07947             self.assertEqual(expected2[i],da1.getIJ(0,i));
07948             pass
07949         expected3=[0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70]
07950         self.assertEqual(17,da2.getNumberOfTuples());
07951         self.assertEqual(1,da2.getNumberOfComponents());
07952         for i in xrange(17):
07953             self.assertEqual(expected3[i],da2.getIJ(0,i));
07954             pass
07955         expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,53,54,55,56,58,60,62,63,64,65,66,67,68,69,70]
07956         #expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,54,56,57,58,59,60,62,63,64,65,66,67,68,69,70];
07957         self.assertEqual(48,da4.getNumberOfTuples());
07958         self.assertEqual(1,da4.getNumberOfComponents());
07959         for i in xrange(48):
07960             self.assertEqual(expected4[i],da4.getIJ(0,i));
07961             pass
07962         expected5=[0,1,0,3,0,7,0,1,2,1,4,1,2,3,2,5,2,3,6,3,4,9,4,8,4,5,10,5,9,5,6,11,6,10,6,7,8,7,11,7,8,12,8,9,12,9,10,12,10,11,12,11,13,13,13,13,12,14,13,15,14,15,14,14,14,14,15,15,15,15]
07963         self.assertEqual(70,da3.getNumberOfTuples());
07964         self.assertEqual(1,da3.getNumberOfComponents());
07965         for i in xrange(70):
07966             self.assertEqual(expected5[i],da3.getIJ(0,i));
07967             pass
07968         pass

Definition at line 567 of file MEDCouplingBasicsTest.py.

00567 
00568     def testEqualFieldDouble(self):
00569         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
00570         mesh2=MEDCouplingDataForTest.build2DTargetMesh_1();
00571         #
00572         fieldOnCells1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00573         fieldOnCells1.setMesh(mesh1);
00574         fieldOnCells2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00575         fieldOnCells2.setMesh(mesh2);
00576         #
00577         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00578         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00579         #
00580         fieldOnNodes1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00581         self.assertTrue(not fieldOnCells1.isEqual(fieldOnNodes1,1e-12,1e-15));
00582         self.assertTrue(not fieldOnNodes1.isEqual(fieldOnCells1,1e-12,1e-15));
00583         #
00584         fieldOnCells2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00585         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00586         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00587         fieldOnCells1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
00588         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00589         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00590         fieldOnCells1.setTime(4.,6,7);
00591         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00592         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00593         fieldOnCells2.setTime(4.,6,7);
00594         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00595         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00596         fieldOnCells1.setName("Power");
00597         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00598         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00599         fieldOnCells2.setName("Power");
00600         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00601         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00602         #
00603         fieldOnCells1.setMesh(mesh1);
00604         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00605         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00606         fieldOnCells2.setMesh(mesh1);
00607         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00608         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00609         arr=DataArrayDouble.New();
00610         arr.setName("popo");
00611         arr.setValues(mesh1.getNumberOfCells()*3*[6.],mesh1.getNumberOfCells(),3);
00612         fieldOnCells1.setArray(arr);
00613         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00614         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00615         fieldOnCells2.setArray(arr);
00616         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00617         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00618         #
00619         arr2=arr.deepCpy();
00620         fieldOnCells2.setArray(arr2);
00621         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00622         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00623         arr.setIJ(1,2,6.1);
00624         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00625         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00626         arr.setIJ(1,2,6.);
00627         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00628         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00629         arr2.setName("popo2");
00630         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00631         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00632         #
00633         arr2.setName("popo");
00634         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00635         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00636         #
00637         arr2.setInfoOnComponent(2,"jjj");
00638         self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00639         self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00640         arr.setInfoOnComponent(2,"jjj");
00641         self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
00642         self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
00643         pass

Definition at line 517 of file MEDCouplingBasicsTest.py.

00517 
00518     def testEqualMesh(self):
00519         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
00520         mesh2=MEDCouplingDataForTest.build2DTargetMesh_1();
00521         #
00522         self.assertTrue(mesh1.isEqual(mesh1,1e-12));
00523         #
00524         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
00525         self.assertTrue(mesh2.isEqual(mesh1,1e-12));
00526         pt=mesh2.getCoords().getValues();
00527         tmp=pt[1]
00528         mesh2.getCoords().setIJ(0,1,5.999);
00529         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
00530         self.assertTrue(not mesh2.isEqual(mesh1,1e-12));
00531         mesh2.getCoords().setIJ(0,1,tmp);
00532         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
00533         self.assertTrue(mesh2.isEqual(mesh1,1e-12));
00534         #
00535         pt2=mesh1.getNodalConnectivity().getValues();
00536         mesh1.getNodalConnectivity().setIJ(5,0,int(pt2[5])+1);
00537         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
00538         self.assertTrue(not mesh2.isEqual(mesh1,1e-12));
00539         mesh1.getNodalConnectivity().setIJ(5,0,int(pt2[5]));
00540         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
00541         self.assertTrue(mesh2.isEqual(mesh1,1e-12));
00542         #
00543         pt2=mesh1.getNodalConnectivityIndex().getValues();
00544         mesh1.getNodalConnectivityIndex().setIJ(1,0,int(pt2[1]+1));
00545         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
00546         self.assertTrue(not mesh2.isEqual(mesh1,1e-12));
00547         mesh1.getNodalConnectivityIndex().setIJ(1,0,int(pt2[1]));
00548         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
00549         self.assertTrue(mesh2.isEqual(mesh1,1e-12));
00550         #
00551         tmp3=mesh1.getName();
00552         mesh1.setName("lllll");
00553         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
00554         self.assertTrue(not mesh2.isEqual(mesh1,1e-12));
00555         mesh1.setName(tmp3);
00556         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
00557         self.assertTrue(mesh2.isEqual(mesh1,1e-12));
00558         #
00559         tmp3=mesh2.getCoords().getInfoOnComponent(1);
00560         mesh2.getCoords().setInfoOnComponent(1,"kkkkkk");
00561         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
00562         self.assertTrue(not mesh2.isEqual(mesh1,1e-12));
00563         mesh2.getCoords().setInfoOnComponent(1,tmp3);
00564         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
00565         self.assertTrue(mesh2.isEqual(mesh1,1e-12));
00566         pass
    

Definition at line 683 of file MEDCouplingBasicsTest.py.

00683 
00684     def testExtrudedMesh1(self):
00685         mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
00686         ext=MEDCouplingExtrudedMesh.New(mesh3D,mesh2D,1);
00687         self.assertEqual(18,ext.getNumberOfCells());
00688         self.assertEqual(60,ext.getNumberOfNodes());
00689         ids3D=ext.getMesh3DIds();
00690         ids3DExpected=[5,4,3,2,1,0, 11,10,9,8,7,6, 17,16,15,14,13,12]
00691         self.assertEqual(18,ids3D.getNumberOfTuples());
00692         self.assertEqual(1,ids3D.getNumberOfComponents());
00693         self.assertEqual(ids3DExpected,list(ids3D.getValues()));
00694         mesh1D=ext.getMesh1D();
00695         self.assertEqual(4,mesh1D.getNumberOfNodes());
00696         self.assertEqual(3,mesh1D.getNumberOfCells());
00697         mesh1DExpected=[0.66666666666666663, 1.4583333333333333, 0, 0.66666666666666663,
00698                         1.4583333333333333, 1, 0.66666666666666663, 1.4583333333333333,
00699                         2, 0.66666666666666663, 1.4583333333333333, 3]
00700         mesh1DCoords=mesh1D.getCoords();
00701         self.assertEqual(4,mesh1DCoords.getNumberOfTuples());
00702         self.assertEqual(3,mesh1DCoords.getNumberOfComponents());
00703         self.assertEqual(mesh1DExpected,mesh1DCoords.getValues());
00704         conn1D=mesh1D.getNodalConnectivity();
00705         self.assertEqual(9,conn1D.getNumberOfTuples());
00706         self.assertEqual(1,conn1D.getNumberOfComponents());
00707         conn1DExpected=[1,0,1,1,1,2,1,2,3]
00708         self.assertEqual(conn1DExpected,list(conn1D.getValues()));
00709         pass

Definition at line 710 of file MEDCouplingBasicsTest.py.

00710 
00711     def testExtrudedMesh3(self):
00712         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
00713         m1.changeSpaceDimension(3);
00714         m2=MEDCouplingDataForTest.buildCU1DMesh_U();
00715         m2.changeSpaceDimension(3);
00716         center=[0.,0.,0.]
00717         vector=[0.,1.,0.]
00718         m2.rotate(center,vector,-pi/2.);
00719         m3=m1.buildExtrudedMesh(m2,0);
00720         #
00721         m4=MEDCouplingExtrudedMesh.New(m3,m1,0);
00722         self.assertEqual(15,m4.getNumberOfCells());
00723         self.assertEqual(5,m4.getMesh2D().getNumberOfCells());
00724         self.assertEqual(3,m4.getMesh1D().getNumberOfCells());
00725         m3DIds=m4.getMesh3DIds().getValues();
00726         self.assertEqual(range(15),list(m3DIds));
00727         #some random in cells to check that extrusion alg find it correctly
00728         expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4]
00729         m3.renumberCells(expected1,False);
00730         m4=MEDCouplingExtrudedMesh.New(m3,m1,0);
00731         self.assertEqual(15,m4.getNumberOfCells());
00732         self.assertEqual(5,m4.getMesh2D().getNumberOfCells());
00733         self.assertEqual(3,m4.getMesh1D().getNumberOfCells());
00734         m3DIds=m4.getMesh3DIds().getValues();
00735         self.assertEqual(expected1,list(m3DIds));
00736         #play with polygons and polyedrons
00737         cells=[2,3]
00738         m1.convertToPolyTypes(cells);
00739         m3=m1.buildExtrudedMesh(m2,0);
00740         self.assertEqual(NORM_HEXA8,m3.getTypeOfCell(0));
00741         self.assertEqual(NORM_PENTA6,m3.getTypeOfCell(1));
00742         self.assertEqual(NORM_POLYHED,m3.getTypeOfCell(2));
00743         self.assertEqual(NORM_POLYHED,m3.getTypeOfCell(3));
00744         self.assertEqual(NORM_HEXA8,m3.getTypeOfCell(4));
00745         m3.renumberCells(expected1,False);
00746         m4=MEDCouplingExtrudedMesh.New(m3,m1,0);
00747         self.assertEqual(15,m4.getNumberOfCells());
00748         self.assertEqual(5,m4.getMesh2D().getNumberOfCells());
00749         self.assertEqual(3,m4.getMesh1D().getNumberOfCells());
00750         m3DIds=m4.getMesh3DIds().getValues();
00751         self.assertEqual(expected1,list(m3DIds));
00752         pass

Definition at line 753 of file MEDCouplingBasicsTest.py.

00753 
00754     def testExtrudedMesh4(self):
00755         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
00756         cells=[2,4];
00757         m1.convertToPolyTypes(cells);
00758         m1.changeSpaceDimension(3);
00759         m2=MEDCouplingDataForTest.buildCU1DMesh_U();
00760         m2.changeSpaceDimension(3);
00761         center=[0.,0.,0.]
00762         vector=[0.,1.,0.]
00763         m2.rotate(center,vector,-pi/2.);
00764         m3=m1.buildExtrudedMesh(m2,0);
00765         expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4]
00766         rexpected1=[3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12]
00767         m3.renumberCells(expected1,False);
00768         m4=MEDCouplingExtrudedMesh.New(m3,m1,0);
00769         self.assertEqual(NORM_HEXA8,m4.getTypeOfCell(0));
00770         self.assertEqual(NORM_HEXA8,m4.getTypeOfCell(1));
00771         self.assertEqual(NORM_POLYHED,m4.getTypeOfCell(2));
00772         self.assertEqual(NORM_PENTA6,m4.getTypeOfCell(7));
00773         f=m4.getMeasureField(True);
00774         arr=f.getArray();
00775         self.assertEqual(15,arr.getNumberOfTuples());
00776         self.assertEqual(1,arr.getNumberOfComponents());
00777         arrPtr=arr.getValues();
00778         expected2=[0.075,0.0375,0.0375,0.075,0.075,
00779                    0.1125,0.05625,0.05625,0.1125,0.1125,
00780                    0.0625,0.03125,0.03125,0.0625,0.0625]
00781         for i in xrange(15):
00782             self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],16);
00783             pass
00784         m5=m4.build3DUnstructuredMesh();
00785         self.assertTrue(m5.isEqual(m3,1e-12));
00786         f=m5.getMeasureField(True);
00787         f.setMesh(m4)
00788         self.assertTrue(isinstance(f.getMesh(),MEDCouplingExtrudedMesh))
00789         arr=f.getArray();
00790         arrPtr=arr.getValues();
00791         for i in xrange(15):
00792             self.assertAlmostEqual(expected2[rexpected1[i]],arrPtr[i],15);
00793             pass
00794         pass

Definition at line 5407 of file MEDCouplingBasicsTest.py.

05407 
05408     def testExtrudedMesh5(self):
05409         coo1=[0.,1.,2.,3.5]
05410         a=DataArrayDouble.New();
05411         a.setValues(coo1,4,1);
05412         b=MEDCouplingCMesh.New();
05413         b.setCoordsAt(0,a);
05414         c=b.buildUnstructured();
05415         self.assertEqual(1,c.getSpaceDimension());
05416         c.changeSpaceDimension(2);
05417         #
05418         d=DataArrayDouble.New();
05419         d.alloc(13,1);
05420         d.iota();
05421         e=MEDCouplingCMesh.New();
05422         e.setCoordsAt(0,d);
05423         f=e.buildUnstructured();
05424         g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
05425         h=g.fromPolarToCart();
05426         f.setCoords(h);
05427         i=c.buildExtrudedMesh(f,1);
05428         self.assertEqual(52,i.getNumberOfNodes());
05429         tmp,tmp2,tmp3=i.mergeNodes(1e-9);
05430         self.assertTrue(tmp2);
05431         self.assertEqual(37,tmp3);
05432         i.convertDegeneratedCells();
05433         i.checkCoherency();
05434         self.assertEqual(36,i.getNumberOfCells());
05435         self.assertEqual(37,i.getNumberOfNodes());
05436         self.assertEqual(12,i.getNumberOfCellsWithType(NORM_TRI3));
05437         self.assertEqual(24,i.getNumberOfCellsWithType(NORM_QUAD4));
05438         expected1=[0.25,0.75,2.0625]
05439         j=i.getMeasureField(True);
05440         for ii in xrange(12):
05441             for k in xrange(3):
05442                 self.assertAlmostEqual(expected1[k],j.getIJ(0,ii*3+k),10);
05443                 pass
05444             pass
05445         expected2=[0.62200846792814113, 0.16666666666681595, 1.4513530918323276, 0.38888888888923495, 2.6293994326053212, 0.7045454545460802, 0.45534180126145435, 0.45534180126150181, 1.0624642029433926, 1.0624642029435025, 1.9248539780597826, 1.9248539780599816, 0.16666666666661334, 0.62200846792815856, 0.38888888888876294, 1.4513530918323678, 0.70454545454522521, 2.629399432605394, -0.16666666666674007, 0.62200846792812436, -0.38888888888906142, 1.4513530918322881, -0.70454545454576778, 2.6293994326052488, -0.45534180126154766, 0.45534180126140844, -1.0624642029436118, 1.0624642029432834, -1.9248539780601803, 1.9248539780595841, -0.62200846792817499, 0.1666666666665495, -1.451353091832408, 0.388888888888613, -2.6293994326054668, 0.70454545454495332, -0.62200846792810593, -0.16666666666680507, -1.451353091832247, -0.38888888888921297, -2.6293994326051746, -0.70454545454604123, -0.45534180126135926, -0.45534180126159562, -1.0624642029431723, -1.0624642029437235, -1.9248539780593836, -1.9248539780603811, -0.1666666666664828, -0.62200846792819242, -0.38888888888846079, -1.4513530918324489, -0.70454545454467987, -2.6293994326055397, 0.16666666666687083, -0.62200846792808862, 0.38888888888936374, -1.4513530918322073, 0.70454545454631357, -2.6293994326051022, 0.45534180126164348, -0.45534180126131207, 1.0624642029438327, -1.0624642029430627, 1.9248539780605791, -1.9248539780591853, 0.62200846792821063, -0.16666666666641802, 1.4513530918324888, -0.38888888888831086, 2.6293994326056125, -0.70454545454440853]
05446         m=i.getBarycenterAndOwner();
05447         for i in xrange(72):
05448             self.assertAlmostEqual(expected2[i],m.getIJ(0,i),10);
05449             pass
05450         #
05451         pass

Definition at line 5452 of file MEDCouplingBasicsTest.py.

05452 
05453     def testExtrudedMesh6(self):
05454         coo1=[0.,1.,2.,3.5]
05455         a=DataArrayDouble.New();
05456         a.setValues(coo1,4,1);
05457         b=MEDCouplingCMesh.New();
05458         b.setCoordsAt(0,a);
05459         c=b.buildUnstructured();
05460         self.assertEqual(1,c.getSpaceDimension());
05461         c.changeSpaceDimension(2);
05462         #
05463         d=DataArrayDouble.New();
05464         d.alloc(5,1);
05465         d.iota();
05466         e=MEDCouplingCMesh.New();
05467         e.setCoordsAt(0,d);
05468         f=e.buildUnstructured();
05469         d2=f.getCoords().applyFunc("x*x/2");
05470         f.setCoords(d2);
05471         f.changeSpaceDimension(2);
05472         #
05473         center=[0.,0.]
05474         f.rotate(center,[],pi/3);
05475         g=c.buildExtrudedMesh(f,0);
05476         g.checkCoherency();
05477         expected1=[ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 ]
05478         f1=g.getMeasureField(True);
05479         for i in xrange(12):
05480             self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),12);
05481             pass
05482         expected2=[0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414]
05483         f2=g.getBarycenterAndOwner();
05484         for i in xrange(24):
05485             self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),12);
05486             pass
05487         pass

Definition at line 5488 of file MEDCouplingBasicsTest.py.

05488 
05489     def testExtrudedMesh7(self):
05490         coo1=[0.,1.,2.,3.5]
05491         a=DataArrayDouble.New();
05492         a.setValues(coo1,4,1);
05493         b=MEDCouplingCMesh.New();
05494         b.setCoordsAt(0,a);
05495         c=b.buildUnstructured();
05496         self.assertEqual(1,c.getSpaceDimension());
05497         c.changeSpaceDimension(2);
05498         #
05499         d=DataArrayDouble.New();
05500         d.alloc(13,1);
05501         d.iota();
05502         e=MEDCouplingCMesh.New();
05503         e.setCoordsAt(0,d);
05504         f=e.buildUnstructured();
05505         g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
05506         h=g.fromPolarToCart();
05507         f.setCoords(h);
05508         i=c.buildExtrudedMesh(f,1);
05509         self.assertEqual(52,i.getNumberOfNodes());
05510         tmp,tmp2,tmp3=i.mergeNodes(1e-9);
05511         self.assertTrue(tmp2);
05512         self.assertEqual(37,tmp3);
05513         i.convertDegeneratedCells();
05514         vec1=[10.,0]
05515         i.translate(vec1);
05516         g2=h.applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec");
05517         f.setCoords(g2);
05518         i.changeSpaceDimension(3);
05519         i3=i.buildExtrudedMesh(f,1);
05520         f2=i3.getMeasureField(True);
05521         tmp,tmp2,tmp3=i.mergeNodes(1e-9);
05522         self.assertTrue(tmp2);
05523         self.assertEqual(444,tmp3);
05524         expected1=[1.327751058489274, 4.2942574094314701, 13.024068164857139, 1.3069177251569044, 4.1484240761012954, 12.297505664866796, 1.270833333332571, 3.8958333333309674, 11.039062499993179, 1.2291666666659207, 3.6041666666644425, 9.585937499993932, 1.1930822748415895, 3.3515759238941376, 8.3274943351204556, 1.1722489415082769, 3.2057425905609289, 7.6009318351210622, 1.1722489415082862, 3.2057425905609884, 7.6009318351213713, 1.1930822748416161, 3.3515759238943001, 8.3274943351212727, 1.2291666666659564, 3.6041666666646734, 9.5859374999950777, 1.2708333333326081, 3.8958333333311868, 11.039062499994293, 1.3069177251569224, 4.1484240761014384, 12.297505664867627, 1.3277510584902354, 4.2942574094346071, 13.024068164866796]
05525         for ii in xrange(12):
05526             for jj in xrange(36):
05527                 self.assertAlmostEqual(expected1[jj],f2.getIJ(0,ii*36+jj),9);
05528                 pass
05529         #
05530         pass

Definition at line 5319 of file MEDCouplingBasicsTest.py.

05319 
05320     def testFieldCopyTinyAttrFrom1(self):
05321         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
05322         f1.setName("f1");
05323         f1.setTimeTolerance(1.e-5);
05324         f1.setDescription("f1Desc");
05325         f1.setTime(1.23,4,5);
05326         f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
05327         f2.setName("f2");
05328         f2.setDescription("f2Desc");
05329         f2.setTime(6.78,9,10);
05330         f2.setTimeTolerance(4.556e-12);
05331         #
05332         f1.copyTinyAttrFrom(f2);
05333         self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
05334         t,dt,it=f1.getTime()
05335         self.assertAlmostEqual(6.78,t,12);
05336         self.assertEqual(9,dt);
05337         self.assertEqual(10,it);
05338         self.assertTrue(f1.getName()=="f1");#name unchanged
05339         self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
05340         #
05341         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
05342         f1.setName("f1");
05343         f1.setTimeTolerance(1.e-5);
05344         f1.setDescription("f1Desc");
05345         f2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
05346         f2.setName("f2");
05347         f2.setDescription("f2Desc");
05348         f2.setTimeTolerance(4.556e-12);
05349         #
05350         f1.copyTinyAttrFrom(f2);
05351         self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
05352         self.assertTrue(f1.getName()=="f1");#name unchanged
05353         self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
05354         #
05355         f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
05356         f1.setName("f1");
05357         f1.setTimeTolerance(1.e-5);
05358         f1.setDescription("f1Desc");
05359         f1.setTime(1.23,4,5);
05360         f1.setEndTime(5.43,2,1);
05361         f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
05362         f2.setName("f2");
05363         f2.setDescription("f2Desc");
05364         f2.setTimeTolerance(4.556e-12);
05365         f2.setTime(6.78,9,10);
05366         f2.setEndTime(10.98,7,6);
05367         #
05368         f1.copyTinyAttrFrom(f2);
05369         self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
05370         self.assertTrue(f1.getName()=="f1");#name unchanged
05371         self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
05372         t,dt,it=f1.getTime()
05373         self.assertAlmostEqual(6.78,t,12);
05374         self.assertEqual(9,dt);
05375         self.assertEqual(10,it);
05376         t,dt,it=f1.getEndTime()
05377         self.assertAlmostEqual(10.98,t,12);
05378         self.assertEqual(7,dt);
05379         self.assertEqual(6,it);
05380         #
05381         f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
05382         f1.setName("f1");
05383         f1.setTimeTolerance(1.e-5);
05384         f1.setDescription("f1Desc");
05385         f1.setTime(1.23,4,5);
05386         f1.setEndTime(5.43,2,1);
05387         f2=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
05388         f2.setName("f2");
05389         f2.setDescription("f2Desc");
05390         f2.setTimeTolerance(4.556e-12);
05391         f2.setTime(6.78,9,10);
05392         f2.setEndTime(10.98,7,6);
05393         #
05394         f1.copyTinyAttrFrom(f2);
05395         self.assertAlmostEqual(4.556e-12,f1.getTimeTolerance(),24);
05396         self.assertTrue(f1.getName()=="f1");#name unchanged
05397         self.assertTrue(f1.getDescription()=="f1Desc");#description unchanged
05398         t,dt,it=f1.getTime()
05399         self.assertAlmostEqual(6.78,t,12);
05400         self.assertEqual(9,dt);
05401         self.assertEqual(10,it);
05402         t,dt,it=f1.getEndTime()
05403         self.assertAlmostEqual(10.98,t,12);
05404         self.assertEqual(7,dt);
05405         self.assertEqual(6,it);
05406         pass

Definition at line 4244 of file MEDCouplingBasicsTest.py.

04244 
04245     def testFieldDoubleGetMinMaxValues2(self):
04246         m2,m1=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
04247         self.assertEqual(18,m2.getNumberOfCells());
04248         arr1=[8.71,4.53,-12.41,8.71,-8.71,8.7099,4.55,8.71,5.55,6.77,-1e-200,4.55,8.7099,0.,1.23,0.,2.22,8.71]
04249         f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04250         a=DataArrayDouble.New();
04251         a.setValues(arr1,18,1);
04252         f.setArray(a);
04253         f.setMesh(m2);
04254         #
04255         f.checkCoherency();
04256         m=f.getMaxValue();
04257         self.assertAlmostEqual(8.71,m,12);
04258         m,ws=f.getMaxValue2();
04259         self.assertAlmostEqual(8.71,m,12);
04260         self.assertEqual(4,ws.getNumberOfTuples());
04261         self.assertEqual(1,ws.getNumberOfComponents());
04262         expected1=[0,3,7,17]
04263         for i in xrange(4):
04264             self.assertEqual(expected1[i],ws.getIJ(i,0));
04265             pass
04266         #
04267         arr2=[-8.71,-4.53,12.41,-8.71,8.71,-8.7099,-4.55,-8.71,-5.55,-6.77,1e-200,-4.55,-8.7099,0.,-1.23,0.,-2.22,-8.71]
04268         a.setValues(arr2,18,1);
04269         f.checkCoherency();
04270         m=f.getMinValue();
04271         self.assertAlmostEqual(-8.71,m,12);
04272         m,ws=f.getMinValue2();
04273         self.assertAlmostEqual(-8.71,m,12);
04274         self.assertEqual(4,ws.getNumberOfTuples());
04275         self.assertEqual(1,ws.getNumberOfComponents());
04276         for i in xrange(4):
04277             self.assertEqual(expected1[i],ws.getIJ(i,0));
04278             pass
04279         pass

Definition at line 3743 of file MEDCouplingBasicsTest.py.

03743 
03744     def testFieldDoubleOpEqual1(self):
03745         m=MEDCouplingDataForTest.build2DTargetMesh_1();
03746         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
03747         self.assertRaises(InterpKernelException,f1.assign,0.07);
03748         f1.setMesh(m);
03749         f1.assign(0.07);
03750         f1.checkCoherency();
03751         self.assertEqual(1,f1.getNumberOfComponents());
03752         self.assertEqual(5,f1.getNumberOfTuples());
03753         for i in xrange(5):
03754             self.assertAlmostEqual(0.07,f1.getIJ(i,0),16);
03755             pass
03756         f1.assign(0.09);
03757         f1.checkCoherency();
03758         self.assertEqual(1,f1.getNumberOfComponents());
03759         self.assertEqual(5,f1.getNumberOfTuples());
03760         for i in xrange(5):
03761             self.assertAlmostEqual(0.09,f1.getIJ(i,0),16);
03762             pass
03763         #
03764         f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME);
03765         f1.setEndTime(4.5,2,3);
03766         f1.setMesh(m);
03767         f1.assign(0.08);
03768         f1.checkCoherency();
03769         self.assertEqual(1,f1.getNumberOfComponents());
03770         self.assertEqual(9,f1.getNumberOfTuples());
03771         for i in xrange(9):
03772             self.assertAlmostEqual(0.08,f1.getIJ(i,0),16);
03773             pass
03774         self.assertEqual(1,f1.getEndArray().getNumberOfComponents());
03775         self.assertEqual(9,f1.getEndArray().getNumberOfTuples());
03776         for i in xrange(9):
03777             self.assertAlmostEqual(0.08,f1.getEndArray().getIJ(i,0),16);
03778             pass
03779         pass

Definition at line 3972 of file MEDCouplingBasicsTest.py.

03972 
03973     def testFieldDoubleZipConnectivity1(self):
03974         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
03975         m2=MEDCouplingDataForTest.build2DTargetMesh_1();
03976         cells1=[2,3,4]
03977         m3_1=m2.buildPartOfMySelf(cells1,True);
03978         m3=m3_1;
03979         m4=MEDCouplingDataForTest.build2DSourceMesh_1();
03980         m5=MEDCouplingUMesh.MergeUMeshes(m1,m3);
03981         m6=MEDCouplingUMesh.MergeUMeshes(m5,m4);
03982         #
03983         self.assertEqual(10,m6.getNumberOfCells());
03984         self.assertEqual(22,m6.getNumberOfNodes());
03985         arr,areNodesMerged,newNbOfNodes=m6.mergeNodes(1e-13);
03986         self.assertEqual(9,m6.getNumberOfNodes());
03987         f=m6.fillFromAnalytic(ON_CELLS,2,"x");
03988         f2=m6.fillFromAnalytic(ON_NODES,2,"x");
03989         self.assertEqual(10,f.getNumberOfTuples());
03990         self.assertEqual(2,f.getNumberOfComponents());
03991         expected1=[-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321,
03992                    -0.05, -0.05, 0.45, 0.45, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45,
03993                    0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326];
03994         for i in xrange(20):
03995             self.assertAlmostEqual(expected1[i],f.getIJ(0,i),12);
03996             pass
03997         f.getArray().setInfoOnComponent(0,"titi");
03998         f.getArray().setInfoOnComponent(1,"tutu");
03999         f.checkCoherency();
04000         self.assertTrue(f.zipConnectivity(0));
04001         expected2=[-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321,
04002                    -0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326];
04003         self.assertEqual(7,f.getNumberOfTuples());
04004         self.assertEqual(2,f.getNumberOfComponents());
04005         for i in xrange(14):
04006             self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12);
04007             pass
04008         self.assertTrue(f.getArray().getInfoOnComponent(0)=="titi");
04009         self.assertTrue(f.getArray().getInfoOnComponent(1)=="tutu");
04010         self.assertTrue(not f.zipConnectivity(0));
04011         #
04012         expected3=[-0.3, -0.3, 0.2, 0.2, 0.7, 0.7, -0.3, -0.3, 0.2, 0.2, 0.7, 0.7,
04013                    -0.3, -0.3, 0.2, 0.2, 0.7, 0.7];
04014         self.assertEqual(9,f2.getNumberOfTuples());
04015         self.assertEqual(2,f2.getNumberOfComponents());
04016         for i in xrange(18):
04017             self.assertAlmostEqual(expected3[i],f2.getIJ(0,i),12);
04018             pass
04019         self.assertTrue(f2.zipConnectivity(0));
04020         self.assertEqual(9,f2.getNumberOfTuples());
04021         self.assertEqual(2,f2.getNumberOfComponents());
04022         for i in xrange(18):
04023             self.assertAlmostEqual(expected3[i],f2.getIJ(0,i),12);
04024             pass
04025         pass

Definition at line 3945 of file MEDCouplingBasicsTest.py.

03945 
03946     def testFieldDoubleZipCoords1(self):
03947         m=MEDCouplingDataForTest.build2DTargetMeshMergeNode_1();
03948         f=m.fillFromAnalytic(ON_NODES,2,"x*2.");
03949         f.getArray().setInfoOnComponent(0,"titi");
03950         f.getArray().setInfoOnComponent(1,"tutu");
03951         f.checkCoherency();
03952         self.assertEqual(18,f.getNumberOfTuples());
03953         self.assertEqual(2,f.getNumberOfComponents());
03954         expected1=[-0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4]
03955         for i in xrange(36):
03956             self.assertAlmostEqual(expected1[i],f.getIJ(0,i),12);
03957             pass
03958         self.assertTrue(f.zipCoords());
03959         f.checkCoherency();
03960         expected2=[-0.6, -0.6, 1.4, 1.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4]
03961         for i in xrange(30):
03962             self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12);
03963             pass
03964         self.assertTrue(not f.zipCoords());
03965         f.checkCoherency();
03966         for i in xrange(30):
03967             self.assertAlmostEqual(expected2[i],f.getIJ(0,i),12);
03968             pass
03969         self.assertTrue(f.getArray().getInfoOnComponent(0)=="titi");
03970         self.assertTrue(f.getArray().getInfoOnComponent(1)=="tutu");
03971         pass

Definition at line 5682 of file MEDCouplingBasicsTest.py.

05682 
05683     def testFieldMeld1(self):
05684         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
05685         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
05686         f1.setMesh(m);
05687         da1=DataArrayDouble.New();
05688         arr1=[12.,23.,34.,45.,56.]
05689         da1.setValues(arr1,5,1);
05690         da1.setInfoOnComponent(0,"aaa");
05691         f1.setArray(da1);
05692         f1.setTime(3.4,2,1);
05693         f1.checkCoherency();
05694         #
05695         f2=f1.deepCpy();
05696         f2.setMesh(f1.getMesh());
05697         f2.checkCoherency();
05698         f2.changeNbOfComponents(2,5.);
05699         f2.assign(5.);
05700         f2.getArray().setInfoOnComponent(0,"bbb");
05701         f2.getArray().setInfoOnComponent(1,"ccc");
05702         f2.checkCoherency();
05703         #
05704         f3=MEDCouplingFieldDouble.MeldFields(f2,f1);
05705         f3.checkCoherency();
05706         self.assertEqual(5,f3.getNumberOfTuples());
05707         self.assertEqual(3,f3.getNumberOfComponents());
05708         self.assertTrue(f3.getArray().getInfoOnComponent(0)=="bbb");
05709         self.assertTrue(f3.getArray().getInfoOnComponent(1)=="ccc");
05710         self.assertTrue(f3.getArray().getInfoOnComponent(2)=="aaa");
05711         expected1=[5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.]
05712         for i in xrange(15):
05713             self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),12);
05714             pass
05715         time,dt,it=f3.getTime();
05716         self.assertAlmostEqual(3.4,time,14);
05717         self.assertEqual(2,dt);
05718         self.assertEqual(1,it);
05719         #
05720         f4=f2.buildNewTimeReprFromThis(NO_TIME,False);
05721         f5=f1.buildNewTimeReprFromThis(NO_TIME,False);
05722         f6=MEDCouplingFieldDouble.MeldFields(f4,f5);
05723         f6.checkCoherency();
05724         self.assertEqual(5,f6.getNumberOfTuples());
05725         self.assertEqual(3,f6.getNumberOfComponents());
05726         self.assertTrue(f6.getArray().getInfoOnComponent(0)=="bbb");
05727         self.assertTrue(f6.getArray().getInfoOnComponent(1)=="ccc");
05728         self.assertTrue(f6.getArray().getInfoOnComponent(2)=="aaa");
05729         for i in xrange(15):
05730             self.assertAlmostEqual(expected1[i],f6.getIJ(0,i),12);
05731             pass
05732         #
05733         pass

Definition at line 6005 of file MEDCouplingBasicsTest.py.

06005 
06006     def testFieldOperatorDivDiffComp1(self):
06007         m=MEDCouplingDataForTest.build2DTargetMesh_1();
06008         m1,d0,d1,d2,d3=m.buildDescendingConnectivity();
06009         #
06010         f1=m1.buildOrthogonalField();
06011         arr1=[2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.]
06012         arr=DataArrayDouble.New();
06013         arr.setValues(arr1,13,1);
06014         f2=MEDCouplingFieldDouble.New(ON_CELLS);
06015         f2.setArray(arr);
06016         f2.setMesh(m1);
06017         f2.checkCoherency();
06018         #
06019         f3=f1/f2;
06020         self.assertRaises(InterpKernelException,f2.__div__,f1)
06021         f3.checkCoherency();
06022         f1/=f2;
06023         #self.assertRaises(InterpKernelException,f2.__idiv__,f1) # mem leaks
06024         self.assertTrue(f1.isEqual(f3,1e-10,1e-10));
06025         expected1=[-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0]
06026         for i in xrange(26):
06027             self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),10);
06028             pass
06029         pass

Definition at line 7034 of file MEDCouplingBasicsTest.py.

07034 
07035     def testFieldOverTime1(self):
07036         fs=MEDCouplingDataForTest.buildMultiFields_2();
07037         self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs);
07038         f4bis=fs[4].buildNewTimeReprFromThis(ONE_TIME,False);
07039         fs[4]=f4bis;
07040         self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs);
07041         f4bis.setTime(2.7,20,21);
07042         fot=MEDCouplingFieldOverTime.New(fs);
07043         dt=fot.getDefinitionTimeZone();
07044         hs=dt.getHotSpotsTime();
07045         self.assertEqual(6,len(hs));
07046         expected1=[0.2,0.7,1.2,1.35,1.7,2.7]
07047         for i in xrange(6):
07048             self.assertAlmostEqual(expected1[i],hs[i],12);
07049             pass
07050         meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.2);
07051         self.assertEqual(0,meshId);
07052         self.assertEqual(0,arrId);
07053         self.assertEqual(0,arrIdInField);
07054         self.assertEqual(0,fieldId);
07055         #
07056         meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.7);
07057         self.assertEqual(0,meshId);
07058         self.assertEqual(1,arrId);
07059         self.assertEqual(0,arrIdInField);
07060         self.assertEqual(1,fieldId);
07061         #
07062         meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeLeft(1.2);#**** WARNING left here
07063         self.assertEqual(0,meshId);
07064         self.assertEqual(2,arrId);
07065         self.assertEqual(1,arrIdInField);
07066         self.assertEqual(1,fieldId);
07067         #
07068         meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.2);#**** WARNING right again here
07069         self.assertEqual(1,meshId);
07070         self.assertEqual(3,arrId);
07071         self.assertEqual(0,arrIdInField);
07072         self.assertEqual(2,fieldId);
07073         #
07074         meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.35);
07075         self.assertEqual(1,meshId);
07076         self.assertEqual(3,arrId);
07077         self.assertEqual(0,arrIdInField);
07078         self.assertEqual(2,fieldId);
07079         #
07080         meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.7);
07081         self.assertEqual(0,meshId);
07082         self.assertEqual(3,arrId);
07083         self.assertEqual(0,arrIdInField);
07084         self.assertEqual(3,fieldId);
07085         #
07086         meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(2.7);
07087         self.assertEqual(1,meshId);
07088         self.assertEqual(4,arrId);
07089         self.assertEqual(0,arrIdInField);
07090         self.assertEqual(4,fieldId);
07091         #
07092         dt2=MEDCouplingDefinitionTime();
07093         self.assertTrue(not dt2.isEqual(dt));
07094         dt2.assign(dt);
07095         dt2.assign(dt);#to check memory management
07096         self.assertTrue(dt2.isEqual(dt));
07097         #
07098         dt3=MEDCouplingDefinitionTime();
07099         #
07100         pass

Definition at line 966 of file MEDCouplingBasicsTest.py.

00966 
00967     def testFillFromAnalytic(self):
00968         m=MEDCouplingDataForTest.build2DTargetMesh_1();             
00969         f1=m.fillFromAnalytic(ON_CELLS,1,"x+y");
00970         f1.checkCoherency();                    
00971         self.assertEqual(f1.getTypeOfField(),ON_CELLS);
00972         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
00973         self.assertEqual(1,f1.getNumberOfComponents());
00974         self.assertEqual(5,f1.getNumberOfTuples());
00975         values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9]
00976         tmp=f1.getArray().getValues();
00977         self.assertEqual(len(values1),len(tmp))
00978         for i in xrange(len(tmp)):
00979             self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
00980             pass
00981         #
00982         f1=m.fillFromAnalytic(ON_NODES,1,"x+y");
00983         f1.checkCoherency();
00984         self.assertEqual(f1.getTypeOfField(),ON_NODES);
00985         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
00986         self.assertEqual(1,f1.getNumberOfComponents());
00987         self.assertEqual(9,f1.getNumberOfTuples());
00988         values2=[-0.6,-0.1,0.4,-0.1,0.4,0.9,0.4,0.9,1.4]
00989         tmp=f1.getArray().getValues();
00990         self.assertEqual(len(values2),len(tmp))
00991         for i in xrange(len(tmp)):
00992             self.assertTrue(abs(tmp[i]-values2[i])<1.e-12)
00993             pass
00994         #
00995         f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+(2*(x+y))*JVec");
00996         f1.checkCoherency();
00997         self.assertEqual(f1.getTypeOfField(),ON_NODES);
00998         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
00999         self.assertEqual(2,f1.getNumberOfComponents());
01000         self.assertEqual(9,f1.getNumberOfTuples());
01001         values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8]
01002         tmp=f1.getArray().getValues();
01003         self.assertEqual(len(values3),len(tmp))
01004         for i in xrange(len(tmp)):
01005             self.assertTrue(abs(tmp[i]-values3[i])<1.e-12)
01006             pass
01007         values4=f1.accumulate();
01008         self.assertEqual(2,len(values4))
01009         self.assertTrue(abs(3.6-values4[0])<1.e-12);
01010         self.assertTrue(abs(7.2-values4[1])<1.e-12);
01011         values4=f1.integral(True);
01012         self.assertEqual(2,len(values4))
01013         self.assertTrue(abs(0.5-values4[0])<1.e-12);
01014         self.assertTrue(abs(1.-values4[1])<1.e-12);
01015         #
01016         self.assertRaises(InterpKernelException,m.fillFromAnalytic,ON_NODES,1,"1./(x-0.2)");
01017         pass

Definition at line 1018 of file MEDCouplingBasicsTest.py.

01018 
01019     def testFillFromAnalytic2(self):
01020         m=MEDCouplingDataForTest.build2DTargetMesh_1();
01021         f1=m.fillFromAnalytic(ON_CELLS,1,"y+x");
01022         f1.checkCoherency();
01023         self.assertEqual(f1.getTypeOfField(),ON_CELLS);
01024         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01025         self.assertEqual(1,f1.getNumberOfComponents());
01026         self.assertEqual(5,f1.getNumberOfTuples());
01027         values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9]
01028         tmp=f1.getArray().getValues();
01029         self.assertEqual(len(values1),len(tmp))
01030         for i in xrange(len(values1)):
01031             self.assertTrue(abs(values1[i]-tmp[i])<1.e-12);
01032             pass
01033         #
01034         f1=m.fillFromAnalytic(ON_NODES,1,"y+2*x");
01035         f1.checkCoherency();
01036         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01037         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01038         self.assertEqual(1,f1.getNumberOfComponents());
01039         self.assertEqual(9,f1.getNumberOfTuples());
01040         values2=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
01041         tmp=f1.getArray().getValues();
01042         self.assertEqual(len(values2),len(tmp))
01043         for i in xrange(len(values2)):
01044             self.assertTrue(abs(values2[i]-tmp[i])<1.e-12);
01045             pass
01046         f1=m.fillFromAnalytic(ON_NODES,1,"2.*x+y");
01047         f1.checkCoherency();
01048         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01049         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01050         self.assertEqual(1,f1.getNumberOfComponents());
01051         self.assertEqual(9,f1.getNumberOfTuples());
01052         tmp=f1.getArray().getValues();
01053         values2Bis=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
01054         self.assertEqual(len(values2Bis),len(tmp))
01055         for i in xrange(len(values2Bis)):
01056             self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12);
01057             pass
01058         #
01059         f1=m.fillFromAnalytic(ON_NODES,2,"(x+y)*IVec+2*(x+y)*JVec");
01060         f1.checkCoherency();
01061         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01062         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01063         self.assertEqual(2,f1.getNumberOfComponents());
01064         self.assertEqual(9,f1.getNumberOfTuples());
01065         values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8]
01066         tmp=f1.getArray().getValues();
01067         self.assertEqual(len(values3),len(tmp))
01068         for i in xrange(len(values3)):
01069             self.assertTrue(abs(values3[i]-tmp[i])<1.e-12);
01070             pass
01071         values4=f1.accumulate();
01072         self.assertTrue(abs(3.6-values4[0])<1.e-12);
01073         self.assertTrue(abs(7.2-values4[1])<1.e-12);
01074         values4=f1.integral(True);
01075         self.assertTrue(abs(0.5-values4[0])<1.e-12);
01076         self.assertTrue(abs(1.-values4[1])<1.e-12);
01077         pass

Definition at line 3661 of file MEDCouplingBasicsTest.py.

03661 
03662     def testFillFromAnalytic3(self):
03663         m=MEDCouplingDataForTest.build2DTargetMesh_1()
03664         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
03665         self.assertRaises(InterpKernelException,f1.fillFromAnalytic,1,"y+x");
03666         f1.setMesh(m)
03667         f1.setName("myField");
03668         f1.fillFromAnalytic(1,"y+x");
03669         f1.checkCoherency();
03670         self.assertEqual(f1.getName(),"myField");
03671         self.assertEqual(f1.getTypeOfField(),ON_CELLS);
03672         self.assertEqual(f1.getTimeDiscretization(),ONE_TIME);
03673         self.assertEqual(1,f1.getNumberOfComponents());
03674         self.assertEqual(5,f1.getNumberOfTuples());
03675         values1=[-0.1,0.23333333333333336,0.56666666666666665,0.4,0.9]
03676         tmp=f1.getArray().getValues();
03677         self.assertEqual(len(values1),len(tmp))
03678         for i in xrange(len(values1)):
03679             self.assertTrue(abs(values1[i]-tmp[i])<1.e-12);
03680             pass
03681         #
03682         f1=MEDCouplingFieldDouble.New(ON_NODES,CONST_ON_TIME_INTERVAL)
03683         f1.setMesh(m)
03684         f1.fillFromAnalytic(1,"y+2*x");
03685         f1.setEndTime(1.2,3,4);
03686         f1.checkCoherency();
03687         self.assertEqual(f1.getTypeOfField(),ON_NODES);
03688         self.assertEqual(f1.getTimeDiscretization(),CONST_ON_TIME_INTERVAL);
03689         self.assertEqual(1,f1.getNumberOfComponents());
03690         self.assertEqual(9,f1.getNumberOfTuples());
03691         values2=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
03692         tmp=f1.getArray().getValues();
03693         self.assertEqual(len(values2),len(tmp))
03694         for i in xrange(len(values2)):
03695             self.assertTrue(abs(values2[i]-tmp[i])<1.e-12);
03696             pass
03697         f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME);
03698         f1.setMesh(m)
03699         f1.fillFromAnalytic(1,"2.*x+y");
03700         f1.setEndTime(1.2,3,4);
03701         f1.checkCoherency();
03702         self.assertEqual(f1.getTypeOfField(),ON_NODES);
03703         self.assertEqual(f1.getTimeDiscretization(),LINEAR_TIME);
03704         self.assertEqual(1,f1.getNumberOfComponents());
03705         self.assertEqual(9,f1.getNumberOfTuples());
03706         tmp=f1.getArray().getValues();
03707         values2Bis=[-0.9,0.1,1.1,-0.4,0.6,1.6,0.1,1.1,2.1]
03708         self.assertEqual(len(values2Bis),len(tmp))
03709         for i in xrange(len(values2Bis)):
03710             self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12);
03711             pass
03712         tmp=f1.getEndArray().getValues();
03713         self.assertEqual(len(values2Bis),len(tmp))
03714         for i in xrange(len(values2Bis)):
03715             self.assertTrue(abs(values2Bis[i]-tmp[i])<1.e-12);
03716             pass
03717         #
03718         f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
03719         f1.setMesh(m)
03720         f1.fillFromAnalytic(2,"(x+y)*IVec+2*(x+y)*JVec");
03721         f1.checkCoherency();
03722         self.assertEqual(f1.getTypeOfField(),ON_NODES);
03723         self.assertEqual(f1.getTimeDiscretization(),ONE_TIME);
03724         self.assertEqual(2,f1.getNumberOfComponents());
03725         self.assertEqual(9,f1.getNumberOfTuples());
03726         values3=[-0.6,-1.2,-0.1,-0.2,0.4,0.8,-0.1,-0.2,0.4,0.8,0.9,1.8,0.4,0.8,0.9,1.8,1.4,2.8]
03727         tmp=f1.getArray().getValues();
03728         self.assertEqual(len(values3),len(tmp))
03729         for i in xrange(len(values3)):
03730             self.assertTrue(abs(values3[i]-tmp[i])<1.e-12);
03731             pass
03732         values4=f1.accumulate();
03733         self.assertTrue(abs(3.6-values4[0])<1.e-12);
03734         self.assertTrue(abs(7.2-values4[1])<1.e-12);
03735         values4=f1.integral(True);
03736         self.assertTrue(abs(0.5-values4[0])<1.e-12);
03737         self.assertTrue(abs(1.-values4[1])<1.e-12);
03738         #
03739         f1=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
03740         f1.setMesh(m);
03741         self.assertRaises(InterpKernelException,f1.fillFromAnalytic,1,"1./(x-0.2)");
03742         pass

Definition at line 7314 of file MEDCouplingBasicsTest.py.

07314 
07315     def testFillFromAnalyticThree1(self):
07316         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
07317         vs=3*[None];
07318         vs[0]="x"; vs[1]="Y"; vs[2]="z";
07319         self.assertRaises(InterpKernelException,m1.fillFromAnalytic3,ON_NODES,1,vs,"y+z");
07320         vs[1]="y";
07321         f1=m1.fillFromAnalytic3(ON_NODES,1,vs,"y+z");
07322         self.assertEqual(1,f1.getNumberOfComponents());
07323         self.assertEqual(9,f1.getNumberOfTuples());
07324         expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2]
07325         for i in xrange(9):
07326             self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
07327             pass
07328         pass

Definition at line 7299 of file MEDCouplingBasicsTest.py.

07299 
07300     def testFillFromAnalyticTwo1(self):
07301         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
07302         self.assertRaises(InterpKernelException,m1.fillFromAnalytic2,ON_NODES,1,"y+z");
07303         m1.getCoords().setInfoOnComponent(0,"x [m]");
07304         m1.getCoords().setInfoOnComponent(1,"y");
07305         m1.getCoords().setInfoOnComponent(2,"z");
07306         f1=m1.fillFromAnalytic2(ON_NODES,1,"y+z");
07307         self.assertEqual(1,f1.getNumberOfComponents());
07308         self.assertEqual(9,f1.getNumberOfTuples());
07309         expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2]
07310         for i in xrange(9):
07311             self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
07312             pass
07313         pass

Definition at line 8274 of file MEDCouplingBasicsTest.py.

08274 
08275     def testFindAndCorrectBadOriented3DExtrudedCells1(self):
08276         coords=[0.0011180339887498999, -0.0011755705045849499, 0.0, -0.0012331070204200001, -0.0011755705045849499, 0.0, -0.00067557050458494599, -0.00145964954842536, 0.0, -0.00050000000000000001, -0.00086602540378443902, 0.0, 0.00140211303259031, -0.00061803398874989504, 0.0, 0.00086602540378443902, -0.00050000000000000001, 0.0, 0.001, 0.0, 0.0, 0.00034561537182258202, 0.000269164072574575, 0.0, 0.0, 0.001, 0.0, -0.00050000000000000001, 0.00086602540378443902, 0.0, -0.000269164072574575, 0.00034561537182258202, 0.0, -0.001, 0.0, 0.0, -0.00086602540378443902, -0.00050000000000000001, 0.0, -0.00034561537182258202, -0.000269164072574575, 0.0, 0.0, -0.001, 0.0, 0.00050000000000000001, -0.00086602540378443902, 0.0, 0.000269164072574575, -0.00034561537182258202, 0.0, 0.0015, -6.01853107621011e-36, 0.0, 0.00056049747291484397, -0.00145964954842536, 0.0, 0.0011180339887498999, -0.0011755705045849499, 0.00050000000000000001, -0.0012331070204200001, -0.0011755705045849499, 0.00050000000000000001, -0.00067557050458494599, -0.00145964954842536, 0.00050000000000000001, -0.00050000000000000001, -0.00086602540378443902, 0.00050000000000000001, 0.00140211303259031, -0.00061803398874989504, 0.00050000000000000001, 0.00086602540378443902, -0.00050000000000000001, 0.00050000000000000001, 0.001, 0.0, 0.00050000000000000001, 0.00034561537182258202, 0.000269164072574575, 0.00050000000000000001, 0.0, 0.001, 0.00050000000000000001, -0.00050000000000000001, 0.00086602540378443902, 0.00050000000000000001, -0.000269164072574575, 0.00034561537182258202, 0.00050000000000000001, -0.001, 0.0, 0.00050000000000000001, -0.00086602540378443902, -0.00050000000000000001, 0.00050000000000000001, -0.00034561537182258202, -0.000269164072574575, 0.00050000000000000001, 0.0, -0.001, 0.00050000000000000001, 0.00050000000000000001, -0.00086602540378443902, 0.00050000000000000001, 0.000269164072574575, -0.00034561537182258202, 0.00050000000000000001, 0.0015, -6.01853107621011e-36, 0.00050000000000000001, 0.00056049747291484397, -0.00145964954842536, 0.00050000000000000001];
08277         conn=[2, 1, 3, 21, 20, 22, 4, 0, 5, 23, 19, 24, 8, 9, 10, 27, 28, 29, 11, 12, 13, 30, 31, 32, 0, 18, 15, 5, 19, 37, 34, 24, 6, 17, 4, 5, 25, 36, 23, 24, 3, 14, 16, 13, 22, 33, 35, 32, 13, 16, 7, 10, 32, 35, 26, 29]
08278         connExp=[16, 2, 1, 3, 21, 20, 22, 16, 4, 0, 5, 23, 19, 24, 16, 8, 10, 9, 27, 29, 28, 16, 11, 13, 12, 30, 32, 31, 18, 0, 18, 15, 5, 19, 37, 34, 24,18, 6, 17, 4, 5, 25, 36, 23, 24, 18, 3, 13, 16, 14, 22, 32, 35, 33, 18, 13, 10, 7, 16, 32, 29, 26, 35]
08279         invalidCells=[2,3,6,7]
08280         m=MEDCouplingUMesh.New("Example",3);
08281         coo=DataArrayDouble.New();
08282         coo.setValues(coords,38,3);
08283         m.setCoords(coo);
08284         m.allocateCells(8);
08285         m.insertNextCell(NORM_PENTA6,6,conn[0:6])
08286         m.insertNextCell(NORM_PENTA6,6,conn[6:12])
08287         m.insertNextCell(NORM_PENTA6,6,conn[12:18])
08288         m.insertNextCell(NORM_PENTA6,6,conn[18:24])
08289         m.insertNextCell(NORM_HEXA8,8,conn[24:32])
08290         m.insertNextCell(NORM_HEXA8,8,conn[32:40])
08291         m.insertNextCell(NORM_HEXA8,8,conn[40:48])
08292         m.insertNextCell(NORM_HEXA8,8,conn[48:56])
08293         m.finishInsertingCells();
08294         #
08295         v=m.findAndCorrectBadOriented3DExtrudedCells();
08296         self.assertEqual(4,len(v));
08297         self.assertEqual(v.getValues(),invalidCells);
08298         self.assertEqual(connExp,m.getNodalConnectivity().getValues());
08299         #
08300         pass

Definition at line 345 of file MEDCouplingBasicsTest.py.

00345 
00346     def testFindBoundaryNodes(self):
00347         mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
00348         boundaryNodes=mesh.findBoundaryNodes();
00349         expected1=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26];
00350         self.assertEqual(expected1,boundaryNodes.getValues());
00351         pass

Definition at line 795 of file MEDCouplingBasicsTest.py.

00795 
00796     def testFindCommonNodes(self):
00797         targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1();
00798         comm,commI=targetMesh.findCommonNodes(1e-10,-1);
00799         self.assertEqual(1,commI.getNumberOfTuples());
00800         self.assertEqual(0,comm.getNumberOfTuples());
00801         o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI);
00802         self.assertEqual(27,newNbOfNodes);
00803         self.assertEqual(27,o2n.getNumberOfTuples());
00804         o2nExp1=range(27)
00805         self.assertEqual(o2nExp1,list(o2n.getValues()));
00806         #
00807         targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1();
00808         self.assertEqual(31,targetMesh.getNumberOfNodes());
00809         comm,commI=targetMesh.findCommonNodes(1e-10);# testing default parameter
00810         self.assertEqual(3,commI.getNumberOfTuples());
00811         self.assertEqual(6,comm.getNumberOfTuples());
00812         commExpected=[1,27,28,29,23,30]
00813         commIExpected=[0,4,6]
00814         self.assertEqual(commExpected,list(comm.getValues()));
00815         self.assertEqual(commIExpected,list(commI.getValues()));
00816         o2n,newNbOfNodes=targetMesh.buildNewNumberingFromCommonNodesFormat(comm,commI);
00817         self.assertEqual(31,o2n.getNumberOfTuples());
00818         self.assertEqual(27,newNbOfNodes);
00819         o2nExp2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
00820                  21,22,23,24,25,26,1,1,1,23]
00821         self.assertEqual(o2nExp2,list(o2n.getValues()));
00822         #
00823         targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1();
00824         time=targetMesh.getTimeOfThis();
00825         o2n,areNodesMerged,newNbOfNodes=targetMesh.mergeNodes(1e-10);
00826         targetMesh.updateTime();
00827         self.assertEqual(time,targetMesh.getTimeOfThis());
00828         self.assertTrue(not areNodesMerged);
00829         #
00830         targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1();
00831         time=targetMesh.getTimeOfThis();
00832         o2n,areNodesMerged,newNbOfNodes=targetMesh.mergeNodes(1e-10);
00833         targetMesh.updateTime();
00834         self.assertTrue(time!=targetMesh.getTimeOfThis());
00835         self.assertTrue(areNodesMerged);
00836         connExp=[18,0,1,4,3,9,10,13,12, 18,1,2,5,4,10,11,14,13, 18,3,4,7,6,12,13,16,15,
00837                  18,4,5,8,7,13,14,17,16,
00838                  18,9,10,13,12,18,19,22,21, 18,10,11,14,13,19,20,23,22, 18,12,13,16,15,21,22,25,24,
00839                  18,13,14,17,16,22,23,26,25]
00840         self.assertEqual(72,targetMesh.getNodalConnectivity().getNumberOfTuples());
00841         self.assertEqual(connExp,list(targetMesh.getNodalConnectivity().getValues()));
00842         self.assertEqual(27,targetMesh.getCoords().getNumberOfTuples());
00843         coordsExp=[ 0., 0., 0., 50., 0., 0. , 200., 0., 0.  , 0., 50., 0., 50., 50., 0. ,
00844                     200., 50., 0.,   0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
00845                     0., 0., 50., 50., 0., 50. , 200., 0., 50.  , 0., 50., 50., 50.,
00846                     50., 50. , 200., 50., 50.,   0., 200., 50., 50., 200., 50. ,
00847                     200., 200., 50. , 0., 0., 200., 50., 0., 200. , 200., 0., 200.  
00848                     , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 
00849                     0., 200., 200., 50., 200., 200. , 200., 200., 200. ]
00850         self.assertEqual(coordsExp,targetMesh.getCoords().getValues());
00851         # 2D
00852         targetMesh=MEDCouplingDataForTest.build2DTargetMeshMergeNode_1();
00853         self.assertEqual(18,targetMesh.getNumberOfNodes());
00854         time=targetMesh.getTimeOfThis();
00855         o2n,areNodesMerged,newNbOfNodes=targetMesh.mergeNodes(1e-10);
00856         self.assertTrue(time!=targetMesh.getTimeOfThis());
00857         self.assertTrue(areNodesMerged);
00858         self.assertEqual(9,targetMesh.getNumberOfNodes());
00859         connExp2=[4,0,4,3,1, 3,1,3,2, 3,3,5,2, 4,4,6,7,3, 4,7,8,5,3]
00860         self.assertEqual(23,targetMesh.getNodalConnectivity().getNumberOfTuples());
00861         self.assertEqual(connExp2,list(targetMesh.getNodalConnectivity().getValues()));
00862         coordsExp2=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, 0.2,0.2, -0.3,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7]
00863         self.assertEqual(9,targetMesh.getCoords().getNumberOfTuples());
00864         self.assertEqual(coordsExp2,targetMesh.getCoords().getValues());
00865         pass

Definition at line 1912 of file MEDCouplingBasicsTest.py.

01912 
01913     def testFindNodeOnPlane(self):
01914         mesh=MEDCouplingDataForTest.build3DTargetMesh_1();
01915         pt=[300.,300.,0.]
01916         v=[0.,0.,2.]
01917         n=mesh.findNodesOnPlane(pt,v,1e-12);
01918         self.assertEqual(9,len(n));
01919         m3dSurf=mesh.buildFacePartOfMySelfNode(n,True);
01920         self.assertTrue(isinstance(m3dSurf,MEDCouplingUMesh))
01921         me=MEDCouplingExtrudedMesh.New(mesh,m3dSurf,0);
01922         da=me.getMesh3DIds();
01923         self.assertEqual(8,me.getNumberOfCells());
01924         expected=[0,1,2,3,4,5,6,7]
01925         val=da.getValues();
01926         self.assertEqual(expected,list(val));
01927         #
01928         m3dSurf=mesh.buildFacePartOfMySelfNode(n,True);
01929         self.assertTrue(isinstance(m3dSurf,MEDCouplingUMesh))
01930         me=MEDCouplingExtrudedMesh.New(mesh,m3dSurf,0);
01931         da=me.getMesh3DIds();
01932         self.assertEqual(8,me.getNumberOfCells());
01933         expected=[0,1,2,3,4,5,6,7]
01934         val=da.getValues();
01935         self.assertEqual(expected,list(val));
01936         pass

Definition at line 8634 of file MEDCouplingBasicsTest.py.

08634 
08635     def testFindNodesOnLine1(self):
08636         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
08637         pt=[-0.3,-0.3]
08638         pt2=[0.,0.,0.]
08639         pt3=[-0.3,0.,0.]
08640         vec=[0.,1.]
08641         vec2=[1.,0.,0.]
08642         vec3=[0.,1.,1.]
08643         expected1=[0,3,6]
08644         res=mesh.findNodesOnLine(pt,vec,1e-12);
08645         self.assertEqual(3,len(res));
08646         self.assertEqual(expected1,res.getValues());
08647         #
08648         mesh.changeSpaceDimension(3);
08649         mesh.rotate(pt2,vec2,pi/4.);
08650         res=mesh.findNodesOnLine(pt3,vec3,1e-12);
08651         self.assertEqual(3,len(res));
08652         self.assertEqual(expected1,res.getValues());
08653         pass

Definition at line 1448 of file MEDCouplingBasicsTest.py.

01448 
01449     def testFuseUMeshesOnSameCoords(self):
01450         m2=MEDCouplingDataForTest.build2DTargetMesh_1();
01451         cells1=[2,3,4]
01452         m3=m2.buildPartOfMySelf(cells1,True);
01453         self.assertTrue(isinstance(m3,MEDCouplingUMesh))
01454         cells2=[1,2,4]
01455         m4=m2.buildPartOfMySelf(cells2,True);
01456         self.assertTrue(isinstance(m4,MEDCouplingUMesh))
01457         cells3=[1,2]
01458         m5=m2.buildPartOfMySelf(cells3,True);
01459         self.assertTrue(isinstance(m5,MEDCouplingUMesh))
01460         meshes=[m3,m4,m5]
01461         #
01462         m7,corr=MEDCouplingUMesh.FuseUMeshesOnSameCoords(meshes,0);
01463         self.assertEqual(4,m7.getNumberOfCells());
01464         self.assertEqual(3,len(corr));
01465         expectedVals1=[3,3,2]
01466         expectedVals2=[[0,1,2],[3,0,2],[3,0]]
01467         for i in xrange(3):
01468             arr=corr[i];
01469             self.assertEqual(1,arr.getNumberOfComponents());
01470             nbOfVals=expectedVals1[i];
01471             self.assertEqual(nbOfVals,arr.getNumberOfTuples());
01472             vals=arr.getValues();
01473             self.assertEqual(expectedVals2[i],list(vals));
01474             pass
01475         arr2,fidsOfGroups=DataArrayInt.MakePartition(corr,m7.getNumberOfCells());
01476         fidExp=[5,1,3,4]
01477         fidsGrp=[[1,3,5],[3,4,5],[4,5]]
01478         self.assertEqual(3,len(fidsOfGroups));
01479         self.assertEqual(1,arr2.getNumberOfComponents());
01480         self.assertEqual(4,arr2.getNumberOfTuples());
01481         self.assertEqual(fidExp,list(arr2.getValues()));
01482         for i in xrange(3):
01483             nbOfVals=expectedVals1[i];
01484             self.assertEqual(list(fidsOfGroups[i]),fidsGrp[i]);
01485             pass
01486         pass

Definition at line 1487 of file MEDCouplingBasicsTest.py.

01487 
01488     def testFuseUMeshesOnSameCoords2(self):
01489         m1,m2=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
01490         part1=[2,3,6,4,10]
01491         m3=m1.buildPartOfMySelf(part1,True);
01492         part2=[5,6,4,7]
01493         m4=m1.buildPartOfMySelf(part2,True);
01494         meshes=[m1,m3,m3,m4]
01495         m5,corr=MEDCouplingUMesh.FuseUMeshesOnSameCoords(meshes,0);
01496         self.assertEqual(18,m5.getNumberOfCells());
01497         exp2=[
01498             [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],
01499             [2,3,6,4,10],
01500             [2,3,6,4,10],
01501             [5,6,4,7]]
01502         i=0;
01503         for it in corr:
01504             self.assertEqual(exp2[i],list(it.getValues()));
01505             i+=1
01506             pass
01507         pass

Definition at line 7390 of file MEDCouplingBasicsTest.py.

07390 
07391     def testGaussCoordinates1(self):
07392         #Testing 1D cell types
07393         m1=MEDCouplingDataForTest.build1DMultiTypes_1();
07394         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
07395         f.setMesh(m1);
07396         wg1=[0.3];
07397         gsCoo1=[0.2];
07398         refCoo1=[-1.0,1.0];
07399         f.setGaussLocalizationOnType(NORM_SEG2,refCoo1,gsCoo1,wg1);
07400         wg2=wg1;
07401         gsCoo2=[0.2];
07402         refCoo2=[-1.0,1.0,0.0];
07403         f.setGaussLocalizationOnType(NORM_SEG3,refCoo2,gsCoo2,wg2);
07404         #
07405         resToTest=f.getLocalizationOfDiscr();
07406         self.assertEqual(3,resToTest.getNumberOfComponents());
07407         self.assertEqual(2,resToTest.getNumberOfTuples());
07408         expected1=[0.6,0.6,0.6, 0.6,0.6,0.6]
07409         for i in xrange(6):
07410             self.assertAlmostEqual(expected1[i],resToTest.getIJ(0,i),14);
07411             pass
07412         #
07413         #Testing 2D cell types
07414         m2=MEDCouplingDataForTest.build2DMultiTypes_1();
07415         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
07416         f.setMesh(m2);
07417         wg3=[0.3,0.3];
07418         tria3CooGauss=[ 0.1, 0.8, 0.2, 0.7 ]
07419         gsCoo3=tria3CooGauss
07420         tria3CooRef=[ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 ]
07421         refCoo3=tria3CooRef;
07422         f.setGaussLocalizationOnType(NORM_TRI3,refCoo3,gsCoo3,wg3);
07423         wg4=[0.3,0.3,0.3];
07424         tria6CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 ]
07425         gsCoo4=tria6CooGauss;
07426         tria6CooRef=[0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5]
07427         refCoo4=tria6CooRef;
07428         f.setGaussLocalizationOnType(NORM_TRI6,refCoo4,gsCoo4,wg4);
07429         wg5=[0.3,0.3,0.3,0.3];
07430         quad4CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 ]
07431         gsCoo5=quad4CooGauss;
07432         quad4CooRef=[-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0]
07433         refCoo5=quad4CooRef;
07434         f.setGaussLocalizationOnType(NORM_QUAD4,refCoo5,gsCoo5,wg5);
07435         wg6=[0.3,0.3,0.3,0.3];
07436         quad8CooGauss=[ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 ]
07437         gsCoo6=quad8CooGauss;
07438         quad8CooRef=[ -1.0, -1.0, 1.0, -1.0, 1.0,  1.0, -1.0,  1.0, 0.0, -1.0, 1.0,  0.0, 0.0,  1.0, -1.0,  0.0]
07439         refCoo6=quad8CooRef;
07440         f.setGaussLocalizationOnType(NORM_QUAD8,refCoo6,gsCoo6,wg6);
07441         #
07442         resToTest=f.getLocalizationOfDiscr();
07443         self.assertEqual(3,resToTest.getNumberOfComponents());
07444         self.assertEqual(13,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
07445         expected2=[5.1,1.55,0.0, 4.7,1.65,0.0,
07446                    2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,#TRI6
07447                    2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,#QUAD4
07448                    2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 ];#QUAD8
07449         for i in xrange(39):
07450             self.assertAlmostEqual(expected2[i],resToTest.getIJ(0,i),14);
07451             pass
07452         #
07453         #Testing 3D cell types
07454         m3=MEDCouplingDataForTest.build3DMultiTypes_1();
07455         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
07456         f.setMesh(m3);
07457         #
07458         wg7=[0.3];
07459         tetra4CooGauss=[0.34, 0.16, 0.21]
07460         gsCoo7=tetra4CooGauss;
07461         tetra4CooRef=[0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0]
07462         refCoo7=tetra4CooRef;
07463         f.setGaussLocalizationOnType(NORM_TETRA4,refCoo7,gsCoo7,wg7);
07464         wg8=[0.3];
07465         tetra10CooGauss=[0.2, 0.3, 0.1]
07466         gsCoo8=tetra10CooGauss;
07467         tetra10CooRef=[0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5]
07468         refCoo8=tetra10CooRef;
07469         f.setGaussLocalizationOnType(NORM_TETRA10,refCoo8,gsCoo8,wg8);
07470         wg9=[0.3];
07471         pyra5CooGauss=[0.2, 0.3, 0.1]
07472         gsCoo9=pyra5CooGauss;
07473         pyra5CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0]
07474         refCoo9=pyra5CooRef;
07475         f.setGaussLocalizationOnType(NORM_PYRA5,refCoo9,gsCoo9,wg9);
07476         wg10=[0.3];
07477         pyra13CooGauss=[0.1, 0.2, 0.7]
07478         gsCoo10=pyra13CooGauss;
07479         pyra13CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5]
07480         refCoo10=pyra13CooRef;
07481         f.setGaussLocalizationOnType(NORM_PYRA13,refCoo10,gsCoo10,wg10);
07482         wg11=[0.3];
07483         penta6CooGauss=[0.2, 0.3, 0.1]
07484         gsCoo11=penta6CooGauss;
07485         penta6CooRef=[-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0]
07486         refCoo11=penta6CooRef;
07487         f.setGaussLocalizationOnType(NORM_PENTA6,refCoo11,gsCoo11,wg11);
07488         wg12=[0.3];
07489         penta15CooGauss=[0.2, 0.3,0.15]
07490         gsCoo12=penta15CooGauss;
07491         penta15CooRef=[-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0]
07492         refCoo12=penta15CooRef;
07493         f.setGaussLocalizationOnType(NORM_PENTA15,refCoo12,gsCoo12,wg12);
07494         wg13=[0.3];
07495         hexa8CooGauss=[0.2,0.3,0.15]
07496         gsCoo13=hexa8CooGauss;
07497         hexa8CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0]
07498         refCoo13=hexa8CooRef;
07499         f.setGaussLocalizationOnType(NORM_HEXA8,refCoo13,gsCoo13,wg13);
07500         wg14=[0.3];
07501         hexa20CooGauss=[0.11,0.3,0.55]
07502         gsCoo14=hexa20CooGauss;
07503         hexa20CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0]
07504         refCoo14=hexa20CooRef;
07505         f.setGaussLocalizationOnType(NORM_HEXA20,refCoo14,gsCoo14,wg14);
07506         #
07507         resToTest=f.getLocalizationOfDiscr();
07508         self.assertEqual(3,resToTest.getNumberOfComponents());
07509         self.assertEqual(8,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
07510         expected3=[1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255]
07511         for i in xrange(24):
07512             self.assertAlmostEqual(expected3[i],resToTest.getIJ(0,i),14);
07513             pass
07514         #
07515         pass

Definition at line 1972 of file MEDCouplingBasicsTest.py.

01972 
01973     def testGaussPointField1(self):
01974         _a=0.446948490915965;
01975         _b=0.091576213509771;
01976         _p1=0.11169079483905;
01977         _p2=0.0549758718227661;
01978         refCoo1=[ 0.,0., 1.,0., 0.,1. ]
01979         gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
01980                  2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ]
01981         wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
01982         _refCoo1=refCoo1
01983         _gsCoo1=gsCoo1
01984         _wg1=wg1
01985         #
01986         m=MEDCouplingDataForTest.build2DTargetMesh_1();
01987         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,NO_TIME);
01988         f.setMesh(m);
01989         self.assertEqual(5,f.getNumberOfMeshPlacesExpected());
01990         self.assertEqual(0,f.getNbOfGaussLocalization());
01991         f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
01992         self.assertRaises(InterpKernelException,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1)
01993         self.assertEqual(1,f.getNbOfGaussLocalization());
01994         refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
01995         _refCoo2=refCoo2
01996         _gsCoo1=_gsCoo1[0:4]
01997         _wg1=_wg1[0:2]
01998         f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
01999         self.assertEqual(2,f.getNbOfGaussLocalization());
02000         array=DataArrayDouble.New();
02001         ptr=18*2*[None]
02002         for i in xrange(18*2):
02003             ptr[i]=float(i+1)
02004         array.setValues(ptr,18,2);
02005         ptr=array.getPointer();
02006         f.setArray(array);
02007         f.setName("MyFirstFieldOnGaussPoint");
02008         f.checkCoherency();
02009         self.assertAlmostEqual(27.,f.getIJK(2,5,0),14);
02010         self.assertAlmostEqual(16.,f.getIJK(1,5,1),14);
02011         #
02012         f.clearGaussLocalizations();
02013         self.assertEqual(0,f.getNbOfGaussLocalization());
02014         self.assertRaises(InterpKernelException,f.checkCoherency);
02015         ids1=[0,1,3,4]
02016         self.assertRaises(InterpKernelException,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1);
02017         self.assertEqual(0,f.getNbOfGaussLocalization());
02018         ids2=[0,4]
02019         f.setGaussLocalizationOnCells(ids2,_refCoo2,_gsCoo1,_wg1);
02020         self.assertEqual(1,f.getNbOfGaussLocalization());
02021         self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0));
02022         self.assertRaises(InterpKernelException,f.getGaussLocalizationIdOfOneCell,1);
02023         ids3=[1,2]
02024         f.setGaussLocalizationOnCells(ids3,_refCoo1,_gsCoo1,_wg1);
02025         self.assertEqual(2,f.getNbOfGaussLocalization());
02026         self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0));
02027         self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(1));
02028         self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(2));
02029         self.assertRaises(InterpKernelException,f.checkCoherency);#<- cell 3 has no localization
02030         ids4=[3]
02031         _gsCoo2=_gsCoo1;
02032         _wg2=_wg1;
02033         _gsCoo2[0]=0.8888777776666;
02034         _wg2[0]=0.1234567892377;
02035         f.setGaussLocalizationOnCells(ids4,_refCoo2,_gsCoo2,_wg2);
02036         self.assertEqual(3,f.getNbOfGaussLocalization());
02037         tmpIds=f.getCellIdsHavingGaussLocalization(0);
02038         self.assertEqual(ids2,list(tmpIds.getValues()));
02039         self.assertRaises(InterpKernelException,f.checkCoherency);#<- it's always not ok because undelying array not with the good size.
02040         array2=f.getArray().substr(0,10);
02041         f.setArray(array2);
02042         f.checkCoherency();#<- here it is OK
02043         f2=f.clone(True);
02044         self.assertTrue(f.isEqual(f2,1e-14,1e-14));
02045         gl1=f2.getGaussLocalization(0);
02046         tmp=gl1.getGaussCoord(1,1);
02047         self.assertAlmostEqual(2.07*_b-1,tmp,14);
02048         gl1.setGaussCoord(1,1,0.07);
02049         self.assertTrue(not f.isEqual(f2,1e-14,1e-14));
02050         gl1.setGaussCoord(1,1,tmp);
02051         self.assertTrue(f.isEqual(f2,1e-14,1e-14));
02052         f2.checkCoherency();
02053         pass

Definition at line 2054 of file MEDCouplingBasicsTest.py.

02054 
02055     def testGaussPointNEField1(self):
02056         m=MEDCouplingDataForTest.build2DTargetMesh_1();
02057         f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,NO_TIME);
02058         f.setMesh(m);
02059         self.assertEqual(5,f.getNumberOfMeshPlacesExpected());
02060         f.setName("MyFirstFieldOnNE");
02061         f.setDescription("MyDescriptionNE");
02062         array=DataArrayDouble.New();
02063         tmp=18*2*[None]
02064         for i in xrange(18*2):
02065             tmp[i]=float(i+7)
02066             pass
02067         array.setValues(tmp,18,2);
02068         ptr=array.getPointer();
02069         f.setArray(array);
02070         #
02071         f.checkCoherency();
02072         f2=f.clone(True);
02073         self.assertTrue(f.isEqual(f2,1e-14,1e-14));
02074         self.assertAlmostEqual(21.,f.getIJK(2,0,0),14);
02075         self.assertAlmostEqual(18.,f.getIJK(1,1,1),14);
02076         pass

Definition at line 8861 of file MEDCouplingBasicsTest.py.

08861 
08862     def testGetCellIdsCrossingPlane1(self):
08863         mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
08864         vec=[-0.07,1.,0.07]
08865         origin=[1.524,1.4552,1.74768]
08866         ids1=mesh3D.getCellIdsCrossingPlane(origin,vec,1e-10)
08867         self.assertEqual([1,3,4,7,9,10,13,15,16],ids1.getValues())
08868         vec2=[0.,0.,1.]
08869         ids2=mesh3D.getCellIdsCrossingPlane(origin,vec2,1e-10)
08870         self.assertEqual([6,7,8,9,10,11],ids2.getValues())
08871         pass

Definition at line 1537 of file MEDCouplingBasicsTest.py.

01537 
01538     def testGetCellsContainingPoint(self):
01539         targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1();
01540         pos=[0.,0.,0.4,0.4,0.,0.4,0.1,0.1,0.25,0.,0.65,0.]
01541         #2D basic
01542         t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12);
01543         self.assertEqual(6,t1.getNumberOfTuples());
01544         self.assertEqual(1,t1.getNumberOfComponents());
01545         self.assertEqual(7,t2.getNumberOfTuples());
01546         self.assertEqual(1,t2.getNumberOfComponents());
01547         expectedValues1=[0,4,3,0,1,2]
01548         expectedValues2=[0,1,2,3,4,5,6]
01549         self.assertEqual(list(t1.getValues()),expectedValues1);
01550         self.assertEqual(list(t2.getValues()),expectedValues2);
01551         #2D with no help of bounding box.
01552         center=[0.2,0.2]
01553         MEDCouplingPointSet.Rotate2DAlg(center,0.78539816339744830962,6,pos);
01554         targetMesh.rotate(center,[],0.78539816339744830962);
01555         t1=None
01556         t2=None
01557         t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12);
01558         self.assertEqual(6,t1.getNumberOfTuples());
01559         self.assertEqual(7,t2.getNumberOfTuples());
01560         self.assertEqual(list(t1.getValues()),expectedValues1);
01561         self.assertEqual(list(t2.getValues()),expectedValues2);
01562         #2D outside
01563         pos1bis=[-0.3303300858899107,-0.11819805153394641]
01564         self.assertEqual(-1,targetMesh.getCellContainingPoint(pos1bis,1e-12));
01565         #test limits 2D
01566         targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1();
01567         pos2=[0.2,-0.05]
01568         t1=None
01569         t1=targetMesh.getCellsContainingPoint(pos2,1e-12)
01570         self.assertEqual(2,len(t1));
01571         expectedValues3=[0,1]
01572         self.assertEqual(list(t1.getValues()),expectedValues3);
01573         pos3=[0.2,0.2]
01574         t1=None
01575         t1=targetMesh.getCellsContainingPoint(pos3,1e-12);
01576         self.assertEqual(5,len(t1));
01577         expectedValues4=[0,1,2,3,4]
01578         self.assertEqual(list(t1.getValues()),expectedValues4);
01579         self.assertEqual(0,targetMesh.getCellContainingPoint(pos3,1e-12));
01580         #3D
01581         targetMesh=MEDCouplingDataForTest.build3DTargetMesh_1();
01582         pos4=[25.,25.,25.]
01583         self.assertEqual(0,targetMesh.getCellContainingPoint(pos4,1e-12));
01584         pos5=[50.,50.,50.]
01585         t1=None
01586         t1=targetMesh.getCellsContainingPoint(pos5,1e-12);
01587         self.assertEqual(8,len(t1));
01588         expectedValues5=[0,1,2,3,4,5,6,7]
01589         self.assertEqual(list(t1.getValues()),expectedValues5);
01590         pos6=[0., 50., 0.]
01591         t1=None
01592         t1=targetMesh.getCellsContainingPoint(pos6,1e-12);
01593         self.assertEqual(2,len(t1));
01594         expectedValues6=[0,2]
01595         self.assertEqual(list(t1.getValues()),expectedValues6);
01596         #3D outside
01597         pos7=[-1.0,-1.0,0.]
01598         self.assertEqual(-1,targetMesh.getCellContainingPoint(pos7,1e-12));
01599         #3D outside 2
01600         center2=[0.,0.,0.]
01601         vec2=[0.,-1.,0.]
01602         targetMesh.rotate(center2,vec2,0.78539816339744830962);
01603         pos8=[-25.,25.,12.]
01604         self.assertEqual(-1,targetMesh.getCellContainingPoint(pos8,1e-12));
01605         pass

Definition at line 8229 of file MEDCouplingBasicsTest.py.

08229 
08230     def testGetDistributionOfTypes1(self):
08231         m=MEDCouplingDataForTest.build2DTargetMesh_1();
08232         tab1=[2,0,1,3,4]
08233         self.assertRaises(InterpKernelException,m.getDistributionOfTypes);
08234         m.renumberCells(tab1,False);
08235         code=m.getDistributionOfTypes();
08236         self.assertEqual(6,len(code));
08237         self.assertEqual(3,code[0]);
08238         self.assertEqual(2,code[1]);
08239         self.assertEqual(0,code[2]);
08240         self.assertEqual(4,code[3]);
08241         self.assertEqual(3,code[4]);
08242         self.assertEqual(0,code[5]);
08243         pass

Definition at line 3639 of file MEDCouplingBasicsTest.py.

03639 
03640     def testGetEdgeRatioField1(self):
03641         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
03642         f1=m1.getEdgeRatioField();
03643         self.assertEqual(m1.getNumberOfCells(),f1.getNumberOfTuples());
03644         self.assertEqual(5,f1.getNumberOfTuples());
03645         self.assertEqual(1,f1.getNumberOfComponents());
03646         expected1=[1.,1.4142135623730951, 1.4142135623730951,1.,1.]
03647         for i in xrange(5):
03648             self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),14);
03649             pass
03650         #
03651         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
03652         f1=m1.getEdgeRatioField();
03653         self.assertEqual(m1.getNumberOfCells(),f1.getNumberOfTuples());
03654         self.assertEqual(5,f1.getNumberOfTuples());
03655         self.assertEqual(1,f1.getNumberOfComponents());
03656         expected2=[1.4142135623730951, 1.7320508075688772, 1.7320508075688772, 1.4142135623730951, 1.4142135623730951]
03657         for i in xrange(5):
03658             self.assertAlmostEqual(expected2[i],f1.getIJ(i,0),14);
03659             pass
03660         pass

Definition at line 3020 of file MEDCouplingBasicsTest.py.

03020 
03021     def testGetIdsInRange1(self):
03022         mesh1=MEDCouplingDataForTest.build2DTargetMesh_3();
03023         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
03024         f1.setTime(2.3,5,6);
03025         f1.setMesh(mesh1);
03026         array=DataArrayDouble.New();
03027         arr1=[2.,8.,6.,5.,11.,7.,9.,3.,10.,4.]
03028         array.setValues(arr1,mesh1.getNumberOfCells(),1);
03029         f1.setArray(array);
03030         #
03031         f1.checkCoherency();
03032         da=f1.getIdsInRange(2.9,7.1);
03033         self.failUnlessEqual(5,da.getNbOfElems());
03034         expected1=[2,3,5,7,9]
03035         self.failUnlessEqual(expected1,list(da.getValues()));
03036         da=f1.getIdsInRange(8.,12.);
03037         self.failUnlessEqual(4,da.getNbOfElems());
03038         expected2=[1,4,6,8]
03039         self.failUnlessEqual(expected2,list(da.getValues()));
03040         #
03041         pass

Definition at line 7969 of file MEDCouplingBasicsTest.py.

07969 
07970     def testGetLevArrPerCellTypes1(self):
07971         m,m1=MEDCouplingDataForTest.buildPointe_1();
07972         m1,d0,d1,d2,d3=m.buildDescendingConnectivity();
07973         order=[NORM_TRI3,NORM_QUAD4];
07974         da0,da1=m1.getLevArrPerCellTypes(order);
07975         expected0=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1]
07976         expected1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46]
07977         self.assertEqual(47,da0.getNumberOfTuples());
07978         self.assertEqual(1,da0.getNumberOfComponents());
07979         for i in xrange(47):
07980             self.assertEqual(expected0[i],da0.getIJ(0,i));
07981             pass
07982         self.assertEqual(2,da1.getNumberOfTuples());
07983         self.assertEqual(1,da1.getNumberOfComponents());
07984         self.assertEqual(36,da1.getIJ(0,0));#36 TRI3
07985         self.assertEqual(11,da1.getIJ(1,0));#11 QUAD4
07986         #
07987         da2=da0.buildPermArrPerLevel();
07988         #
07989         self.assertEqual(47,da2.getNumberOfTuples());
07990         self.assertEqual(1,da2.getNumberOfComponents());
07991         for i in xrange(47):
07992             self.assertEqual(expected1[i],da2.getIJ(0,i));
07993             pass
07994         pass

Definition at line 2869 of file MEDCouplingBasicsTest.py.

02869 
02870     def testGetMaxValue1(self):
02871         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
02872         nbOfCells=m.getNumberOfCells();
02873         f=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
02874         f.setMesh(m);
02875         a1=DataArrayDouble.New();
02876         val1=[3.,4.,5.,6.,7.]
02877         a1.setValues(val1,nbOfCells,1);
02878         a2=DataArrayDouble.New();
02879         val2=[0.,1.,2.,8.,7.]
02880         a2.setValues(val2,nbOfCells,1);
02881         f.setArray(a1);
02882         f.setEndArray(a2);
02883         f.setEndTime(3.,3,4);
02884         f.checkCoherency();
02885         #
02886         self.assertAlmostEqual(8.,f.getMaxValue(),14);
02887         self.assertAlmostEqual(0.,f.getMinValue(),14);
02888         self.assertAlmostEqual(5.,f.getAverageValue(),14);
02889         self.assertAlmostEqual(5.125,f.getWeightedAverageValue(),14);
02890         a1.setIJ(0,2,9.5);
02891         self.assertAlmostEqual(9.5,f.getMaxValue(),14);
02892         self.assertAlmostEqual(0.,f.getMinValue(),14);
02893         a2.setIJ(0,0,9.);
02894         self.assertAlmostEqual(9.5,f.getMaxValue(),14);
02895         self.assertAlmostEqual(1.,f.getMinValue(),14);
02896         pass

Definition at line 3844 of file MEDCouplingBasicsTest.py.

03844 
03845     def testGetMeasureFieldCMesh1(self):
03846         m=MEDCouplingCMesh.New();
03847         da=DataArrayDouble.New();
03848         discX=[2.3,3.4,5.8,10.2]
03849         discY=[12.3,23.4,45.8]
03850         discZ=[-0.7,1.2,1.25,2.13,2.67]
03851         da.setValues(discX,4,1);
03852         m.setCoordsAt(0,da);
03853         m.checkCoherency();
03854         self.assertEqual(4,m.getNumberOfNodes());
03855         self.assertEqual(3,m.getNumberOfCells());
03856         self.assertEqual(1,m.getSpaceDimension());
03857         f=m.getMeasureField(True);
03858         self.assertEqual(3,f.getNumberOfTuples());
03859         self.assertEqual(1,f.getNumberOfComponents());
03860         expected1=[1.1,2.4,4.4]
03861         for i in xrange(3):
03862             self.assertAlmostEqual(expected1[i],f.getIJ(i,0),12);
03863             pass
03864         coords=m.getCoordinatesAndOwner();
03865         self.assertEqual(4,coords.getNumberOfTuples());
03866         self.assertEqual(1,coords.getNumberOfComponents());
03867         for i in xrange(4):
03868             self.assertAlmostEqual(discX[i],coords.getIJ(i,0),12);
03869             pass
03870         coords=m.getBarycenterAndOwner();
03871         self.assertEqual(3,coords.getNumberOfTuples());
03872         self.assertEqual(1,coords.getNumberOfComponents());
03873         expected1_3=[2.85,4.6,8.]
03874         for i in xrange(3):
03875             self.assertAlmostEqual(expected1_3[i],coords.getIJ(i,0),12);
03876             pass
03877         #
03878         da=DataArrayDouble.New();
03879         da.setValues(discY,3,1);
03880         m.setCoordsAt(1,da);
03881         m.checkCoherency();
03882         self.assertEqual(12,m.getNumberOfNodes());
03883         self.assertEqual(6,m.getNumberOfCells());
03884         self.assertEqual(2,m.getSpaceDimension());
03885         f=m.getMeasureField(True);
03886         self.assertEqual(6,f.getNumberOfTuples());
03887         self.assertEqual(1,f.getNumberOfComponents());
03888         expected2=[12.21,26.64,48.84,24.64,53.76,98.56]
03889         for i in xrange(6):
03890             self.assertAlmostEqual(expected2[i],f.getIJ(i,0),12);
03891             pass
03892         coords=m.getCoordinatesAndOwner();
03893         self.assertEqual(12,coords.getNumberOfTuples());
03894         self.assertEqual(2,coords.getNumberOfComponents());
03895         expected2_2=[2.3,12.3,3.4,12.3,5.8,12.3,10.2,12.3, 2.3,23.4,3.4,23.4,5.8,23.4,10.2,23.4, 2.3,45.8,3.4,45.8,5.8,45.8,10.2,45.8]
03896         for i in xrange(24):
03897             self.assertAlmostEqual(expected2_2[i],coords.getIJ(0,i),12);
03898             pass
03899         coords=m.getBarycenterAndOwner();
03900         self.assertEqual(6,coords.getNumberOfTuples());
03901         self.assertEqual(2,coords.getNumberOfComponents());
03902         expected2_3=[2.85,17.85,4.6,17.85,8.,17.85, 2.85,34.6,4.6,34.6,8.,34.6]
03903         for i in xrange(12):
03904             self.assertAlmostEqual(expected2_3[i],coords.getIJ(0,i),12);
03905             pass
03906         #
03907         da=DataArrayDouble.New();
03908         da.setValues(discZ,5,1);
03909         m.setCoordsAt(2,da);
03910         m.checkCoherency();
03911         self.assertEqual(60,m.getNumberOfNodes());
03912         self.assertEqual(24,m.getNumberOfCells());
03913         self.assertEqual(3,m.getSpaceDimension());
03914         f=m.getMeasureField(True);
03915         self.assertEqual(24,f.getNumberOfTuples());
03916         self.assertEqual(1,f.getNumberOfComponents());
03917         expected3=[23.199, 50.616, 92.796, 46.816, 102.144, 187.264, 0.6105, 1.332, 2.442, 1.232, 2.688, 4.928, 10.7448, 23.4432, 42.9792, 21.6832, 47.3088, 86.7328, 6.5934, 14.3856, 26.3736, 13.3056, 29.0304, 53.2224]
03918         for i in xrange(24):
03919             self.assertAlmostEqual(expected3[i],f.getIJ(i,0),12);
03920             pass
03921         coords=m.getCoordinatesAndOwner();
03922         self.assertEqual(60,coords.getNumberOfTuples());
03923         self.assertEqual(3,coords.getNumberOfComponents());
03924         expected3_2=[
03925             2.3,12.3,-0.7, 3.4,12.3,-0.7, 5.8,12.3,-0.7, 10.2,12.3,-0.7, 2.3,23.4,-0.7, 3.4,23.4,-0.7, 5.8,23.4,-0.7, 10.2,23.4,-0.7, 2.3,45.8,-0.7, 3.4,45.8,-0.7, 5.8,45.8,-0.7, 10.2,45.8,-0.7,
03926             2.3,12.3,1.2, 3.4,12.3,1.2, 5.8,12.3,1.2, 10.2,12.3,1.2, 2.3,23.4,1.2, 3.4,23.4,1.2, 5.8,23.4,1.2, 10.2,23.4,1.2, 2.3,45.8,1.2, 3.4,45.8,1.2, 5.8,45.8,1.2, 10.2,45.8,1.2,
03927             2.3,12.3,1.25, 3.4,12.3,1.25, 5.8,12.3,1.25, 10.2,12.3,1.25, 2.3,23.4,1.25, 3.4,23.4,1.25, 5.8,23.4,1.25, 10.2,23.4,1.25, 2.3,45.8,1.25, 3.4,45.8,1.25, 5.8,45.8,1.25, 10.2,45.8,1.25,
03928             2.3,12.3,2.13, 3.4,12.3,2.13, 5.8,12.3,2.13, 10.2,12.3,2.13, 2.3,23.4,2.13, 3.4,23.4,2.13, 5.8,23.4,2.13, 10.2,23.4,2.13, 2.3,45.8,2.13, 3.4,45.8,2.13, 5.8,45.8,2.13, 10.2,45.8,2.13,
03929             2.3,12.3,2.67, 3.4,12.3,2.67, 5.8,12.3,2.67, 10.2,12.3,2.67, 2.3,23.4,2.67, 3.4,23.4,2.67, 5.8,23.4,2.67, 10.2,23.4,2.67, 2.3,45.8,2.67, 3.4,45.8,2.67, 5.8,45.8,2.67, 10.2,45.8,2.67];
03930         for i in xrange(180):
03931             self.assertAlmostEqual(expected3_2[i],coords.getIJ(0,i),12);
03932             pass
03933         coords=m.getBarycenterAndOwner();
03934         self.assertEqual(24,coords.getNumberOfTuples());
03935         self.assertEqual(3,coords.getNumberOfComponents());
03936         expected3_3=[
03937             2.85,17.85,0.25,4.6,17.85,0.25,8.,17.85,0.25, 2.85,34.6,0.25,4.6,34.6,0.25,8.,34.6,0.25,
03938             2.85,17.85,1.225,4.6,17.85,1.225,8.,17.85,1.225, 2.85,34.6,1.225,4.6,34.6,1.225,8.,34.6,1.225,
03939             2.85,17.85,1.69,4.6,17.85,1.69,8.,17.85,1.69, 2.85,34.6,1.69,4.6,34.6,1.69,8.,34.6,1.69,
03940             2.85,17.85,2.4,4.6,17.85,2.4,8.,17.85,2.4, 2.85,34.6,2.4,4.6,34.6,2.4,8.,34.6,2.4];
03941         for i in xrange(72):
03942             self.assertAlmostEqual(expected3_3[i],coords.getIJ(0,i),12);
03943             pass
03944         pass

Definition at line 8554 of file MEDCouplingBasicsTest.py.

08554 
08555     def testGetNodeIdsInUse1(self):
08556         m0=MEDCouplingDataForTest.build2DTargetMesh_1();
08557         CellIds=[1,2]
08558         m1=m0.buildPartOfMySelf(CellIds,True);
08559         arr,newNbOfNodes=m1.getNodeIdsInUse();
08560         expected=[-1,0,1,-1,2,3,-1,-1,-1]
08561         self.assertEqual(4,newNbOfNodes);
08562         self.assertEqual(9,arr.getNbOfElems());
08563         self.assertEqual(expected,arr.getValues());
08564         arr2=arr.invertArrayO2N2N2O(newNbOfNodes);
08565         self.assertEqual(4,arr2.getNbOfElems());
08566         expected2=[1,2,4,5]
08567         self.assertEqual(expected2,arr2.getValues());
08568         pass

Definition at line 5303 of file MEDCouplingBasicsTest.py.

05303 
05304     def testGetNodeIdsNearPoints1(self):
05305         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
05306         coords=mesh.getCoords();
05307         tmp=DataArrayDouble.New();
05308         vals=[0.2,0.2,0.1,0.2,0.2,0.2]
05309         tmp.setValues(vals,3,2);
05310         tmp2=DataArrayDouble.Aggregate(coords,tmp);
05311         mesh.setCoords(tmp2);
05312         pts=[0.2,0.2,0.1,0.3,-0.3,0.7]
05313         c=mesh.getNodeIdsNearPoint(pts,1e-7);
05314         self.assertEqual([4,9,11],c.getValues());
05315         c,cI=mesh.getNodeIdsNearPoints(pts,3,1e-7);
05316         self.assertEqual([0,3,3,4],cI.getValues());
05317         self.assertEqual([4,9,11,6],c.getValues());
05318         pass

Definition at line 3624 of file MEDCouplingBasicsTest.py.

03624 
03625     def testGetNodeIdsOfCell1(self):
03626         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03627         li=mesh1.getNodeIdsOfCell(1)
03628         expected1=[1, 4, 2]
03629         self.assertEqual(expected1,list(li))
03630         li=mesh1.getCoordinatesOfNode(4)
03631         self.assertEqual(2,len(li))
03632         self.assertAlmostEqual(0.2,li[0],13);
03633         self.assertAlmostEqual(0.2,li[1],13);
03634         li=mesh1.getCoords().getValuesAsTuple()
03635         self.assertEqual(9,len(li))
03636         li2=mesh1.getNodalConnectivityIndex().getValuesAsTuple()
03637         self.assertEqual(6,len(li2))
03638         pass

Definition at line 9248 of file MEDCouplingBasicsTest.py.

09248 
09249     def testGetNodeIdsOfCell2(self):
09250         m1c=MEDCouplingCMesh.New();
09251         coordsX=DataArrayDouble.New();
09252         arrX=[ -1., 1., 2., 4., 4.5 ]
09253         coordsX.setValues(arrX,5,1);
09254         coordsY=DataArrayDouble.New();
09255         arrY=[ -2., 2., 4., 8.]
09256         coordsY.setValues(arrY,4,1);
09257         coordsZ=DataArrayDouble.New();
09258         arrZ=[ -2., 2., 4.]
09259         coordsZ.setValues(arrZ,3,1);
09260         # test in 1D
09261         m1c.setCoordsAt(0,coordsX);
09262         expected1=[[0,1],[1,2],[2,3],[3,4]]
09263         self.assertEqual(4,m1c.getNumberOfCells())
09264         for i in xrange(m1c.getNumberOfCells()):
09265             self.assertEqual(expected1[i],m1c.getNodeIdsOfCell(i))
09266             pass
09267         # test in 2D
09268         m1c.setCoordsAt(1,coordsY);
09269         self.assertEqual(12,m1c.getNumberOfCells())
09270         expected2=[[0,1,6,5],[1,2,7,6],[2,3,8,7],[3,4,9,8],[4,5,11,10],[5,6,12,11],[6,7,13,12],[7,8,14,13],[8,9,16,15],[9,10,17,16],[10,11,18,17],[11,12,19,18]]
09271         for i in xrange(m1c.getNumberOfCells()):
09272             self.assertEqual(expected2[i],m1c.getNodeIdsOfCell(i))
09273             pass
09274         # test in 3D
09275         m1c.setCoordsAt(2,coordsZ);
09276         expected3=[[0,1,6,5,20,21,26,25],[1,2,7,6,21,22,27,26],[2,3,8,7,22,23,28,27],[3,4,9,8,23,24,29,28],[4,5,11,10,24,25,31,30],[5,6,12,11,25,26,32,31],[6,7,13,12,26,27,33,32],[7,8,14,13,27,28,34,33],[8,9,16,15,28,29,36,35],[9,10,17,16,29,30,37,36],[10,11,18,17,30,31,38,37],[11,12,19,18,31,32,39,38],[20,21,26,25,40,41,46,45],[21,22,27,26,41,42,47,46],[22,23,28,27,42,43,48,47],[23,24,29,28,43,44,49,48],[24,25,31,30,44,45,51,50],[25,26,32,31,45,46,52,51],[26,27,33,32,46,47,53,52],[27,28,34,33,47,48,54,53],[28,29,36,35,48,49,56,55],[29,30,37,36,49,50,57,56],[30,31,38,37,50,51,58,57],[31,32,39,38,51,52,59,58]]
09277         self.assertEqual(24,m1c.getNumberOfCells())
09278         for i in xrange(m1c.getNumberOfCells()):
09279             self.assertEqual(expected3[i],m1c.getNodeIdsOfCell(i))
09280             pass
09281         pass
    

Definition at line 1606 of file MEDCouplingBasicsTest.py.

01606 
01607     def testGetValueOn1(self):
01608         targetMesh=MEDCouplingDataForTest.build2DTargetMesh_1();
01609         fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS);
01610         nbOfCells=targetMesh.getNumberOfCells();
01611         fieldOnCells.setMesh(targetMesh);
01612         array=DataArrayDouble.New();
01613         tmp=2*nbOfCells*[None]
01614         for i in xrange(nbOfCells):
01615             tmp[2*i]=7.+float(i);
01616             tmp[2*i+1]=17.+float(i)
01617             pass
01618         array.setValues(tmp,nbOfCells,2);
01619         fieldOnCells.setArray(array);
01620         #
01621         pos1=[0.25,0.]
01622         res=fieldOnCells.getValueOn(pos1);
01623         self.assertEqual(2,len(res))
01624         self.assertTrue(abs(8.-res[0])<1e-12);
01625         self.assertTrue(abs(18.-res[1])<1e-12);
01626         #
01627         #
01628         targetMesh=MEDCouplingDataForTest.build2DSourceMesh_1();
01629         fieldOnNodes=MEDCouplingFieldDouble.New(ON_NODES);
01630         nbOfNodes=targetMesh.getNumberOfNodes();
01631         fieldOnNodes.setMesh(targetMesh);
01632         array=DataArrayDouble.New();
01633         tmp=2*nbOfNodes*[None]
01634         for i in xrange(nbOfNodes):
01635             tmp[2*i]=17.+float(i);
01636             tmp[2*i+1]=27.+float(i)
01637             pass
01638         array.setValues(tmp,nbOfNodes,2);
01639         fieldOnNodes.setArray(array);
01640         #
01641         pos2=[-0.13333333333333333,-0.13333333333333333]
01642         res=None
01643         res=fieldOnNodes.getValueOn(pos2);
01644         self.assertEqual(2,len(res))
01645         self.assertTrue(abs(17.5-res[0])<1e-12);
01646         self.assertTrue(abs(27.5-res[1])<1e-12);
01647         pos3=[0.033333333333333326,0.36666666666666664]
01648         res=None
01649         res=fieldOnNodes.getValueOn(pos3);
01650         self.assertEqual(2,len(res))
01651         self.assertTrue(abs(18.666666666666667-res[0])<1e-12);
01652         self.assertTrue(abs(28.666666666666667-res[1])<1e-12);
01653         pass

Definition at line 7568 of file MEDCouplingBasicsTest.py.

07568 
07569     def testGetValueOn2(self):
07570         m=MEDCouplingDataForTest.build2DTargetMesh_1();
07571         f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
07572         f.setMesh(m);
07573         arr=DataArrayDouble.New();
07574         nbOfCells=m.getNumberOfCells();
07575         f.setArray(arr);
07576         values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.]
07577         arr.setValues(values1,nbOfCells,3);
07578         loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45]
07579         f.checkCoherency();
07580         locs=f.getValueOnMulti(loc);
07581         self.assertEqual(5,locs.getNumberOfTuples());
07582         self.assertEqual(3,locs.getNumberOfComponents());
07583         for j in xrange(15):
07584             self.assertAlmostEqual(values1[j],locs.getIJ(0,j),12);
07585             pass
07586         # Testing ON_NODES
07587         f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
07588         f.setMesh(m);
07589         arr=DataArrayDouble.New();
07590         nbOfNodes=m.getNumberOfNodes();
07591         f.setArray(arr);
07592         values2=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.]
07593         arr.setValues(values2,nbOfNodes,3);
07594         loc2=[0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432]
07595         expected2=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272]
07596         f.checkCoherency();
07597         loc3=DataArrayDouble.New()
07598         loc3.setValues(loc2,4,2);
07599         locs=f.getValueOnMulti(loc3);
07600         self.assertEqual(4,locs.getNumberOfTuples());
07601         self.assertEqual(3,locs.getNumberOfComponents());
07602         for i in xrange(12):
07603             self.assertAlmostEqual(expected2[i],locs.getIJ(0,i),12);
07604             pass
07605         #
07606         pass

Definition at line 9221 of file MEDCouplingBasicsTest.py.

09221 
09222     def testGetValueOn3(self):
09223         v=[0.,1.,1.5,2.]
09224         v2=[0.7,1.25,0.,2.,1.5]
09225         disp=[5.,50.,500.,6.,60.,600.,7.,70.,700.,8.,80.,800.]
09226         m=MEDCouplingUMesh.New("myMesh",1)
09227         nbNodes=len(v)
09228         nbCells=nbNodes-1
09229         m.allocateCells(nbCells)
09230         coords=DataArrayDouble.New() ; coords.setValues(v,nbNodes,1)
09231         m.setCoords(coords)
09232         m.insertNextCell(NORM_SEG2,2,[0,1])
09233         m.insertNextCell(NORM_SEG2,2,[2,1])
09234         m.insertNextCell(NORM_SEG2,2,[2,3])
09235         m.finishInsertingCells()
09236         f=MEDCouplingFieldDouble.New(ON_NODES)
09237         f.setMesh(m)
09238         array=DataArrayDouble.New(); array.setValues(disp,m.getNumberOfNodes(),3)
09239         f.setArray(array)
09240         arr1=f.getValueOnMulti(v2)
09241         self.assertEqual(5,arr1.getNumberOfTuples());
09242         self.assertEqual(3,arr1.getNumberOfComponents());
09243         expected1=[5.7,57.,570.,6.5,65.,650.,5.,50.,500.,8.,80.,800.,7.,70.,700.]
09244         for i in xrange(15):
09245             self.assertAlmostEqual(expected1[i],arr1.getIJ(0,i),14);
09246             pass
09247         pass

Definition at line 8596 of file MEDCouplingBasicsTest.py.

08596 
08597     def testIntersect2DMeshesTmp1(self):
08598         m1c=MEDCouplingCMesh.New();
08599         coordsX=DataArrayDouble.New();
08600         arrX=[ -1., 1., 2., 4. ]
08601         coordsX.setValues(arrX,4,1);
08602         m1c.setCoordsAt(0,coordsX);
08603         coordsY=DataArrayDouble.New();
08604         arrY=[ -2., 2., 4., 8. ]
08605         coordsY.setValues(arrY,4,1);
08606         m1c.setCoordsAt(1,coordsY);
08607         m1=m1c.buildUnstructured()
08608         m1bis=m1.buildPartOfMySelf([3,4,5],False)
08609         m2=m1.deepCpy()
08610         m2=m2.buildPartOfMySelf([0,1,2],False)
08611         m2.translate([0.5,0.5])
08612         #
08613         m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m1bis,m2,1e-10)
08614         expected1=[0,1,1,2,2]
08615         expected2=[0,0,1,1,2]
08616         self.assertEqual(5,d1.getNumberOfTuples());
08617         self.assertEqual(5,d2.getNumberOfTuples());
08618         self.assertEqual(5,m3.getNumberOfCells());
08619         self.assertEqual(22,m3.getNumberOfNodes());
08620         self.assertEqual(2,m3.getSpaceDimension());
08621         self.assertEqual(expected1,d1.getValues());
08622         self.assertEqual(expected2,d2.getValues());
08623         expected3=[5,17,1,16,12,5,18,1,17,13,5,19,2,18,13,5,20,2,19,14,5,21,3,20,14]
08624         expected4=[0,5,10,15,20,25]
08625         expected5=[-1.0,2.0,1.0,2.0,2.0,2.0,4.0,2.0,-1.0,4.0,1.0,4.0,2.0,4.0,4.0,4.0,-0.5,-1.5,1.5,-1.5,2.5,-1.5,4.5,-1.5,-0.5,2.5,1.5,2.5,2.5,2.5,4.5,2.5,-0.5,2.0,1.0,2.5,1.5,2.0,2.0,2.5,2.5,2.0,4.0,2.5]
08626         self.assertEqual(25,m3.getNodalConnectivity().getNumberOfTuples());
08627         self.assertEqual(6,m3.getNodalConnectivityIndex().getNumberOfTuples());
08628         self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
08629         self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
08630         for i in xrange(44):
08631             self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
08632             pass
08633         pass

Definition at line 8654 of file MEDCouplingBasicsTest.py.

08654 
08655     def testIntersect2DMeshesTmp2(self):
08656         m1c=MEDCouplingCMesh.New();
08657         coordsX1=DataArrayDouble.New();
08658         arrX1=[ 0., 1., 1.5, 2. ]
08659         coordsX1.setValues(arrX1,4,1);
08660         m1c.setCoordsAt(0,coordsX1);
08661         coordsY1=DataArrayDouble.New();
08662         arrY1=[ 0., 1.5, 3.]
08663         coordsY1.setValues(arrY1,3,1);
08664         m1c.setCoordsAt(1,coordsY1);
08665         m1=m1c.buildUnstructured();
08666         m2c=MEDCouplingCMesh.New();
08667         coordsX2=DataArrayDouble.New();
08668         arrX2=[ 0., 1., 2. ]
08669         coordsX2.setValues(arrX2,3,1);
08670         m2c.setCoordsAt(0,coordsX2);
08671         coordsY2=DataArrayDouble.New();
08672         arrY2=[ 0., 1., 3.]
08673         coordsY2.setValues(arrY2,3,1);
08674         m2c.setCoordsAt(1,coordsY2);
08675         m2=m2c.buildUnstructured();
08676         #
08677         m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m1,m2,1e-10)
08678         #
08679         expected1=[0,0,1,1,2,2,3,4,5]
08680         expected2=[0,2,1,3,1,3,2,3,3]
08681         self.assertEqual(9,d1.getNumberOfTuples());
08682         self.assertEqual(9,d2.getNumberOfTuples());
08683         self.assertEqual(9,m3.getNumberOfCells());
08684         self.assertEqual(22,m3.getNumberOfNodes());
08685         self.assertEqual(2,m3.getSpaceDimension());
08686         self.assertEqual(expected1,d1.getValues());
08687         self.assertEqual(expected2,d2.getValues());
08688         expected3=[5,16,13,12,15,5,15,4,5,16,5,21,2,13,16,5,16,5,6,21,5,17,14,2,21,5,21,6,7,17,5,4,18,19,5,5,5,19,10,6,5,6,10,20,7]
08689         expected4=[0,5,10,15,20,25,30,35,40,45]
08690         expected5=[0.0,0.0,1.0,0.0,1.5,0.0,2.0,0.0,0.0,1.5,1.0,1.5,1.5,1.5,2.0,1.5,0.0,3.0,1.0,3.0,1.5,3.0,2.0,3.0,0.0,0.0,1.0,0.0,2.0,0.0,0.0,1.0,1.0,1.0,2.0,1.0,0.0,3.0,1.0,3.0,2.0,3.0,1.5,1.0]
08691         self.assertEqual(45,m3.getNodalConnectivity().getNumberOfTuples());
08692         self.assertEqual(10,m3.getNodalConnectivityIndex().getNumberOfTuples());
08693         self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
08694         self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
08695         for i in xrange(44):
08696             self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
08697             pass
08698         pass
    

Definition at line 8705 of file MEDCouplingBasicsTest.py.

08705 
08706     def testIntersect2DMeshesTmp3(self):
08707         m1Coords=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1,0.,-1.5,0.5,0.,1.25,0.,0.70710678118654757,0.70710678118654757,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.70710678118654757,0.70710678118654757,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.70710678118654757,-0.70710678118654757,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.70710678118654757,-0.70710678118654757,1.0606601717798214,-1.0606601717798214];
08708         m1Conn=[0,3,1,13,11,9, 3,4,2,1,14,12,10,11, 5,3,0,15,13,17, 6,4,3,5,16,14,15,18, 5,0,7,17,21,19, 6,5,7,8,18,19,22,20, 0,1,7,9,23,21, 1,2,8,7,10,24,22,23];
08709         m1=MEDCouplingUMesh.New();
08710         m1.setMeshDimension(2);
08711         m1.allocateCells(8);
08712         m1.insertNextCell(NORM_TRI6,6,m1Conn[0:6]);
08713         m1.insertNextCell(NORM_QUAD8,8,m1Conn[6:14]);
08714         m1.insertNextCell(NORM_TRI6,6,m1Conn[14:20]);
08715         m1.insertNextCell(NORM_QUAD8,8,m1Conn[20:28]);
08716         m1.insertNextCell(NORM_TRI6,6,m1Conn[28:34]);
08717         m1.insertNextCell(NORM_QUAD8,8,m1Conn[34:42]);
08718         m1.insertNextCell(NORM_TRI6,6,m1Conn[42:48]);
08719         m1.insertNextCell(NORM_QUAD8,8,m1Conn[48:56]);
08720         m1.finishInsertingCells();
08721         myCoords1=DataArrayDouble.New();
08722         myCoords1.setValues(m1Coords,25,2);
08723         m1.setCoords(myCoords1);
08724         #
08725         m2Coords=[0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1,-1.1,-1.,0.,-1.,1.1,-1,1.7,-1.]
08726         m2Conn=[0,3,2,1, 1,2,5,4, 7,6,3,0, 8,9,6,7, 7,0,12,11, 8,7,11,10, 0,1,13,12, 1,4,14,13]
08727         m2=MEDCouplingUMesh.New();
08728         m2.setMeshDimension(2);
08729         m2.allocateCells(8);
08730         for i in xrange(8):
08731             m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)])
08732             pass
08733         m2.finishInsertingCells();
08734         myCoords2=DataArrayDouble.New();
08735         myCoords2.setValues(m2Coords,15,2);
08736         m2.setCoords(myCoords2);
08737         #
08738         m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m1,m2,1e-10)
08739         m3.unPolyze()
08740         #
08741         expected1=[0,1,1,2,3,3,4,5,5,6,7,7]
08742         expected2=[0,0,1,2,2,3,4,4,5,6,6,7]
08743         self.assertEqual(12,d1.getNumberOfTuples());
08744         self.assertEqual(12,d2.getNumberOfTuples());
08745         self.assertEqual(12,m3.getNumberOfCells());
08746         self.assertEqual(88,m3.getNumberOfNodes());
08747         self.assertEqual(2,m3.getSpaceDimension());
08748         self.assertEqual(expected1,d1.getValues());
08749         self.assertEqual(expected2,d2.getValues());
08750         expected3=[6,28,1,25,44,45,46,8,26,1,28,27,47,48,49,50,8,40,2,26,27,51,52,53,54,6,28,25,5,55,56,57,8,28,5,32,31,58,59,60,61,8,32,6,41,31,62,63,64,65,6,25,37,5,66,67,68,8,32,5,37,36,69,70,71,72,8,42,6,32,36,73,74,75,76,6,1,37,25,77,78,79,8,37,1,26,38,80,81,82,83,8,26,2,43,38,84,85,86,87]
08751         expected4=[0,7,16,25,32,41,50,57,66,75,82,91,100]
08752         expected5=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1.,-1.1,-1.,0.,-1.,1.1,-1.,1.7,-1.,1.118033988749895,1.,-1.118033988749895,1.,-1.118033988749895,-1.,1.118033988749895,-1.,0.7071067811865477,0.7071067811865476,0.5,0.,0.,0.5,1.05,0.,0.7071067811865475,0.7071067811865477,0.55,1.,1.1,0.5,1.4012585384440737,0.535233134659635,1.3,0.,1.1,0.5,1.1090169943749475,1.,0.,0.5,-0.5,0.,-0.7071067811865477,0.7071067811865476,-0.7071067811865475,0.7071067811865477,-1.05,0.,-1.1,0.5,-0.55,1.,-1.3,0.,-1.4012585384440737,0.5352331346596344,-1.1090169943749475,1.,-1.1,0.5,0.,-0.5,-0.7071067811865475,-0.7071067811865477,-0.5,0.,-1.05,0.,-0.7071067811865478,-0.7071067811865475,-0.55,-1.,-1.1,-0.5,-1.4012585384440732,-0.5352331346596354,-1.3,0.,-1.1,-0.5,-1.1090169943749475,-1.,0.7071067811865475,-0.7071067811865477,0.,-0.5,0.5,0.,0.7071067811865477,-0.7071067811865475,1.05,0.,1.1,-0.5,0.55,-1.,1.3,0.,1.4012585384440737,-0.535233134659635,1.1090169943749475,-1.,1.1,-0.5]
08753         self.assertEqual(100,m3.getNodalConnectivity().getNumberOfTuples());
08754         self.assertEqual(13,m3.getNodalConnectivityIndex().getNumberOfTuples());
08755         self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
08756         self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
08757         for i in xrange(176):
08758             self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
08759             pass
08760         pass

Definition at line 8805 of file MEDCouplingBasicsTest.py.

08805 
08806     def testIntersect2DMeshesTmp4(self):
08807         m1Coords=[0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1,0.,-1.5,0.5,0.,1.25,0.,0.70710678118654757,0.70710678118654757,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.70710678118654757,0.70710678118654757,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.70710678118654757,-0.70710678118654757,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.70710678118654757,-0.70710678118654757,1.0606601717798214,-1.0606601717798214];
08808         m1Conn=[0,3,1,13,11,9, 3,4,2,1,14,12,10,11, 5,3,0,15,13,17, 6,4,3,5,16,14,15,18, 5,0,7,17,21,19, 6,5,7,8,18,19,22,20, 0,1,7,9,23,21, 1,2,8,7,10,24,22,23];
08809         m1=MEDCouplingUMesh.New();
08810         m1.setMeshDimension(2);
08811         m1.allocateCells(8);
08812         m1.insertNextCell(NORM_TRI6,6,m1Conn[0:6]);
08813         m1.insertNextCell(NORM_QUAD8,8,m1Conn[6:14]);
08814         m1.insertNextCell(NORM_TRI6,6,m1Conn[14:20]);
08815         m1.insertNextCell(NORM_QUAD8,8,m1Conn[20:28]);
08816         m1.insertNextCell(NORM_TRI6,6,m1Conn[28:34]);
08817         m1.insertNextCell(NORM_QUAD8,8,m1Conn[34:42]);
08818         m1.insertNextCell(NORM_TRI6,6,m1Conn[42:48]);
08819         m1.insertNextCell(NORM_QUAD8,8,m1Conn[48:56]);
08820         m1.finishInsertingCells();
08821         myCoords1=DataArrayDouble.New();
08822         myCoords1.setValues(m1Coords,25,2);
08823         m1.setCoords(myCoords1);
08824         #
08825         m2Coords=[0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1,-1.1,-1.,0.,-1.,1.1,-1,1.7,-1.]
08826         m2Conn=[0,3,2,1, 1,2,5,4, 7,6,3,0, 8,9,6,7, 7,0,12,11, 8,7,11,10, 0,1,13,12, 1,4,14,13]
08827         m2=MEDCouplingUMesh.New();
08828         m2.setMeshDimension(2);
08829         m2.allocateCells(8);
08830         for i in xrange(8):
08831             m2.insertNextCell(NORM_QUAD4,4,m2Conn[4*i:4*(i+1)])
08832             pass
08833         m2.finishInsertingCells();
08834         myCoords2=DataArrayDouble.New();
08835         myCoords2.setValues(m2Coords,15,2);
08836         m2.setCoords(myCoords2);
08837         #
08838         m3,d1,d2=MEDCouplingUMesh.Intersect2DMeshes(m2,m1,1e-10)
08839         m3.unPolyze()
08840         #
08841         expected1=[0,0,1,2,2,3,4,4,5,6,6,7]
08842         expected2=[0,1,1,2,3,3,4,5,5,6,7,7]
08843         self.assertEqual(12,d1.getNumberOfTuples());
08844         self.assertEqual(12,d2.getNumberOfTuples());
08845         self.assertEqual(12,m3.getNumberOfCells());
08846         self.assertEqual(88,m3.getNumberOfNodes());
08847         self.assertEqual(2,m3.getSpaceDimension());
08848         self.assertEqual(expected1,d1.getValues());
08849         self.assertEqual(expected2,d2.getValues());
08850         expected3=[6,16,15,18,44,45,46,8,18,2,1,16,47,48,49,50,8,17,1,2,40,51,52,53,54,6,18,15,20,55,56,57,8,20,7,6,18,58,59,60,61,8,41,6,7,21,62,63,64,65,6,20,15,22,66,67,68,8,22,11,7,20,69,70,71,72,8,21,7,11,42,73,74,75,76,6,22,15,16,77,78,79,8,16,1,13,22,80,81,82,83,8,43,13,1,17,84,85,86,87]
08851         expected4=[0,7,16,25,32,41,50,57,66,75,82,91,100]
08852         expected5=[0.,0.,1.1,0.,1.1,1.,0.,1.,1.7,0.,1.7,1.,-1.1,1.,-1.1,0.,-1.7,0.,-1.7,1.,-1.7,-1.,-1.1,-1.,0.,-1.,1.1,-1.,1.7,-1.,0.,0.,1.,0.,1.5,0.,0.,1.,0.,1.5,-1.,0.,-1.5,0.,0.,-1.,0.,-1.5,0.5,0.,1.25,0.,0.7071067811865476,0.7071067811865476,1.0606601717798214,1.0606601717798214,0.,0.5,0.,1.25,-0.7071067811865476,0.7071067811865476,-1.0606601717798214,1.0606601717798214,-0.5,0.,-1.25,0.,-0.7071067811865476,-0.7071067811865476,-1.0606601717798214,-1.0606601717798214,0.,-0.5,0.,-1.25,0.7071067811865476,-0.7071067811865476,1.0606601717798214,-1.0606601717798214,1.1180339887498951,1.,-1.1180339887498951,1.,-1.1180339887498951,-1.,1.1180339887498951,-1.,0.5,0.,0.,0.5,0.7071067811865477,0.7071067811865476,0.55,1.,1.1,0.5,1.05,0.,0.7071067811865477,0.7071067811865477,1.3,0.,1.1,0.5,1.1090169943749475,1.,1.4012585384440737,0.535233134659635,0.,0.5,-0.5,0.,-0.7071067811865477,0.7071067811865476,-1.05,0.,-1.1,0.5,-0.55,1.,-0.7071067811865477,0.7071067811865477,-1.1090169943749475,1.,-1.1,0.5,-1.3,0.,-1.4012585384440737,0.5352331346596344,-0.5,0.,0.,-0.5,-0.7071067811865475,-0.7071067811865477,-0.55,-1.,-1.1,-0.5,-1.05,0.,-0.7071067811865479,-0.7071067811865476,-1.3,0.,-1.1,-0.5,-1.1090169943749475,-1.,-1.4012585384440734,-0.5352331346596354,0.,-0.5,0.5,0.,0.7071067811865475,-0.7071067811865477,1.05,0.,1.1,-0.5,0.55,-1.,0.7071067811865477,-0.7071067811865476,1.1090169943749475,-1.,1.1,-0.5,1.3,0.,1.4012585384440737,-0.535233134659635]
08853         self.assertEqual(100,m3.getNodalConnectivity().getNumberOfTuples());
08854         self.assertEqual(13,m3.getNodalConnectivityIndex().getNumberOfTuples());
08855         self.assertEqual(expected3,m3.getNodalConnectivity().getValues());
08856         self.assertEqual(expected4,m3.getNodalConnectivityIndex().getValues());
08857         for i in xrange(176):
08858             self.assertAlmostEqual(expected5[i],m3.getCoords().getIJ(0,i),12);
08859             pass
08860         pass

Definition at line 3310 of file MEDCouplingBasicsTest.py.

03310 
03311     def testInverse1(self):
03312         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03313         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03314         f1.setMesh(mesh1);
03315         array=DataArrayDouble.New();
03316         arr1=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1]
03317         array.setValues(arr1,mesh1.getNumberOfCells(),9);
03318         f1.setArray(array);
03319         f1.checkCoherency();
03320         #
03321         f2=f1.inverse();
03322         f2.checkCoherency();
03323         self.assertEqual(9,f2.getNumberOfComponents());
03324         self.assertEqual(5,f2.getNumberOfTuples());
03325         expected1=[-2.6538108356290113, 2.855831037649208, -1.1111111111111067, 3.461891643709813, -4.775022956841121, 2.2222222222222143, -1.1111111111111054, 2.222222222222214, -1.1111111111111072]
03326         for i in xrange(5):
03327             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
03328             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
03329             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
03330             self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13);
03331             self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13);
03332             self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13);
03333             self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13);
03334             self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13);
03335             self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13);
03336             pass
03337         #
03338         array=DataArrayDouble.New();
03339         arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5]
03340         array.setValues(arr3,mesh1.getNumberOfCells(),6);
03341         f1.setArray(array);
03342         f1.checkCoherency();
03343         #
03344         f2=f1.inverse();
03345         f2.checkCoherency();
03346         self.assertEqual(6,f2.getNumberOfComponents());
03347         self.assertEqual(5,f2.getNumberOfTuples());
03348         expected3=[-0.3617705098531818, -0.8678630828458127, -0.026843764174972983, 0.5539957431465833, 0.13133439560823013, -0.05301294502145887]
03349         for i in xrange(5):
03350             self.assertAlmostEqual(expected3[0],f2.getIJ(i,0),13);
03351             self.assertAlmostEqual(expected3[1],f2.getIJ(i,1),13);
03352             self.assertAlmostEqual(expected3[2],f2.getIJ(i,2),13);
03353             self.assertAlmostEqual(expected3[3],f2.getIJ(i,3),13);
03354             self.assertAlmostEqual(expected3[4],f2.getIJ(i,4),13);
03355             self.assertAlmostEqual(expected3[5],f2.getIJ(i,5),13);
03356             pass
03357         #
03358         array=DataArrayDouble.New();
03359         arr2=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5]
03360         array.setValues(arr2,mesh1.getNumberOfCells(),4);
03361         f1.setArray(array);
03362         f1.checkCoherency();
03363         #
03364         f2=f1.inverse();
03365         f2.checkCoherency();
03366         self.assertEqual(4,f2.getNumberOfComponents());
03367         self.assertEqual(5,f2.getNumberOfTuples());
03368         expected2=[-1.8595041322314059, 0.9504132231404963, 1.404958677685951, -0.49586776859504156]
03369         for i in xrange(5):
03370             self.assertAlmostEqual(expected2[0],f2.getIJ(i,0),13);
03371             self.assertAlmostEqual(expected2[1],f2.getIJ(i,1),13);
03372             self.assertAlmostEqual(expected2[2],f2.getIJ(i,2),13);
03373             self.assertAlmostEqual(expected2[3],f2.getIJ(i,3),13);
03374             pass
03375         #
03376         pass

Here is the caller graph for this function:

Definition at line 4544 of file MEDCouplingBasicsTest.py.

04544 
04545     def testInverse1(self):
04546         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04547         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04548         f1.setMesh(mesh1);
04549         array=DataArrayDouble.New();
04550         arr1=[1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1, 1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1]
04551         array.setValues(arr1,mesh1.getNumberOfCells(),9);
04552         f1.setArray(array);
04553         f1.checkCoherency();
04554         #
04555         f2=f1.inverse();
04556         f2.checkCoherency();
04557         self.assertEqual(9,f2.getNumberOfComponents());
04558         self.assertEqual(5,f2.getNumberOfTuples());
04559         expected1=[-2.6538108356290113, 2.855831037649208, -1.1111111111111067, 3.461891643709813, -4.775022956841121, 2.2222222222222143, -1.1111111111111054, 2.222222222222214, -1.1111111111111072]
04560         for i in xrange(5):
04561             self.assertAlmostEqual(expected1[0],f2.getIJ(i,0),13);
04562             self.assertAlmostEqual(expected1[1],f2.getIJ(i,1),13);
04563             self.assertAlmostEqual(expected1[2],f2.getIJ(i,2),13);
04564             self.assertAlmostEqual(expected1[3],f2.getIJ(i,3),13);
04565             self.assertAlmostEqual(expected1[4],f2.getIJ(i,4),13);
04566             self.assertAlmostEqual(expected1[5],f2.getIJ(i,5),13);
04567             self.assertAlmostEqual(expected1[6],f2.getIJ(i,6),13);
04568             self.assertAlmostEqual(expected1[7],f2.getIJ(i,7),13);
04569             self.assertAlmostEqual(expected1[8],f2.getIJ(i,8),13);
04570             pass
04571         #
04572         array=DataArrayDouble.New();
04573         arr3=[7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5, 7.8,8.9,9.1,10.2,23.4,34.5]
04574         array.setValues(arr3,mesh1.getNumberOfCells(),6);
04575         f1.setArray(array);
04576         f1.checkCoherency();
04577         #
04578         f2=f1.inverse();
04579         f2.checkCoherency();
04580         self.assertEqual(6,f2.getNumberOfComponents());
04581         self.assertEqual(5,f2.getNumberOfTuples());
04582         expected3=[-0.3617705098531818, -0.8678630828458127, -0.026843764174972983, 0.5539957431465833, 0.13133439560823013, -0.05301294502145887]
04583         for i in xrange(5):
04584             self.assertAlmostEqual(expected3[0],f2.getIJ(i,0),13);
04585             self.assertAlmostEqual(expected3[1],f2.getIJ(i,1),13);
04586             self.assertAlmostEqual(expected3[2],f2.getIJ(i,2),13);
04587             self.assertAlmostEqual(expected3[3],f2.getIJ(i,3),13);
04588             self.assertAlmostEqual(expected3[4],f2.getIJ(i,4),13);
04589             self.assertAlmostEqual(expected3[5],f2.getIJ(i,5),13);
04590             pass
04591         #
04592         array=DataArrayDouble.New();
04593         arr2=[1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5, 1.2,2.3,3.4,4.5]
04594         array.setValues(arr2,mesh1.getNumberOfCells(),4);
04595         f1.setArray(array);
04596         f1.checkCoherency();
04597         #
04598         f2=f1.inverse();
04599         f2.checkCoherency();
04600         self.assertEqual(4,f2.getNumberOfComponents());
04601         self.assertEqual(5,f2.getNumberOfTuples());
04602         expected2=[-1.8595041322314059, 0.9504132231404963, 1.404958677685951, -0.49586776859504156]
04603         for i in xrange(5):
04604             self.assertAlmostEqual(expected2[0],f2.getIJ(i,0),13);
04605             self.assertAlmostEqual(expected2[1],f2.getIJ(i,1),13);
04606             self.assertAlmostEqual(expected2[2],f2.getIJ(i,2),13);
04607             self.assertAlmostEqual(expected2[3],f2.getIJ(i,3),13);
04608             pass
04609         #
04610         pass

Here is the call graph for this function:

Definition at line 3556 of file MEDCouplingBasicsTest.py.

03556 
03557     def testIsEqualWithoutConsideringStr1(self):
03558         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03559         mesh2=MEDCouplingDataForTest.build2DTargetMesh_1();
03560         #
03561         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
03562         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03563         mesh2.setName("rr");
03564         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
03565         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03566         da1,da2=mesh1.checkGeoEquivalWith(mesh2,2,1e-12);
03567         self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);
03568         mesh2.setName("");
03569         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
03570         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03571         mesh2.getCoords().setInfoOnComponent(0,"tty");
03572         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
03573         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03574         mesh2.getCoords().setInfoOnComponent(0,"");
03575         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
03576         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03577         mesh2.getCoords().setInfoOnComponent(1,"tty");
03578         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
03579         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03580         mesh2.getCoords().setInfoOnComponent(1,"");
03581         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
03582         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03583         tmp=mesh2.getCoords().getIJ(0,3);
03584         mesh2.getCoords().setIJ(0,3,9999.);
03585         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
03586         self.assertTrue(not mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03587         mesh2.getCoords().setIJ(0,3,tmp);
03588         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
03589         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03590         tmp2=mesh2.getNodalConnectivity().getIJ(0,4);
03591         mesh2.getNodalConnectivity().setIJ(0,4,0);
03592         self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
03593         self.assertTrue(not mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03594         mesh2.getNodalConnectivity().setIJ(0,4,tmp2);
03595         self.assertTrue(mesh1.isEqual(mesh2,1e-12));
03596         self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
03597         #
03598         f1=mesh1.getMeasureField(True);
03599         f2=mesh2.getMeasureField(True);
03600         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
03601         self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12));
03602         f2.setName("ftest");
03603         self.assertTrue(not f1.isEqual(f2,1e-12,1e-12));
03604         self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12));
03605         f1.setName("ftest");
03606         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
03607         self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12));
03608         #
03609         f2.getArray().setInfoOnComponent(0,"eee");
03610         self.assertTrue(not f1.isEqual(f2,1e-12,1e-12));
03611         self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12));
03612         f2.getArray().setInfoOnComponent(0,"");
03613         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
03614         self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12));
03615         #
03616         f2.getArray().setIJ(1,0,0.123);
03617         self.assertTrue(not f1.isEqual(f2,1e-12,1e-12));
03618         self.assertTrue(not f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12));
03619         f2.getArray().setIJ(1,0,0.125);
03620         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
03621         self.assertTrue(f1.isEqualWithoutConsideringStr(f2,1e-12,1e-12));
03622         #
03623         pass
    

Definition at line 4790 of file MEDCouplingBasicsTest.py.

04790 
04791     def testKeepSetSelectedComponent1(self):
04792         arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.]
04793         a1=DataArrayDouble.New();
04794         a1.setValues(arr1,5,4);
04795         expp=[21.,22.,23.,24.]
04796         self.assertEqual(4,len(a1.getTuple(2)));
04797         for i in xrange(4):
04798             self.assertAlmostEqual(expp[i],a1.getTuple(2)[i],12)
04799             pass
04800         a1.setInfoOnComponent(0,"aaaa");
04801         a1.setInfoOnComponent(1,"bbbb");
04802         a1.setInfoOnComponent(2,"cccc");
04803         a1.setInfoOnComponent(3,"dddd");
04804         arr2V=[1,2,1,2,0,0]
04805         a2=a1.keepSelectedComponents(arr2V);
04806         self.assertEqual(6,a2.getNumberOfComponents());
04807         self.assertEqual(5,a2.getNumberOfTuples());
04808         self.assertTrue(a2.getInfoOnComponent(0)=="bbbb");
04809         self.assertTrue(a2.getInfoOnComponent(1)=="cccc");
04810         self.assertTrue(a2.getInfoOnComponent(2)=="bbbb");
04811         self.assertTrue(a2.getInfoOnComponent(3)=="cccc");
04812         self.assertTrue(a2.getInfoOnComponent(4)=="aaaa");
04813         self.assertTrue(a2.getInfoOnComponent(5)=="aaaa");
04814         expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.]
04815         for i in xrange(30):
04816             self.assertAlmostEqual(expected1[i],a2.getIJ(0,i),14);
04817             pass
04818         a3=a1.convertToIntArr();
04819         self.assertEqual([21,22,23,24],a3.getTuple(2))
04820         a4=a3.keepSelectedComponents(arr2V);
04821         self.assertEqual(6,a4.getNumberOfComponents());
04822         self.assertEqual(5,a4.getNumberOfTuples());
04823         self.assertTrue(a4.getInfoOnComponent(0)=="bbbb");
04824         self.assertTrue(a4.getInfoOnComponent(1)=="cccc");
04825         self.assertTrue(a4.getInfoOnComponent(2)=="bbbb");
04826         self.assertTrue(a4.getInfoOnComponent(3)=="cccc");
04827         self.assertTrue(a4.getInfoOnComponent(4)=="aaaa");
04828         self.assertTrue(a4.getInfoOnComponent(5)=="aaaa");
04829         for i in xrange(30):
04830             self.assertEqual(int(expected1[i]),a4.getIJ(0,i));
04831             pass
04832         # setSelectedComponents
04833         arr3V=[3,2]
04834         a5=a1.keepSelectedComponents(arr3V);
04835         a5.setInfoOnComponent(0,"eeee");
04836         a5.setInfoOnComponent(1,"ffff");
04837         arr4V=[1,2]
04838         a2.setSelectedComponents(a5,arr4V);
04839         self.assertEqual(6,a2.getNumberOfComponents());
04840         self.assertEqual(5,a2.getNumberOfTuples());
04841         self.assertTrue(a2.getInfoOnComponent(0)=="bbbb");
04842         self.assertTrue(a2.getInfoOnComponent(1)=="eeee");
04843         self.assertTrue(a2.getInfoOnComponent(2)=="ffff");
04844         self.assertTrue(a2.getInfoOnComponent(3)=="cccc");
04845         self.assertTrue(a2.getInfoOnComponent(4)=="aaaa");
04846         self.assertTrue(a2.getInfoOnComponent(5)=="aaaa");
04847         expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.]
04848         for i in xrange(30):
04849             self.assertAlmostEqual(expected2[i],a2.getIJ(0,i),14);
04850             pass
04851         a6=a5.convertToIntArr();
04852         a6.setInfoOnComponent(0,"eeee");
04853         a6.setInfoOnComponent(1,"ffff");
04854         a4.setSelectedComponents(a6,arr4V);
04855         self.assertEqual(6,a4.getNumberOfComponents());
04856         self.assertEqual(5,a4.getNumberOfTuples());
04857         self.assertTrue(a4.getInfoOnComponent(0)=="bbbb");
04858         self.assertTrue(a4.getInfoOnComponent(1)=="eeee");
04859         self.assertTrue(a4.getInfoOnComponent(2)=="ffff");
04860         self.assertTrue(a4.getInfoOnComponent(3)=="cccc");
04861         self.assertTrue(a4.getInfoOnComponent(4)=="aaaa");
04862         self.assertTrue(a4.getInfoOnComponent(5)=="aaaa");
04863         for i in xrange(30):
04864             self.assertEqual(int(expected2[i]),a4.getIJ(0,i));
04865             pass
04866         # test of throw
04867         arr5V=[2,3,6]
04868         arr6V=[2,7,5]
04869         arr7V=[2,1,4,6]
04870         self.assertRaises(InterpKernelException,a2.keepSelectedComponents,arr5V);
04871         self.assertRaises(InterpKernelException,a2.keepSelectedComponents,arr6V);
04872         self.assertRaises(InterpKernelException,a2.setSelectedComponents,a1,arr7V);
04873         arr7V=arr7V[0:3]
04874         self.assertRaises(InterpKernelException,a2.setSelectedComponents,a1,arr7V);
04875         #
04876         pass

Definition at line 4877 of file MEDCouplingBasicsTest.py.

04877 
04878     def testKeepSetSelectedComponent2(self):
04879         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
04880         arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.]
04881         a1=DataArrayDouble.New();
04882         a1.setValues(arr1,5,4);
04883         a1.setInfoOnComponent(0,"aaaa");
04884         a1.setInfoOnComponent(1,"bbbb");
04885         a1.setInfoOnComponent(2,"cccc");
04886         a1.setInfoOnComponent(3,"dddd");
04887         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
04888         f1.setTime(2.3,4,5);
04889         f1.setMesh(m1);
04890         f1.setName("f1");
04891         f1.setArray(a1);
04892         f1.checkCoherency();
04893         #
04894         arr2V=[1,2,1,2,0,0]
04895         f2=f1.keepSelectedComponents(arr2V);
04896         self.assertTrue(f2.getTimeDiscretization()==ONE_TIME);
04897         t,dt,it=f2.getTime()
04898         self.assertAlmostEqual(2.3,t,13);
04899         self.assertEqual(4,dt);
04900         self.assertEqual(5,it);
04901         f2.checkCoherency();
04902         self.assertEqual(6,f2.getNumberOfComponents());
04903         self.assertEqual(5,f2.getNumberOfTuples());
04904         self.assertTrue(f2.getArray().getInfoOnComponent(0)=="bbbb");
04905         self.assertTrue(f2.getArray().getInfoOnComponent(1)=="cccc");
04906         self.assertTrue(f2.getArray().getInfoOnComponent(2)=="bbbb");
04907         self.assertTrue(f2.getArray().getInfoOnComponent(3)=="cccc");
04908         self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa");
04909         self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa");
04910         expected1=[2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.]
04911         for i in xrange(30):
04912             self.assertAlmostEqual(expected1[i],f2.getIJ(0,i),14);
04913             pass
04914         #setSelectedComponents
04915         arr3V=[3,2]
04916         f5=f1.keepSelectedComponents(arr3V);
04917         f5.setTime(6.7,8,9);
04918         f5.getArray().setInfoOnComponent(0,"eeee");
04919         f5.getArray().setInfoOnComponent(1,"ffff");
04920         f5.checkCoherency();
04921         arr4V=[1,2]
04922         f2.setSelectedComponents(f5,arr4V);
04923         self.assertEqual(6,f2.getNumberOfComponents());
04924         self.assertEqual(5,f2.getNumberOfTuples());
04925         f2.checkCoherency();
04926         t,dt,it=f2.getTime()
04927         self.assertAlmostEqual(2.3,t,13);
04928         self.assertEqual(4,dt);
04929         self.assertEqual(5,it);
04930         self.assertTrue(f2.getArray().getInfoOnComponent(0)=="bbbb");
04931         self.assertTrue(f2.getArray().getInfoOnComponent(1)=="eeee");
04932         self.assertTrue(f2.getArray().getInfoOnComponent(2)=="ffff");
04933         self.assertTrue(f2.getArray().getInfoOnComponent(3)=="cccc");
04934         self.assertTrue(f2.getArray().getInfoOnComponent(4)=="aaaa");
04935         self.assertTrue(f2.getArray().getInfoOnComponent(5)=="aaaa");
04936         expected2=[2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.]
04937         for i in xrange(30):
04938             self.assertAlmostEqual(expected2[i],f2.getIJ(0,i),14);
04939             pass
04940         #
04941         pass
    

Definition at line 3451 of file MEDCouplingBasicsTest.py.

03451 
03452     def testMagnitude1(self):
03453         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03454         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03455         f1.setMesh(mesh1);
03456         array=DataArrayDouble.New();
03457         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6]
03458         array.setValues(arr1,mesh1.getNumberOfCells(),5);
03459         f1.setArray(array);
03460         f1.checkCoherency();
03461         #
03462         f2=f1.magnitude();
03463         f2.checkCoherency();
03464         self.assertEqual(1,f2.getNumberOfComponents());
03465         self.assertEqual(5,f2.getNumberOfTuples());
03466         for i in xrange(5):
03467             self.assertAlmostEqual(8.3606219864313918,f2.getIJ(i,0),13);
03468             pass
03469         #
03470         pass

Here is the caller graph for this function:

Definition at line 4685 of file MEDCouplingBasicsTest.py.

04685 
04686     def testMagnitude1(self):
04687         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04688         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04689         f1.setMesh(mesh1);
04690         array=DataArrayDouble.New();
04691         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6, 1.2,2.3,3.4,4.5,5.6]
04692         array.setValues(arr1,mesh1.getNumberOfCells(),5);
04693         f1.setArray(array);
04694         f1.checkCoherency();
04695         #
04696         f2=f1.magnitude();
04697         f2.checkCoherency();
04698         self.assertEqual(1,f2.getNumberOfComponents());
04699         self.assertEqual(5,f2.getNumberOfTuples());
04700         for i in xrange(5):
04701             self.assertAlmostEqual(8.3606219864313918,f2.getIJ(i,0),13);
04702             pass
04703         #
04704         pass

Here is the call graph for this function:

Definition at line 3471 of file MEDCouplingBasicsTest.py.

03471 
03472     def testMaxPerTuple1(self):
03473         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03474         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03475         f1.setMesh(mesh1);
03476         array=DataArrayDouble.New();
03477         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4]
03478         array.setValues(arr1,mesh1.getNumberOfCells(),5);
03479         f1.setArray(array);
03480         f1.checkCoherency();
03481         #
03482         f2=f1.maxPerTuple();
03483         f2.checkCoherency();
03484         self.assertEqual(1,f2.getNumberOfComponents());
03485         self.assertEqual(5,f2.getNumberOfTuples());
03486         for i in xrange(5):
03487             self.assertAlmostEqual(5.6,f2.getIJ(i,0),13);
03488             pass
03489         #
03490         pass

Here is the caller graph for this function:

Definition at line 4705 of file MEDCouplingBasicsTest.py.

04705 
04706     def testMaxPerTuple1(self):
04707         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04708         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04709         f1.setMesh(mesh1);
04710         array=DataArrayDouble.New();
04711         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4]
04712         array.setValues(arr1,mesh1.getNumberOfCells(),5);
04713         f1.setArray(array);
04714         f1.checkCoherency();
04715         #
04716         f2=f1.maxPerTuple();
04717         f2.checkCoherency();
04718         self.assertEqual(1,f2.getNumberOfComponents());
04719         self.assertEqual(5,f2.getNumberOfTuples());
04720         for i in xrange(5):
04721             self.assertAlmostEqual(5.6,f2.getIJ(i,0),13);
04722             pass
04723         #
04724         pass

Here is the call graph for this function:

Definition at line 941 of file MEDCouplingBasicsTest.py.

00941 
00942     def testMergeField1(self):
00943         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
00944         m2=MEDCouplingDataForTest.build2DSourceMesh_1();
00945         vec=[1.,0.]
00946         m2.translate(vec);
00947         f1=m1.getMeasureField(True);
00948         f2=m2.getMeasureField(True);
00949         f3=MEDCouplingFieldDouble.MergeFields(f1,f2);
00950         f3.checkCoherency();
00951         m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1();
00952         self.assertTrue(f3.getMesh().isEqual(m4,1.e-12));
00953         name=f3.getName();
00954         self.assertEqual(name,"MeasureOfMesh_");
00955         self.assertEqual(f3.getTypeOfField(),ON_CELLS);
00956         self.assertEqual(f3.getTimeDiscretization(),NO_TIME);
00957         self.assertEqual(1,f3.getNumberOfComponents());
00958         self.assertEqual(7,f3.getNumberOfTuples());
00959         values=[0.25,0.125,0.125,0.25,0.25,0.5,0.5]
00960         tmp=f3.getArray().getValues();
00961         self.assertEqual(len(values),len(tmp))
00962         for i in xrange(7):
00963             self.assertTrue(abs(values[i]-tmp[i])<1e-12)
00964             pass
00965         pass

Definition at line 5750 of file MEDCouplingBasicsTest.py.

05750 
05751     def testMergeField2(self):
05752         m=MEDCouplingDataForTest.build2DTargetMesh_1();
05753         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
05754         f1.setMesh(m);
05755         arr=DataArrayDouble.New();
05756         arr.alloc(5,2);
05757         arr.fillWithValue(2.);
05758         f1.setArray(arr);
05759         f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
05760         f2.setMesh(m);
05761         arr=DataArrayDouble.New();
05762         arr.alloc(5,2);
05763         arr.fillWithValue(5.);
05764         f2.setArray(arr);
05765         f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
05766         f3.setMesh(m);
05767         arr=DataArrayDouble.New();
05768         arr.alloc(5,2);
05769         arr.fillWithValue(7.);
05770         f3.setArray(arr);
05771         #
05772         f4=MEDCouplingFieldDouble.MergeFields([f1,f2,f3]);
05773         self.assertEqual(15,f4.getMesh().getNumberOfCells());
05774         expected1=[2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.]
05775         for i in xrange(30):
05776             self.assertAlmostEqual(expected1[i],f4.getIJ(0,i),13);
05777             pass
05778         #
05779         pass

Definition at line 8208 of file MEDCouplingBasicsTest.py.

08208 
08209     def testMergeField3(self):
08210         m=MEDCouplingDataForTest.build2DTargetMesh_1();
08211         m.getCoords().setInfoOnComponent(0,"x [m]");
08212         m.getCoords().setInfoOnComponent(1,"z [km]");
08213         m.setName("m");
08214         m.setDescription("desc");
08215         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
08216         f1.setName("f1");
08217         f1.setMesh(m);
08218         arr=DataArrayDouble.New();
08219         arr.alloc(5,2);
08220         arr.setInfoOnComponent(0,"X [m]");
08221         arr.setInfoOnComponent(1,"YY [mm]");
08222         arr.fillWithValue(2.);
08223         f1.setArray(arr);
08224         #
08225         f2=MEDCouplingFieldDouble.MergeFields([f1]);
08226         self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
08227         #
08228         pass
    

Definition at line 900 of file MEDCouplingBasicsTest.py.

00900 
00901     def testMergeMesh1(self):
00902         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
00903         m2=MEDCouplingDataForTest.build2DSourceMesh_1();
00904         vec=[1.,0.]
00905         m2.translate(vec);
00906         m3=m1.mergeMyselfWith(m2);
00907         self.assertTrue(isinstance(m3,MEDCouplingUMesh));
00908         m3.checkCoherency();
00909         m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1();
00910         self.assertTrue(m3.isEqual(m4,1.e-12));
00911         da,isMerged,newNbOfNodes=m3.mergeNodes(1.e-12);
00912         self.assertEqual(11,m3.getNumberOfNodes());
00913         self.assertTrue(isMerged);
00914         pass

Definition at line 915 of file MEDCouplingBasicsTest.py.

00915 
00916     def testMergeMeshOnSameCoords1(self):
00917         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
00918         m2=MEDCouplingDataForTest.build2DTargetMesh_1();
00919         cells=range(5);
00920         m2.convertToPolyTypes(cells);
00921         m1.tryToShareSameCoords(m2,1e-12);
00922         m3=MEDCouplingDataForTest.build2DTargetMesh_1();
00923         m3.tryToShareSameCoords(m2,1e-12);
00924         meshes=[m1,m2,m3]
00925         m4=MEDCouplingUMesh.MergeUMeshesOnSameCoords(meshes);
00926         m4.checkCoherency();
00927         self.assertEqual(15,m4.getNumberOfCells());
00928         cells1=[0,1,2,3,4]
00929         m1_1=m4.buildPartOfMySelf(cells1,True);
00930         m1_1.setName(m1.getName());
00931         self.assertTrue(m1.isEqual(m1_1,1e-12));
00932         cells2=[5,6,7,8,9]
00933         m2_1=m4.buildPartOfMySelf(cells2,True);
00934         m2_1.setName(m2.getName());
00935         self.assertTrue(m2.isEqual(m2_1,1e-12));
00936         cells3=[10,11,12,13,14]
00937         m3_1=m4.buildPartOfMySelf(cells3,True);
00938         m3_1.setName(m3.getName());
00939         self.assertTrue(m3.isEqual(m3_1,1e-12));
00940         pass

Definition at line 5734 of file MEDCouplingBasicsTest.py.

05734 
05735     def testMergeNodes2(self):
05736         m1=MEDCouplingDataForTest.build2DTargetMesh_1();
05737         m2=MEDCouplingDataForTest.build2DTargetMesh_1();
05738         vec=[0.002,0.]
05739         m2.translate(vec);
05740         #
05741         m3=MEDCouplingUMesh.MergeUMeshes([m1,m2]);
05742         da,b,newNbOfNodes=m3.mergeNodes2(0.01);
05743         self.assertEqual(9,m3.getNumberOfNodes());
05744         expected1=[-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7]
05745         for i in xrange(18):
05746             self.assertAlmostEqual(expected1[i],m3.getCoords().getIJ(0,i),13);
05747             pass
05748         #
05749         pass

Definition at line 1371 of file MEDCouplingBasicsTest.py.

01371 
01372     def testMergeNodesOnField(self):
01373         targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1();
01374         f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z");
01375         f1.mergeNodes(1e-10);
01376         #
01377         targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1();
01378         f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z");
01379         tmp=f1.getArray()
01380         tmp.setIJ(0,0,1000.);
01381         f1.mergeNodes(1e-10);
01382         #
01383         targetMesh=MEDCouplingDataForTest.build3DTargetMeshMergeNode_1();
01384         f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z");
01385         tmp=f1.getArray()
01386         tmp.setIJ(1,0,1000.);
01387         self.assertRaises(InterpKernelException,f1.mergeNodes,1.e-10)
01388         pass

Definition at line 6932 of file MEDCouplingBasicsTest.py.

06932 
06933     def testMergeUMeshes2(self):
06934         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
06935         m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
06936         m3=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
06937         #
06938         vec1=[0,2,3]
06939         m2_2=m2.buildPartOfMySelf(vec1,False);
06940         vec2=[1,1]
06941         m3_2=m3.buildPartOfMySelf(vec2,False);
06942         #
06943         ms=[m1,m2_2,m3_2];
06944         #
06945         self.assertRaises(InterpKernelException,MEDCouplingUMesh.MergeUMeshes,ms+[None]);
06946         self.assertRaises(InterpKernelException,MEDCouplingUMesh.MergeUMeshes,ms+[3.4])
06947         m4=MEDCouplingUMesh.MergeUMeshes(ms);
06948         m4.checkCoherency();
06949         self.assertEqual(10,m4.getNumberOfCells());
06950         self.assertEqual(20,m4.getNumberOfNodes());
06951         self.assertEqual(45,m4.getMeshLength());
06952         m4bis=MEDCouplingMesh.MergeMeshes(ms);
06953         self.assertTrue(m4.isEqual(m4bis,1e-12))
06954         del m4bis
06955         #
06956         vec3=[0,1,2,3,4]
06957         m4_1=m4.buildPartOfMySelf(vec3,False);
06958         m4_1.setName(m1.getName());
06959         self.assertTrue(m4_1.isEqual(m1,1e-12));
06960         #
06961         vec4=[5,6,7]
06962         m4_2=m4.buildPartOfMySelf(vec4,False);
06963         cellCor,nodeCor=m4_2.checkGeoEquivalWith(m2_2,10,1e-12);
06964         #
06965         vec5=[8,9]
06966         m4_3=m4.buildPartOfMySelf(vec5,False);
06967         self.assertEqual(2,m4_3.getNumberOfCells());
06968         self.assertEqual(3,m4_3.getNumberOfNodes());
06969         m3_2.zipCoords();
06970         m4_3.setName(m3_2.getName());
06971         self.assertTrue(m4_3.isEqual(m3_2,1e-12));
06972         #
06973         pass

Definition at line 80 of file MEDCouplingBasicsTest.py.

00080 
00081     def testMesh(self):
00082         tab4=[1, 2, 8, 7, 2, 3, 9, 8, 3,
00083               4, 10, 9, 4, 5, 11, 10, 5,
00084               0, 6, 11, 0, 1, 7, 6 ]
00085         nbOfNodes=12
00086         nbOfCells=6
00087         coords=[ 0.024155, 0.04183768725682622, -0.305, 0.04831000000000001, -1.015761910347357e-17,
00088                  -0.305, 0.09662000000000001, -1.832979297858306e-18, -0.305, 0.120775, 0.04183768725682623,
00089                  -0.305, 0.09662000000000001, 0.08367537451365245, -0.305, 0.04831000000000001, 0.08367537451365246,
00090                  -0.305, 0.024155, 0.04183768725682622, -0.2863, 0.04831000000000001, -1.015761910347357e-17, -0.2863, 
00091                  0.09662000000000001, -1.832979297858306e-18, -0.2863, 0.120775, 0.04183768725682623, -0.2863, 0.09662000000000001,
00092                  0.08367537451365245, -0.2863, 0.04831000000000001, 0.08367537451365246, -0.2863 ]
00093         mesh=MEDCouplingUMesh.New()
00094         mesh.setMeshDimension(2)
00095         mesh.allocateCells(8);
00096         mesh.setName("mesh1")
00097         self.assertTrue(mesh.getName()=="mesh1")
00098         for i in range(nbOfCells):
00099             mesh.insertNextCell(NORM_QUAD4,4,tab4[4*i:4*(i+1)]);
00100             pass
00101         mesh.finishInsertingCells()
00102         self.assertTrue(mesh.getNumberOfCells()==nbOfCells)
00103         self.assertTrue(mesh.getNodalConnectivity().getNbOfElems()==30)
00104         self.assertTrue(mesh.getNodalConnectivityIndex().getNbOfElems()==nbOfCells+1)
00105         myCoords=DataArrayDouble.New()
00106         myCoords.setValues(coords,nbOfNodes,3);
00107         self.assertTrue(myCoords.getIJ(3,2)==-0.305)
00108         mesh.setCoords(myCoords);
00109         mesh.checkCoherency();
00110         self.assertTrue(mesh.getAllTypes()==[4])
00111         myFalseConn=DataArrayInt.New()
00112         myFalseConn.setValues(tab4,6,4)
00113         self.assertTrue(myFalseConn.getIJ(1,1)==3)
00114         #
00115         field=MEDCouplingFieldDouble.New(ON_CELLS)
00116         field.setMesh(mesh)
00117         field.setNature(Integral)
00118         myCoords=DataArrayDouble.New()
00119         sampleTab=[]
00120         for i in range(nbOfCells*9):
00121             sampleTab.append(float(i))
00122         myCoords.setValues(sampleTab,nbOfCells,9);
00123         field.setArray(myCoords)
00124         self.assertTrue(3==mesh.getSpaceDimension())
00125         field.checkCoherency()
00126         mesh2=mesh.clone(False)
00127         mesh3=mesh.clone(True)
00128         mesh3=0
00129         mesh2=0
00130         ## deep full recursively copy of field -> both field and mesh underneath copied
00131         field2=field.clone(True)
00132         field2.setMesh(field.getMesh().clone(True))
00133         mesh3=mesh.clone(True)
00134         field3=mesh3.fillFromAnalytic(ON_CELLS,2,"x*IVec+(y+z)*JVec")
00135         field3.applyFunc("u*u*u+cos(u)")
00136         pass
        

Definition at line 161 of file MEDCouplingBasicsTest.py.

00161 
00162     def testMeshM1D(self):
00163         meshM1D=MEDCouplingUMesh.New();
00164         self.assertRaises(InterpKernelException,meshM1D.getMeshDimension);
00165         self.assertRaises(InterpKernelException,meshM1D.getNumberOfNodes);
00166         self.assertRaises(InterpKernelException,meshM1D.getNumberOfCells);
00167         self.assertRaises(InterpKernelException,meshM1D.setMeshDimension,-2)
00168         self.assertRaises(InterpKernelException,meshM1D.setMeshDimension,-10)
00169         meshM1D.setMeshDimension(-1);
00170         meshM1D.checkCoherency();
00171         self.assertEqual(meshM1D.getMeshDimension(),-1);
00172         self.assertEqual(meshM1D.getNumberOfCells(),1);
00173         self.assertRaises(InterpKernelException,meshM1D.getNumberOfNodes);
00174         self.assertRaises(InterpKernelException,meshM1D.getSpaceDimension);
00175         cpy=meshM1D.clone(True);
00176         self.assertTrue(cpy.isEqual(meshM1D,1e-12));
00177         fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS);
00178         fieldOnCells.setMesh(meshM1D);
00179         array=DataArrayDouble.New();
00180         array.setValues(6*[7.],1,6);
00181         fieldOnCells.setArray(array);
00182         fieldOnCells.checkCoherency();
00183         pass
    

Definition at line 137 of file MEDCouplingBasicsTest.py.

00137 
00138     def testMeshPointsCloud(self):
00139         targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5,
00140                       -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5]
00141         targetMesh=MEDCouplingUMesh.New();
00142         targetMesh.setMeshDimension(0);
00143         targetMesh.allocateCells(8);
00144         targetMesh.insertNextCell(NORM_POINT1,1,[0]);
00145         targetMesh.insertNextCell(NORM_POINT1,1,[1]);
00146         targetMesh.insertNextCell(NORM_POINT1,1,[2]);
00147         targetMesh.insertNextCell(NORM_POINT1,1,[3]);
00148         targetMesh.insertNextCell(NORM_POINT1,1,[4]);
00149         targetMesh.insertNextCell(NORM_POINT1,1,[5]);
00150         targetMesh.insertNextCell(NORM_POINT1,1,[7]);
00151         targetMesh.insertNextCell(NORM_POINT1,1,[6]);
00152         targetMesh.finishInsertingCells();
00153         myCoords=DataArrayDouble.New();
00154         myCoords.setValues(targetCoords,9,3);
00155         targetMesh.setCoords(myCoords);
00156         self.assertEqual(targetMesh.getSpaceDimension(),3)
00157         self.assertEqual(targetMesh.getNumberOfCells(),8)
00158         self.assertEqual(targetMesh.getNumberOfNodes(),9)
00159         self.assertEqual(targetMesh.getMeshDimension(),0)
00160         pass

Definition at line 7169 of file MEDCouplingBasicsTest.py.

07169 
07170     def testMeshSetTime1(self):
07171         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
07172         m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
07173         #
07174         self.assertTrue(m1.isEqual(m2,1e-12));
07175         m1.setTime(3.14,6,7);
07176         tmp3,tmp1,tmp2=m1.getTime();
07177         self.assertEqual(6,tmp1);
07178         self.assertEqual(7,tmp2);
07179         self.assertAlmostEqual(3.14,tmp3,12);
07180         self.assertTrue(not m1.isEqual(m2,1e-12));
07181         m2.setTime(3.14,6,7);
07182         self.assertTrue(m1.isEqual(m2,1e-12));
07183         m1.setTimeUnit("ms");
07184         self.assertTrue(m1.getTimeUnit()=="ms");
07185         m1.setTimeUnit("us");
07186         self.assertTrue(m1.getTimeUnit()=="us");
07187         self.assertTrue(not m1.isEqual(m2,1e-12));
07188         m2.setTimeUnit("us");
07189         self.assertTrue(m1.isEqual(m2,1e-12));
07190         m2.setTime(3.14,6,8);
07191         self.assertTrue(not m1.isEqual(m2,1e-12));
07192         m2.setTime(3.14,7,7);
07193         self.assertTrue(not m1.isEqual(m2,1e-12));
07194         m2.setTime(3.15,6,7);
07195         self.assertTrue(not m1.isEqual(m2,1e-12));
07196         #
07197         m1.setTime(10.34,55,12);
07198         m3=m1.deepCpy();
07199         self.assertTrue(m1.isEqual(m3,1e-12));
07200         tmp3,tmp1,tmp2=m3.getTime();
07201         self.assertEqual(55,tmp1);
07202         self.assertEqual(12,tmp2);
07203         self.assertAlmostEqual(10.34,tmp3,12);
07204         #
07205         # testing CMesh
07206         coo1=[0.,1.,2.,3.5]
07207         a=DataArrayDouble.New();
07208         a.setValues(coo1,4,1);
07209         b=MEDCouplingCMesh.New();
07210         b.setCoordsAt(0,a);
07211         #
07212         b.setTime(5.67,8,100);
07213         tmp3,tmp1,tmp2=b.getTime();
07214         self.assertEqual(8,tmp1);
07215         self.assertEqual(100,tmp2);
07216         self.assertAlmostEqual(5.67,tmp3,12);
07217         c=b.deepCpy();
07218         self.assertTrue(c.isEqual(b,1e-12));
07219         tmp3,tmp1,tmp2=c.getTime();
07220         self.assertEqual(8,tmp1);
07221         self.assertEqual(100,tmp2);
07222         self.assertAlmostEqual(5.67,tmp3,12);
07223         pass

Definition at line 2956 of file MEDCouplingBasicsTest.py.

02956 
02957     def testMinMaxFields1(self):
02958         mesh1=MEDCouplingDataForTest.build2DTargetMesh_3();
02959         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
02960         f1.setTime(2.3,5,6);
02961         f1.setMesh(mesh1);
02962         array=DataArrayDouble.New();
02963         arr1=[7.,107.,207.,8.,108.,208.,9.,109.,209.,10.,110.,210.,11.,111.,211.,12.,112.,212.,13.,113.,213.,14.,114.,214.,15.,115.,215.,16.,116.,216.]
02964         array.setValues(arr1,mesh1.getNumberOfCells(),3);
02965         f1.setArray(array);
02966         f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
02967         f2.setTime(7.8,4,5);
02968         f2.setMesh(mesh1);
02969         array=DataArrayDouble.New();
02970         arr2=[6.,108.,206.,9.,107.,209.,8.,110.,208.,11.,109.,211.,10.,112.,210.,13.,111.,213.,12.,114.,212.,15.,113.,215.,14.,116.,214.,17.,115.,217.]
02971         array.setValues(arr2,mesh1.getNumberOfCells(),3);
02972         f2.setArray(array);
02973         #
02974         f3=f1.max(f2);
02975         expected1=[7.,108.,207.,9.,108.,209.,9.,110.,209.,11.,110.,211.,11.,112.,211.,13.,112.,213.,13.,114.,213.,15.,114.,215.,15.,116.,215.,17.,116.,217.]
02976         for i in xrange(30):
02977             self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),9);
02978             pass
02979         #
02980         f4=f1.min(f2);
02981         expected2=[6.,107.,206.,8.,107.,208.,8.,109.,208.,10.,109.,210.,10.,111.,210.,12.,111.,212.,12.,113.,212.,14.,113.,214.,14.,115.,214.,16.,115.,216.]
02982         for i in xrange(30):
02983             self.assertAlmostEqual(expected2[i],f4.getIJ(0,i),9);
02984             pass
02985         #
02986         pass

Definition at line 7014 of file MEDCouplingBasicsTest.py.

07014 
07015     def testMultiFields1(self):
07016         mfs=MEDCouplingDataForTest.buildMultiFields_1();
07017         ms=mfs.getMeshes();
07018         dms,refs=mfs.getDifferentMeshes()
07019         das=mfs.getArrays();
07020         das2,refs2=mfs.getDifferentArrays()
07021         self.assertEqual(5,len(mfs.getFields()))
07022         self.assertEqual(1,len(mfs.getFields()[0].getArrays()));
07023         self.assertEqual(2,len(mfs.getFields()[1].getArrays()));
07024         self.assertEqual(1,len(mfs.getFields()[2].getArrays()));
07025         self.assertEqual(1,len(mfs.getFields()[3].getArrays()));
07026         self.assertEqual(1,len(mfs.getFields()[4].getArrays()));
07027         self.assertEqual(5,len(ms));
07028         self.assertEqual(2,len(dms));
07029         self.assertEqual(6,len(das));
07030         self.assertEqual(5,len(das2));
07031         mfs2=mfs.deepCpy();
07032         self.assertTrue(mfs.isEqual(mfs2,1e-12,1e-12))
07033         pass

Definition at line 644 of file MEDCouplingBasicsTest.py.

00644 
00645     def testNatureChecking(self):
00646         field=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
00647         field.setNature(Integral);
00648         field.setNature(ConservativeVolumic);
00649         field.setNature(IntegralGlobConstraint);
00650         field=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
00651         field.setNature(ConservativeVolumic);
00652         self.assertRaises(InterpKernelException,field.setNature,Integral);
00653         self.assertRaises(InterpKernelException,field.setNature,IntegralGlobConstraint);
00654         pass

Definition at line 8341 of file MEDCouplingBasicsTest.py.

08341 
08342     def testNonRegressionCopyTinyStrings(self):
08343         m=MEDCouplingDataForTest.build2DTargetMesh_1()
08344         f1=m.getMeasureField(True)
08345         f1.getArray().setInfoOnComponent(0,"P [N/m^2]")
08346         bary=m.getBarycenterAndOwner()
08347         f2=f1.buildNewTimeReprFromThis(ONE_TIME,False)
08348         f2.setArray(bary)
08349         self.assertRaises(InterpKernelException,f2.copyTinyAttrFrom,f1)
08350         pass

Definition at line 8244 of file MEDCouplingBasicsTest.py.

08244 
08245     def testNorm2_1(self):
08246         m=MEDCouplingDataForTest.build2DTargetMesh_1();
08247         f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
08248         f.setMesh(m);
08249         #
08250         d=DataArrayDouble.New();
08251         tab=[1.2,1.3,2.2,2.3,3.2,3.3,4.2,4.3,5.2,5.3]
08252         d.setValues(tab,5,2);
08253         f.setArray(d);
08254         f.checkCoherency();
08255         #
08256         self.assertAlmostEqual(11.209371079592289,f.norm2(),14);
08257         #
08258         pass

Definition at line 2214 of file MEDCouplingBasicsTest.py.

02214 
02215     def testNormL12Integ1D(self):
02216         m1=MEDCouplingDataForTest.build1DTargetMesh_3();
02217         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
02218         f1.setMesh(m1);
02219         array=DataArrayDouble.New();
02220         arr=[-5.23,15.45,-25.56,6.67,-16.78,26.89,-7.91,17.23,-27.43,8.21,-18.63,28.72]
02221         array.setValues(arr,m1.getNumberOfCells(),3);
02222         f1.setArray(array);
02223         #
02224         f3=m1.getBarycenterAndOwner();
02225         self.assertEqual(4,f3.getNumberOfTuples());
02226         self.assertEqual(1,f3.getNumberOfComponents());
02227         expected9=[0.75,5.105,0.8,5.155]
02228         ptr=f3.getValues();
02229         for i in xrange(4):
02230             self.assertTrue(abs(expected9[i]-ptr[i])<1e-12);
02231             pass
02232         #
02233         f2=m1.getMeasureField(False);
02234         self.assertEqual(4,f2.getArray().getNumberOfTuples());
02235         self.assertEqual(1,f2.getNumberOfComponents());
02236         expected1=[0.5,0.21,-0.6,-0.31]
02237         ptr=f2.getArray().getValues();
02238         for i in xrange(4):
02239             self.assertTrue(abs(expected1[i]-ptr[i])<1e-12);
02240             pass
02241         expected2=[0.5,0.21,0.6,0.31]
02242         f2=m1.getMeasureField(True);
02243         ptr=f2.getArray().getValues();
02244         for i in xrange(4):
02245             self.assertTrue(abs(expected2[i]-ptr[i])<1e-12);
02246             pass
02247         #integral
02248         self.assertTrue(4,f1.getNumberOfTuples())
02249         res=f1.integral(False);
02250         self.assertTrue(3,len(res))
02251         expected3=[0.9866,-0.3615,0.4217]
02252         for i in xrange(3):
02253             self.assertTrue(abs(expected3[i]-res[i])<1e-12);
02254             pass
02255         self.assertTrue(abs(expected3[0]-f1.integral(0,False))<1e-12);
02256         self.assertTrue(abs(expected3[1]-f1.integral(1,False))<1e-12);
02257         self.assertTrue(abs(expected3[2]-f1.integral(2,False))<1e-12);
02258         res=f1.integral(True);
02259         expected4=[-3.4152,8.7639,-14.6879]
02260         for i in xrange(3):
02261             self.assertTrue(abs(expected4[i]-res[i])<1e-12);
02262             pass
02263         #normL1
02264         res=f1.normL1();
02265         self.assertTrue(3,len(res))
02266         expected5=[6.979506172839505, 16.89018518518518, 27.02969135802469]
02267         for i in xrange(3):
02268             self.assertTrue(abs(expected5[i]-res[i])<1e-12);
02269             pass
02270         self.assertTrue(abs(expected5[0]-f1.normL1(0))<1e-12);
02271         self.assertTrue(abs(expected5[1]-f1.normL1(1))<1e-12);
02272         self.assertTrue(abs(expected5[2]-f1.normL1(2))<1e-12);
02273         #normL2
02274         res=f1.normL2();
02275         self.assertTrue(3,len(res))
02276         expected7=[7.090910979452395, 16.9275542960123, 27.053271464160858]
02277         for i in xrange(3):
02278             self.assertTrue(abs(expected7[i]-res[i])<1e-9);
02279             pass
02280         self.assertTrue(abs(expected7[0]-f1.normL2(0))<1e-9);
02281         self.assertTrue(abs(expected7[1]-f1.normL2(1))<1e-9);
02282         self.assertTrue(abs(expected7[2]-f1.normL2(2))<1e-9);
02283         #buildMeasureField
02284         f4=f1.buildMeasureField(False);
02285         self.assertTrue(abs(-0.2-f4.accumulate(0))<1e-12);
02286         f4=f1.buildMeasureField(True);
02287         self.assertTrue(abs(1.62-f4.accumulate(0))<1e-12);
02288         # Testing with 2D Curve
02289         m1=MEDCouplingDataForTest.build2DCurveTargetMesh_3();
02290         f2=m1.getMeasureField(False);
02291         self.assertEqual(4,f2.getArray().getNumberOfTuples());
02292         self.assertEqual(1,f2.getNumberOfComponents());
02293         ptr=f2.getArray().getValues();
02294         for i in xrange(4):
02295             self.assertTrue(abs(sqrt(2.)*expected2[i]-ptr[i])<1e-12);
02296             pass
02297         f2=m1.getMeasureField(True);
02298         self.assertEqual(4,f2.getArray().getNumberOfTuples());
02299         self.assertEqual(1,f2.getNumberOfComponents());
02300         ptr=f2.getArray().getValues();
02301         for i in xrange(4):
02302             self.assertTrue(abs(expected2[i]*sqrt(2.)-ptr[i])<1e-12);
02303             pass
02304         #bary
02305         f3=m1.getBarycenterAndOwner();
02306         self.assertEqual(4,f3.getNumberOfTuples());
02307         self.assertEqual(2,f3.getNumberOfComponents());
02308         expected10=[0.75,0.75,5.105,5.105,0.8,0.8,5.155,5.155]
02309         ptr=f3.getValues();
02310         for i in xrange(8):
02311             self.assertTrue(abs(expected10[i]-ptr[i])<1e-12);
02312             pass
02313         #
02314         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
02315         f1.setMesh(m1);
02316         array=DataArrayDouble.New();
02317         array.setValues(arr,m1.getNumberOfCells(),3);
02318         f1.setArray(array);
02319         res=f1.integral(False);
02320         for i in xrange(3):
02321             self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12);
02322             pass
02323         res=f1.integral(True);
02324         for i in xrange(3):
02325             self.assertTrue(abs(sqrt(2.)*expected4[i]-res[i])<1e-12);
02326             pass
02327         res=f1.normL1();
02328         for i in xrange(3):
02329             self.assertTrue(abs(expected5[i]-res[i])<1e-12);
02330             pass
02331         res=f1.normL2();
02332         for i in xrange(3):
02333             self.assertTrue(abs(expected7[i]-res[i])<1e-12);
02334             pass
02335         pass

Definition at line 8259 of file MEDCouplingBasicsTest.py.

08259 
08260     def testNormMax1(self):
08261         m=MEDCouplingDataForTest.build2DTargetMesh_1();
08262         f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
08263         f.setMesh(m);
08264         #
08265         d=DataArrayDouble.New();
08266         tab=[2.3,-1.2,6.3,-7.8,2.9,7.7,2.1,0.,3.6,-7.6]
08267         d.setValues(tab,5,2);
08268         f.setArray(d);
08269         f.checkCoherency();
08270         #
08271         self.assertAlmostEqual(7.8,f.normMax(),14);
08272         #
08273         pass

Definition at line 1141 of file MEDCouplingBasicsTest.py.

01141 
01142     def testOperationsOnFields(self):
01143         m=MEDCouplingDataForTest.build2DTargetMesh_1();
01144         f1=m.fillFromAnalytic(ON_NODES,1,"x+y");
01145         f2=m.fillFromAnalytic(ON_NODES,1,"x+y");
01146         f1.checkCoherency();
01147         f2.checkCoherency();
01148         f3=f1+f2;
01149         f3.checkCoherency();
01150         self.assertEqual(f3.getTypeOfField(),ON_NODES);
01151         self.assertEqual(f3.getTimeDiscretization(),NO_TIME);
01152         values1=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8]
01153         tmp=f3.getArray().getValues();
01154         self.assertEqual(len(values1),len(tmp))
01155         for i in xrange(len(tmp)):
01156             self.assertTrue(abs(tmp[i]-values1[i])<1.e-12)
01157             pass
01158         #
01159         f3=f1*f2;
01160         f3.checkCoherency();
01161         self.assertEqual(f3.getTypeOfField(),ON_NODES);
01162         self.assertEqual(f3.getTimeDiscretization(),NO_TIME);
01163         values2=[0.36,0.01,0.16,0.01,0.16,0.81,0.16,0.81,1.96]
01164         tmp=f3.getArray().getValues();
01165         self.assertEqual(len(values2),len(tmp))
01166         for i in xrange(len(tmp)):
01167             self.assertTrue(abs(tmp[i]-values2[i])<1.e-12)
01168             pass
01169         #
01170         f3=f1+f2;
01171         f4=f1-f3;
01172         f4.checkCoherency();
01173         self.assertEqual(f4.getTypeOfField(),ON_NODES);
01174         self.assertEqual(f4.getTimeDiscretization(),NO_TIME);
01175         values3=[0.6,0.1,-0.4,0.1,-0.4,-0.9,-0.4,-0.9,-1.4]
01176         tmp=f4.getArray().getValues();
01177         self.assertEqual(len(values3),len(tmp))
01178         for i in xrange(len(tmp)):
01179             self.assertTrue(abs(tmp[i]-values3[i])<1.e-12)
01180             pass
01181         #
01182         f3=f1+f2;
01183         f4=f3/f2;
01184         f4.checkCoherency();
01185         self.assertEqual(f4.getTypeOfField(),ON_NODES);
01186         self.assertEqual(f4.getTimeDiscretization(),NO_TIME);
01187         tmp=f4.getArray().getValues();
01188         for i in xrange(len(tmp)):
01189             self.assertTrue(abs(tmp[i]-2.)<1.e-12)
01190             pass
01191         #
01192         f4=f2.buildNewTimeReprFromThis(ONE_TIME,False);
01193         f4.checkCoherency();
01194         self.assertEqual(f4.getTypeOfField(),ON_NODES);
01195         self.assertEqual(f4.getTimeDiscretization(),ONE_TIME);
01196         self.assertRaises(InterpKernelException,f1.__add__,f4);
01197         f5=f4.buildNewTimeReprFromThis(NO_TIME,False);
01198         self.assertEqual(f5.getTypeOfField(),ON_NODES);
01199         self.assertEqual(f5.getTimeDiscretization(),NO_TIME);
01200         f3=f1+f5;
01201         tmp=f3.getArray().getValues();
01202         values4=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8]
01203         self.assertEqual(len(values3),len(tmp))
01204         for i in xrange(len(tmp)):
01205             self.assertTrue(abs(tmp[i]-values4[i])<1.e-12)
01206             pass
01207         #
01208         f4=f2.buildNewTimeReprFromThis(ONE_TIME,True);
01209         f4.checkCoherency();
01210         self.assertEqual(f4.getTypeOfField(),ON_NODES);
01211         self.assertEqual(f4.getTimeDiscretization(),ONE_TIME);
01212         self.assertRaises(InterpKernelException,f1.__add__,f4);
01213         f5=f4.buildNewTimeReprFromThis(NO_TIME,True);
01214         self.assertEqual(f5.getTypeOfField(),ON_NODES);
01215         self.assertEqual(f5.getTimeDiscretization(),NO_TIME);
01216         f3=f1+f5;
01217         tmp=f3.getArray().getValues();
01218         values5=[-1.2,-0.2,0.8,-0.2,0.8,1.8,0.8,1.8,2.8]
01219         self.assertEqual(len(values5),len(tmp))
01220         for i in xrange(len(tmp)):
01221             self.assertTrue(abs(tmp[i]-values5[i])<1.e-12)
01222             pass
01223         pass

Definition at line 1224 of file MEDCouplingBasicsTest.py.

01224 
01225     def testOperationsOnFields2(self):
01226         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
01227         f1=m.fillFromAnalytic(ON_NODES,1,"x+y+z");
01228         f2=m.fillFromAnalytic(ON_NODES,1,"a*a+b+c*c");
01229         f3=f1/f2;
01230         f3.checkCoherency();
01231         self.assertEqual(f3.getTypeOfField(),ON_NODES);
01232         self.assertEqual(f3.getTimeDiscretization(),NO_TIME);
01233         expected1=[-2.4999999999999991, 1.2162162162162162, 0.77868852459016391,
01234                    0.7407407407407407, 1.129032258064516, 0.81632653061224492,
01235                    0.86538461538461531, 1.0919540229885056, 0.84302325581395343]
01236         self.assertEqual(1,f3.getNumberOfComponents());
01237         self.assertEqual(9,f3.getNumberOfTuples());
01238         val=f3.getArray().getValues();
01239         for i in xrange(9):
01240             self.assertTrue(abs(expected1[i]-val[i])<1.e-12);
01241         #
01242         f1=m.buildOrthogonalField();
01243         f2=m.fillFromAnalytic(ON_CELLS,1,"x");
01244         f3=f1*f2;
01245         expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637]
01246         val=f3.getArray().getValues();
01247         for i in xrange(15):
01248             self.assertTrue(abs(expected2[i]-val[i])<1.e-12);
01249             pass
01250         #
01251         f3=f2*f1;
01252         val=f3.getArray().getValues();
01253         for i in xrange(15):
01254             self.assertTrue(abs(expected2[i]-val[i])<1.e-12);
01255             pass
01256         pass

Definition at line 1257 of file MEDCouplingBasicsTest.py.

01257 
01258     def testOperationsOnFields3(self):
01259         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
01260         f1=m.fillFromAnalytic(ON_NODES,1,"x+y+z");
01261         f2=m.fillFromAnalytic(ON_NODES,1,"a*a+b+c*c");
01262         f1/=f2
01263         f1.checkCoherency();
01264         self.assertEqual(f1.getTypeOfField(),ON_NODES);
01265         self.assertEqual(f1.getTimeDiscretization(),NO_TIME);
01266         expected1=[-2.4999999999999991, 1.2162162162162162, 0.77868852459016391,
01267                    0.7407407407407407, 1.129032258064516, 0.81632653061224492,
01268                    0.86538461538461531, 1.0919540229885056, 0.84302325581395343]
01269         self.assertEqual(1,f1.getNumberOfComponents());
01270         self.assertEqual(9,f1.getNumberOfTuples());
01271         val=f1.getArray().getValues();
01272         for i in xrange(9):
01273             self.assertTrue(abs(expected1[i]-val[i])<1.e-12);
01274             pass
01275         #
01276         f1=m.buildOrthogonalField();
01277         f2=m.fillFromAnalytic(ON_CELLS,1,"x");
01278         f1*=f2
01279         expected2=[-0.035355339059327376,0.,0.035355339059327376, 0.2592724864350674,0.,-0.2592724864350674, 0.37712361663282529,0.,-0.37712361663282529, -0.035355339059327376,0.,0.035355339059327376, 0.31819805153394637,0.,-0.31819805153394637]
01280         val=f1.getArray().getValues();
01281         for i in xrange(15):
01282             self.assertTrue(abs(expected2[i]-val[i])<1.e-12);
01283             pass
01284         #
01285         f1=m.buildOrthogonalField();
01286         # to avoid valgrind leaks
01287         # self.assertRaises(InterpKernelException,f2.__imul__,f1);
01288         pass

Definition at line 1289 of file MEDCouplingBasicsTest.py.

01289 
01290     def testOperationsOnFields4(self):
01291         m=MEDCouplingDataForTest.build2DTargetMesh_1();
01292         nbOfCells=m.getNumberOfCells();
01293         f1=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
01294         f1.setMesh(m);
01295         array=DataArrayDouble.New();
01296         f1.setArray(array);
01297         self.assertRaises(InterpKernelException,f1.setEndArray,array);
01298         self.assertRaises(InterpKernelException,f1.getEndArray);
01299         arr1=[0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.]
01300         arr2=[5.,15.,25.,6.,16.,26.,7.,17.,27.,8.,18.,28.,9.,19.,29.]
01301         array.setValues(arr1,nbOfCells,3);
01302         f1.setStartTime(2.,0,0);
01303         f1.setEndTime(3.,0,0);
01304         f1.checkCoherency();
01305         pos=[0.3,-0.2]
01306         res=f1.getValueOn(pos);
01307         self.assertTrue(abs(arr1[3]-res[0])<1.e-12);
01308         self.assertTrue(abs(arr1[4]-res[1])<1.e-12);
01309         self.assertTrue(abs(arr1[5]-res[2])<1.e-12);
01310         res=None
01311         res=f1.getValueOn(pos,2.2);
01312         self.assertTrue(abs(arr1[3]-res[0])<1.e-12);
01313         self.assertTrue(abs(arr1[4]-res[1])<1.e-12);
01314         self.assertTrue(abs(arr1[5]-res[2])<1.e-12);
01315         res=None
01316         self.assertRaises(InterpKernelException,f1.getValueOn,pos,3.2)
01317         f2=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
01318         f2.setMesh(m);
01319         f2.setArray(f1.getArray());
01320         f2.setStartTime(2.,3,0);
01321         f2.setEndTime(4.,13,0);
01322         self.assertRaises(InterpKernelException,f2.checkCoherency)
01323         array2=DataArrayDouble.New();
01324         array2.setValues(arr2,nbOfCells,3);
01325         f2.setEndArray(array2);
01326         f2.checkCoherency();
01327         #
01328         res=None
01329         res=f2.getValueOn(pos,3.21);
01330         self.assertTrue(abs(4.025-res[0])<1.e-12);
01331         self.assertTrue(abs(14.025-res[1])<1.e-12);
01332         self.assertTrue(abs(24.025-res[2])<1.e-12);
01333         f3=f2.clone(True);
01334         self.assertTrue(f2.isEqual(f3,1e-12,1e-12));
01335         f3.getEndArray().setIJ(0,0,5.001);
01336         self.assertTrue(not f2.isEqual(f3,1e-12,1e-12));
01337         self.assertTrue(f2.isEqual(f3,1e-12,1e-2));
01338         f3.setStartTime(2.1,3,0);
01339         self.assertTrue(not f2.isEqual(f3,1e-12,1e-2));
01340         f3.setStartTime(2.,3,0);
01341         self.assertTrue(f2.isEqual(f3,1e-12,1e-2));
01342         f3.setStartTime(2.,4,0);
01343         self.assertTrue(not f2.isEqual(f3,1e-12,1e-2));
01344         f3.setStartTime(2.,3,1);
01345         self.assertTrue(not f2.isEqual(f3,1e-12,1e-2));
01346         f3.setStartTime(2.,3,0);
01347         self.assertTrue(f2.isEqual(f3,1e-12,1e-2));
01348         f3.setEndTime(4.1,13,0);
01349         self.assertTrue(not f2.isEqual(f3,1e-12,1e-2));
01350         f3.setEndTime(4.,13,0);
01351         self.assertTrue(f2.isEqual(f3,1e-12,1e-2));
01352         f3.setEndTime(4.,14,0);
01353         self.assertTrue(not f2.isEqual(f3,1e-12,1e-2));
01354         f3.setEndTime(4.,13,1);
01355         self.assertTrue(not f2.isEqual(f3,1e-12,1e-2));
01356         f3.setEndTime(4.,13,0);
01357         self.assertTrue(f2.isEqual(f3,1e-12,1e-2));
01358         f4=f2+f2
01359         res=None
01360         res=f4.getValueOn(pos,3.21);
01361         self.assertTrue(abs(8.05-res[0])<1.e-12);
01362         self.assertTrue(abs(28.05-res[1])<1.e-12);
01363         self.assertTrue(abs(48.05-res[2])<1.e-12);
01364         f4+=f2;
01365         res=None
01366         res=f4.getValueOn(pos,3.21);
01367         self.assertTrue(abs(12.075-res[0])<1.e-12);
01368         self.assertTrue(abs(42.075-res[1])<1.e-12);
01369         self.assertTrue(abs(72.075-res[2])<1.e-12);
01370         pass
    

Definition at line 7516 of file MEDCouplingBasicsTest.py.

07516 
07517     def testP2Localization1(self):
07518         m=MEDCouplingUMesh.New("testP2",2);
07519         coords=[0.,2.,3.5,0.,4.5,1.5,1.2,0.32,3.4,1.,2.1,2.4]
07520         conn=[0,1,2,3,4,5]
07521         coo=DataArrayDouble.New();
07522         coo.setValues(coords,6,2);
07523         m.setCoords(coo);
07524         m.allocateCells(1);
07525         m.insertNextCell(NORM_TRI6,6,conn[0:6])
07526         m.finishInsertingCells();
07527         #
07528         f=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
07529         f.setMesh(m);
07530         da=DataArrayDouble.New();
07531         vals1=[1.2,2.3,3.4, 2.2,3.3,4.4, 3.2,4.3,5.4, 4.2,5.3,6.4, 5.2,6.3,7.4, 6.2,7.3,8.4]
07532         da.setValues(vals1,6,3);
07533         f.setArray(da);
07534         #
07535         loc=[2.27,1.3]
07536         locs=f.getValueOnMulti(loc);
07537         expected1=[6.0921164547752236, 7.1921164547752232, 8.2921164547752255]
07538         for i in xrange(3):
07539             self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12);
07540             pass
07541         pass

Definition at line 7542 of file MEDCouplingBasicsTest.py.

07542 
07543     def testP2Localization2(self):
07544         m=MEDCouplingUMesh.New("testP2_2",3);
07545         coords=[0.33312787792955395, -0.35155740179580952, -0.03567564825034563, 1.307146326477638, -0.57234557776250305, -0.08608044208272235, 0.5551834466499993, 0.62324964668794192, -0.014638951108536295, 0.37761817224442129, -0.38324019806913578, 0.96283164472856886, 0.79494856035658679, -0.40628057809270046, 0.0021004190225864614, 1.023740446371799, 0.07665912970471335, -0.072889657161871096, 0.54564584619517376, 0.11132872093429744, 0.039647326652013051, 0.27164784387819052, -0.42018012100866675, 0.46563376500745146, 0.89501965094896418, -0.56148455362735061, 0.43337469695473035, 0.49118025152924394, 0.093884938060727313, 0.47216346905220891]
07546         conn=[0,1,2,3,4,5,6,7,8,9]
07547         coo=DataArrayDouble.New();
07548         coo.setValues(coords,10,3);
07549         m.setCoords(coo);
07550         m.allocateCells(1);
07551         m.insertNextCell(NORM_TETRA10,10,conn[0:10])
07552         m.finishInsertingCells();
07553         #
07554         f=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
07555         f.setMesh(m);
07556         da=DataArrayDouble.New();
07557         vals1=[1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2]
07558         da.setValues(vals1,10,1);
07559         f.setArray(da);
07560         #
07561         loc=[0.64637931739890486, -0.16185896817550552, 0.22678966365273748]
07562         locs=f.getValueOnMulti(loc);
07563         expected1=[10.0844021968047]
07564         for i in xrange(1):
07565             self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12);
07566             pass
07567         pass

Definition at line 2158 of file MEDCouplingBasicsTest.py.

02158 
02159     def testPolyhedronBarycenter(self):
02160         connN=[0,3,2,1, -1, 4,5,6,7, -1, 0,4,7,3, -1, 3,7,6,2, -1, 2,6,5,1, -1, 1,5,4,0];
02161         coords=[0.,0.,0., 1.,0.,0., 1.,1.,0., 0.,1.,0., 0.,0.,1., 1.,0.,1., 1.,1.,1., 0.,1.,1., 0.5, 0.5, 0.5];
02162         meshN=MEDCouplingUMesh.New();
02163         meshN.setName("ForBary");
02164         meshN.setMeshDimension(3);
02165         meshN.allocateCells(4);
02166         meshN.insertNextCell(NORM_POLYHED,29,connN[0:29])
02167         meshN.finishInsertingCells();
02168         myCoords=DataArrayDouble.New();
02169         myCoords.setValues(coords,9,3);
02170         meshN.setCoords(myCoords);
02171         meshN.checkCoherency();
02172         #
02173         res1=meshN.arePolyhedronsNotCorrectlyOriented();
02174         meshN.orientCorrectlyPolyhedrons();
02175         self.assertTrue(len(res1)==0);
02176         da=meshN.getBarycenterAndOwner();
02177         self.assertEqual(1,da.getNumberOfTuples());
02178         self.assertEqual(3,da.getNumberOfComponents());
02179         daPtr=da.getValues();
02180         ref=meshN.getCoords().getValues()[24:];
02181         for i in xrange(3):
02182             self.assertTrue(abs(ref[i]-daPtr[i])<1e-12);
02183             pass
02184         #
02185         center=[0.,0.,0.]
02186         vec=[0.,2.78,0.]
02187         da=meshN.getBarycenterAndOwner();
02188         daPtr=da.getValues();
02189         ref=meshN.getCoords().getValues()[24:];
02190         for i in xrange(3):
02191             self.assertTrue(abs(ref[i]-daPtr[i])<1e-12);
02192             pass
02193         #
02194         meshN.rotate(center,vec,pi/7.);
02195         meshN.translate(vec);
02196         da=meshN.getBarycenterAndOwner();
02197         daPtr=da.getValues();
02198         ref=meshN.getCoords().getValues()[24:];
02199         for i in xrange(3):
02200             self.assertTrue(abs(ref[i]-daPtr[i])<1e-12);
02201             pass
02202         #
02203         center2=[1.12,3.45,6.78]
02204         vec2=[4.5,9.3,2.8]
02205         meshN.rotate(center2,vec2,e);
02206         meshN.translate(vec2);
02207         da=meshN.getBarycenterAndOwner();
02208         daPtr=da.getValues();
02209         ref=meshN.getCoords().getValues()[24:];
02210         for i in xrange(3):
02211             self.assertTrue(abs(ref[i]-daPtr[i])<1e-10);
02212             pass
02213         pass

Definition at line 1415 of file MEDCouplingBasicsTest.py.

01415 
01416     def testRearrange2ConsecutiveCellTypes(self):
01417         m1_1=MEDCouplingDataForTest.build2DSourceMesh_1();
01418         m2_1=MEDCouplingDataForTest.build2DTargetMesh_1();
01419         arr1=m1_1.rearrange2ConsecutiveCellTypes();
01420         m1_2=MEDCouplingDataForTest.build2DSourceMesh_1();
01421         self.assertTrue(m1_2.isEqual(m1_1,1e-12));
01422         expected1=[0,1]
01423         self.assertEqual(2,arr1.getNumberOfTuples());
01424         self.assertEqual(1,arr1.getNumberOfComponents());
01425         self.assertEqual(expected1,arr1.getValues());
01426         expected2=[0,3,4,1,2]
01427         arr1=m2_1.rearrange2ConsecutiveCellTypes();
01428         self.assertEqual(5,arr1.getNumberOfTuples());
01429         self.assertEqual(1,arr1.getNumberOfComponents());
01430         self.assertEqual(expected2,list(arr1.getValues()));
01431         m2_2=MEDCouplingDataForTest.build2DTargetMesh_1();
01432         self.assertEqual(5,arr1.getNumberOfTuples());
01433         self.assertEqual(1,arr1.getNumberOfComponents());
01434         self.assertEqual(expected2,list(arr1.getValues()));
01435         self.assertTrue(not m2_2.isEqual(m2_1,1e-12));
01436         m2_2.renumberCells(expected2,False);
01437         self.assertTrue(m2_2.isEqual(m2_1,1e-12));
01438         pass

Definition at line 1937 of file MEDCouplingBasicsTest.py.

01937 
01938     def testRenumberCells(self):
01939         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
01940         m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
01941         self.assertTrue(m.isEqual(m2,0));
01942         arr=[12,3,25,2,26]
01943         m.renumberCells(arr,True);
01944         self.assertTrue(not m.isEqual(m2,0));
01945         self.assertEqual(NORM_QUAD4,m.getTypeOfCell(0));
01946         self.assertEqual(NORM_TRI3,m.getTypeOfCell(1));
01947         self.assertEqual(NORM_QUAD4,m.getTypeOfCell(2));
01948         self.assertEqual(NORM_TRI3,m.getTypeOfCell(3));
01949         self.assertEqual(NORM_QUAD4,m.getTypeOfCell(4));
01950         arr2=[5,-1,-5,4,8]
01951         m.renumberCells(arr2,True);
01952         self.assertTrue(m.isEqual(m2,0));
01953         pass

Definition at line 2464 of file MEDCouplingBasicsTest.py.

02464 
02465     def testRenumberCellsForFields(self):
02466         m=MEDCouplingDataForTest.build2DTargetMesh_1();
02467         f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
02468         f.setMesh(m);
02469         arr=DataArrayDouble.New();
02470         nbOfCells=m.getNumberOfCells();
02471         values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.]
02472         arr.setValues(values1,nbOfCells,3);
02473         f.setArray(arr);
02474         renumber1=[3,1,0,4,2]
02475         loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45]
02476         for j in xrange(5):
02477             res=f.getValueOn(loc[2*j:2*j+2]);
02478             for i in xrange(3):
02479                 self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12);
02480                 pass
02481             pass
02482         f.renumberCells(renumber1,False);
02483         ptr=f.getArray().getValues();
02484         expected1=[9.,109.,10009.,8.,108.,10008.,11.,111.,10011.,7.,107.,10007.,10.,110.,10010.]
02485         for i in xrange(15):
02486             self.assertTrue(abs(expected1[i]-ptr[i])<1e-12);
02487             pass
02488         #check that fields remains the same geometrically
02489         for j in xrange(5):
02490             res=f.getValueOn(loc[2*j:2*(j+1)]);
02491             for i in xrange(3):
02492                 self.assertTrue(abs(values1[i+3*j]-res[i])<1e-12);
02493                 pass
02494             pass
02495         #On gauss
02496         f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,NO_TIME);
02497         f.setMesh(m);
02498         _a=0.446948490915965;
02499         _b=0.091576213509771;
02500         _p1=0.11169079483905;
02501         _p2=0.0549758718227661;
02502         refCoo1=[ 0.,0., 1.,0., 0.,1. ]
02503         gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b, 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ];
02504         wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
02505         _refCoo1=refCoo1[0:6];
02506         _gsCoo1=gsCoo1[0:12];
02507         _wg1=wg1[0:6];
02508         f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
02509         refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
02510         _refCoo2=refCoo2[0:8];
02511         _gsCoo1=_gsCoo1[0:4]
02512         _wg1=_wg1[0:2]
02513         f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
02514         arr=DataArrayDouble.New();
02515         values2=[1.,1001.,2.,1002., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 31.,1031.,32.,1032., 41.,1041.,42.,1042.]
02516         arr.setValues(values2,18,2);
02517         f.setArray(arr);
02518         f.checkCoherency();
02519         fCpy=f.clone(True);
02520         self.assertTrue(f.isEqual(fCpy,1e-12,1e-12));
02521         f.renumberCells(renumber1,False);
02522         self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12));
02523         expected2=[21.,1021.,22.,1022.,23.,1023.,24.,1024.,25.,1025.,26.,1026., 11.,1011.,12.,1012.,13.,1013.,14.,1014.,15.,1015.,16.,1016., 41.,1041.,42.,1042., 1.,1001.,2.,1002., 31.,1031.,32.,1032.]
02524         ptr=f.getArray().getValues();
02525         for i in xrange(36):
02526             self.assertTrue(abs(expected2[i]-ptr[i])<1e-12);
02527             pass
02528         renumber2=[2,1,4,0,3]
02529         f.renumberCells(renumber2,False);
02530         self.assertTrue(f.isEqual(fCpy,1e-12,1e-12));
02531         #GaussNE
02532         f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,NO_TIME);
02533         f.setMesh(m);
02534         arr=DataArrayDouble.New();
02535         values3=[1.,1001.,2.,1002.,3.,1003.,4.,1004., 11.,1011.,12.,1012.,13.,1013., 21.,1021.,22.,1022.,23.,1023., 31.,1031.,32.,1032.,33.,1033.,34.,1034., 41.,1041.,42.,1042.,43.,1043.,44.,1044.]
02536         arr.setValues(values3,18,2);
02537         f.setArray(arr);
02538         f.checkCoherency();
02539         fCpy=f.clone(True);
02540         self.assertTrue(f.isEqual(fCpy,1e-12,1e-12));
02541         f.renumberCells(renumber1,False);
02542         self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12));
02543         expected3=[21.,1021.,22.,1022.,23.,1023.,11.,1011.,12.,1012.,13.,1013.,41.,1041.,42.,1042.,43.,1043.,44.,1044.,1.,1001.,2.,1002.,3.,1003.,4.,1004.,31.,1031.,32.,1032.,33.,1033.,34.,1034.]
02544         ptr=f.getArray().getValues();
02545         for i in xrange(36):
02546             self.assertTrue(abs(expected3[i]-ptr[i])<1e-12);
02547             pass
02548         f.renumberCells(renumber2,False);#perform reverse operation of renumbering to check that the resulting field is equal.
02549         self.assertTrue(f.isEqual(fCpy,1e-12,1e-12));
02550         #
02551         pass

Definition at line 2552 of file MEDCouplingBasicsTest.py.

02552 
02553     def testRenumberNodesForFields(self):
02554         m=MEDCouplingDataForTest.build2DTargetMesh_1();
02555         f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
02556         f.setMesh(m);
02557         self.assertEqual(9,f.getNumberOfMeshPlacesExpected());
02558         arr=DataArrayDouble.New();
02559         nbOfNodes=m.getNumberOfNodes();
02560         values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.]
02561         arr.setValues(values1,nbOfNodes,3);
02562         f.setArray(arr);
02563         f.checkCoherency();
02564         renumber1=[0,4,1,3,5,2,6,7,8]
02565         loc=[0.5432,-0.2432, 0.5478,0.1528]
02566         expected1=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124]
02567         for j in xrange(2):
02568             res=f.getValueOn(loc[2*j:2*j+2]);
02569             for i in xrange(3):
02570                 self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12);
02571                 pass
02572             pass
02573         fCpy=f.clone(True);
02574         self.assertTrue(f.isEqual(fCpy,1e-12,1e-12));
02575         f.renumberNodes(renumber1);
02576         self.assertTrue(not f.isEqual(fCpy,1e-12,1e-12));
02577         for j in xrange(2):
02578             res=f.getValueOn(loc[2*j:2*j+2]);
02579             for i in xrange(3):
02580                 self.assertTrue(abs(expected1[i+3*j]-res[i])<1e-12);
02581                 pass
02582             pass
02583         expected2=[7.,107.,10007.,9.,109.,10009.,12.,112.,10012.,10.,110.,10010.,8.,108.,10008.,11.,111.,10011.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.]
02584         for i in xrange(27):
02585             self.assertTrue(abs(expected2[i]-f.getArray().getValues()[i])<1e-12);
02586             pass
02587         renumber2=[0,2,5,3,1,4,6,7,8]
02588         f.renumberNodes(renumber2);
02589         self.assertTrue(f.isEqual(fCpy,1e-12,1e-12));
02590         pass

Definition at line 9638 of file MEDCouplingBasicsTest.py.

09638 
09639     def testRenumberNodesInConn1(self):
09640         mesh2DCoords=[-0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0. ]
09641         mesh2DConn=[1,4,2, 4,5,2, 0,3,4,1, 6,7,4,3, 7,8,5,4]
09642         mesh2D=MEDCouplingUMesh.New("mesh",2);
09643         mesh2D.allocateCells(5);
09644         mesh2D.insertNextCell(NORM_TRI3,3,mesh2DConn[0:3])
09645         mesh2D.insertNextCell(NORM_TRI3,3,mesh2DConn[3:6])
09646         mesh2D.insertNextCell(NORM_QUAD4,4,mesh2DConn[6:10])
09647         mesh2D.insertNextCell(NORM_QUAD4,4,mesh2DConn[10:14])
09648         mesh2D.insertNextCell(NORM_QUAD4,4,mesh2DConn[14:18])
09649         mesh2D.finishInsertingCells();
09650         myCoords=DataArrayDouble.New(mesh2DCoords,9,3);
09651         mesh2D.setCoords(myCoords);
09652         mesh2D.checkCoherency();
09653         #
09654         mesh3DCoords=[-0.3,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.2,-0.3,0., -0.3,-0.3,1., -0.3,0.2,1., 0.2,0.2,1., 0.2,-0.3,1. ]
09655         mesh3DConn=[0,1,2,3,4,5,6,7]
09656         mesh3D=MEDCouplingUMesh.New("mesh",3);
09657         mesh3D.allocateCells(1);
09658         mesh3D.insertNextCell(NORM_HEXA8,8,mesh3DConn[:])
09659         mesh3D.finishInsertingCells();
09660         myCoords3D=DataArrayDouble.New(mesh3DCoords,8,3);
09661         mesh3D.setCoords(myCoords3D);
09662         mesh3D.checkCoherency();
09663         #
09664         mesh3D_2=mesh3D.deepCpy();
09665         mesh2D_2=mesh2D.deepCpy();
09666         mesh3D_4=mesh3D.deepCpy();
09667         mesh2D_4=mesh2D.deepCpy();
09668         oldNbOf3DNodes=mesh3D.getNumberOfNodes();
09669         renumNodes=DataArrayInt.New();
09670         renumNodes.alloc(mesh2D.getNumberOfNodes(),1);
09671         renumNodes.iota(oldNbOf3DNodes);
09672         coo=DataArrayDouble.Aggregate(mesh3D.getCoords(),mesh2D.getCoords());
09673         mesh3D.setCoords(coo);
09674         mesh2D.setCoords(coo);
09675         mesh2DCpy=mesh2D.deepCpy()
09676         mesh2D_3=mesh2D.deepCpy();
09677         mesh2D_3.shiftNodeNumbersInConn(oldNbOf3DNodes);
09678         mesh2D.renumberNodesInConn(renumNodes);
09679         mesh2DCpy.renumberNodesInConn(renumNodes.getValues());
09680         self.assertTrue(mesh2D.isEqual(mesh2DCpy,1e-12))
09681         self.assertTrue(mesh2D.isEqual(mesh2D_3,1e-12))
09682         #
09683         da1,da2=mesh3D.checkGeoEquivalWith(mesh3D_2,10,1e-12);
09684         self.assertTrue(da1==None);
09685         self.assertEqual(8,da2.getNumberOfTuples());
09686         self.assertEqual(1,da2.getNumberOfComponents());
09687         expected1=[8,11,12,9,4,5,6,7]
09688         for i in xrange(8):
09689             self.assertEqual(expected1[i],da2.getIJ(i,0));
09690             pass
09691         #
09692         da1,da2=mesh2D.checkGeoEquivalWith(mesh2D_2,10,1e-12);
09693         self.assertTrue(da1==None);
09694         self.assertEqual(9,da2.getNumberOfTuples());
09695         self.assertEqual(1,da2.getNumberOfComponents());
09696         for i in xrange(9):
09697             self.assertEqual(8+i,da2.getIJ(i,0));
09698             pass
09699         #
09700         mesh2D_5=mesh2D_4.deepCpy();
09701         mesh2D_5.translate([1.,0.,0.]);
09702         meshes=[mesh3D_4,mesh2D_4,mesh2D_5];
09703         MEDCouplingUMesh.PutUMeshesOnSameAggregatedCoords(meshes);
09704         self.assertTrue(mesh3D_4.getCoords().getHiddenCppPointer()==mesh2D_4.getCoords().getHiddenCppPointer());
09705         self.assertTrue(mesh2D_4.getCoords().getHiddenCppPointer()==mesh2D_5.getCoords().getHiddenCppPointer());
09706         mesh3D_4.checkCoherency(); mesh2D_4.checkCoherency(); mesh2D_5.checkCoherency();
09707         self.assertEqual(26,mesh3D_4.getNumberOfNodes());
09708         self.assertEqual(3,mesh3D_4.getSpaceDimension());
09709         self.assertEqual(9,mesh3D_4.getNodalConnectivity().getNumberOfTuples());
09710         self.assertEqual(23,mesh2D_4.getNodalConnectivity().getNumberOfTuples());
09711         self.assertEqual(23,mesh2D_5.getNodalConnectivity().getNumberOfTuples());
09712         expected2=[18,0,1,2,3,4,5,6,7]
09713         expected3=[3,9,12,10, 3,12,13,10, 4,8,11,12,9, 4,14,15,12,11, 4,15,16,13,12]
09714         expected4=[3,18,21,19, 3,21,22,19, 4,17,20,21,18, 4,23,24,21,20, 4,24,25,22,21]
09715         expected5=[-0.3,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.2,-0.3,0., -0.3,-0.3,1., -0.3,0.2,1., 0.2,0.2,1., 0.2,-0.3,1., -0.3,-0.3,0., 0.2,-0.3,0., 0.7,-0.3,0., -0.3,0.2,0., 0.2,0.2,0., 0.7,0.2,0., -0.3,0.7,0., 0.2,0.7,0., 0.7,0.7,0., 0.7, -0.3, 0.0, 1.2, -0.3, 0.0, 1.7, -0.3, 0.0, 0.7, 0.2, 0.0, 1.2, 0.2, 0.0, 1.7, 0.2, 0.0, 0.7, 0.7, 0.0, 1.2, 0.7, 0.0, 1.7, 0.7, 0.0]
09716         self.assertEqual(expected2,mesh3D_4.getNodalConnectivity().getValues());
09717         self.assertEqual(expected3,mesh2D_4.getNodalConnectivity().getValues());
09718         self.assertEqual(expected4,mesh2D_5.getNodalConnectivity().getValues());
09719         for i in xrange(78):
09720             self.assertAlmostEqual(expected5[i],mesh3D_4.getCoords().getIJ(0,i),12);
09721             pass
09722         #
09723         MEDCouplingUMesh.MergeNodesOnUMeshesSharingSameCoords(meshes,1e-12);
09724         mesh3D_4.checkCoherency(); mesh2D_4.checkCoherency(); mesh2D_5.checkCoherency();
09725         self.assertTrue(mesh3D_4.getCoords().getHiddenCppPointer()==mesh2D_4.getCoords().getHiddenCppPointer());
09726         self.assertTrue(mesh2D_4.getCoords().getHiddenCppPointer()==mesh2D_5.getCoords().getHiddenCppPointer());
09727         self.assertEqual(19,mesh3D_4.getNumberOfNodes());
09728         self.assertEqual(3,mesh3D_4.getSpaceDimension());
09729         self.assertEqual(9,mesh3D_4.getNodalConnectivity().getNumberOfTuples());
09730         self.assertEqual(23,mesh2D_4.getNodalConnectivity().getNumberOfTuples());
09731         self.assertEqual(23,mesh2D_5.getNodalConnectivity().getNumberOfTuples());
09732         expected6=[18,0,1,2,3,4,5,6,7]
09733         expected7=[3,3,2,8, 3,2,9,8, 4,0,1,2,3, 4,10,11,2,1, 4,11,12,9,2]
09734         expected8=[3,13,15,14, 3,15,16,14, 4,8,9,15,13, 4,12,17,15,9, 4,17,18,16,15]
09735         expected9=[-0.3, -0.3, 0., -0.3, 0.2, 0., 0.2, 0.2, 0., 0.2, -0.3, 0., -0.3, -0.3, 1., -0.3, 0.2, 1.,
09736                     0.2, 0.2, 1., 0.2, -0.3, 1., 0.7, -0.3, 0., 0.7, 0.2, 0., -0.3, 0.7, 0., 0.2, 0.7, 0.,
09737                     0.7, 0.7, 0., 1.2, -0.3, 0., 1.7, -0.3, 0., 1.2, 0.2, 0., 1.7, 0.2, 0., 1.2, 0.7, 0., 1.7, 0.7, 0.]
09738         self.assertEqual(expected6,mesh3D_4.getNodalConnectivity().getValues());
09739         self.assertEqual(expected7,mesh2D_4.getNodalConnectivity().getValues());
09740         self.assertEqual(expected8,mesh2D_5.getNodalConnectivity().getValues());
09741         for i in xrange(57):
09742             self.assertAlmostEqual(expected9[i],mesh3D_4.getCoords().getIJ(0,i),1e-12);
09743             pass
09744         #
09745         pass
    

Definition at line 198 of file MEDCouplingBasicsTest.py.

00198 
00199     def testRevNodal(self):
00200         mesh=MEDCouplingDataForTest.build2DTargetMesh_1()
00201         revNodal,revNodalIndx=mesh.getReverseNodalConnectivity();
00202         revNodalExpected=[0,0,1,1,2,0,3,0,1,2,3,4,2,4,3,3,4,4];
00203         revNodalIndexExpected=[0,1,3,5,7,12,14,15,17,18];
00204         self.assertEqual(revNodal.getNbOfElems(),18)
00205         self.assertEqual(revNodalIndx.getNbOfElems(),10)
00206         self.assertEqual(list(revNodal.getValues()),revNodalExpected)
00207         self.assertEqual(list(revNodalIndx.getValues()),revNodalIndexExpected)
00208         pass
    

Definition at line 1872 of file MEDCouplingBasicsTest.py.

01872 
01873     def testScale(self):
01874         mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
01875         pos=[0.2,0.2]
01876         mesh.scale(pos,0.5);
01877         expected1=[-0.05,-0.05, 0.2,-0.05, 0.45,-0.05, -0.05,0.2, 0.2,0.2, 0.45,0.2,
01878                    -0.05,0.45, 0.2,0.45, 0.45,0.45]
01879         val=mesh.getCoords().getValues();
01880         self.assertEqual(18,len(val))
01881         for i in xrange(18):
01882             self.assertTrue(abs(expected1[i]-val[i])<1e-12);
01883             pass
01884         pass

Definition at line 5531 of file MEDCouplingBasicsTest.py.

05531 
05532     def testSimplexize1(self):
05533         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
05534         m.convertToPolyTypes([3]);
05535         da=m.simplexize(0);
05536         self.assertEqual(7,da.getNumberOfTuples());
05537         self.assertEqual(1,da.getNumberOfComponents());
05538         expected2=[0,0,1,2,3,4,4]
05539         for i in xrange(7):
05540             self.assertEqual(expected2[i],da.getIJ(i,0));
05541             pass
05542         m.checkCoherency();
05543         self.assertEqual(7,m.getNumberOfCells());
05544         self.assertEqual(NORM_TRI3,m.getTypeOfCell(0));
05545         self.assertEqual(NORM_TRI3,m.getTypeOfCell(1));
05546         self.assertEqual(NORM_TRI3,m.getTypeOfCell(2));
05547         self.assertEqual(NORM_TRI3,m.getTypeOfCell(3));
05548         self.assertEqual(NORM_POLYGON,m.getTypeOfCell(4));
05549         self.assertEqual(NORM_TRI3,m.getTypeOfCell(5));
05550         self.assertEqual(NORM_TRI3,m.getTypeOfCell(6));
05551         expected1=[0.125,0.125,0.125,0.125,0.25,0.125,0.125]
05552         f=m.getMeasureField(False);
05553         for i in xrange(7):
05554             self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10);
05555             pass
05556         types=m.getAllTypes();
05557         self.assertEqual([NORM_TRI3,NORM_POLYGON],types);
05558         #
05559         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
05560         m.convertToPolyTypes([3]);
05561         da=m.simplexize(1);
05562         self.assertEqual(7,da.getNumberOfTuples());
05563         self.assertEqual(1,da.getNumberOfComponents());
05564         for i in xrange(7):
05565             self.assertEqual(expected2[i],da.getIJ(i,0));
05566             pass
05567         m.checkCoherency();
05568         types=m.getAllTypes();
05569         self.assertEqual([NORM_TRI3,NORM_POLYGON],types);
05570         self.assertEqual(7,m.getNumberOfCells());
05571         self.assertEqual(NORM_TRI3,m.getTypeOfCell(0));
05572         self.assertEqual(NORM_TRI3,m.getTypeOfCell(1));
05573         self.assertEqual(NORM_TRI3,m.getTypeOfCell(2));
05574         self.assertEqual(NORM_TRI3,m.getTypeOfCell(3));
05575         self.assertEqual(NORM_POLYGON,m.getTypeOfCell(4));
05576         self.assertEqual(NORM_TRI3,m.getTypeOfCell(5));
05577         self.assertEqual(NORM_TRI3,m.getTypeOfCell(6));
05578         f=m.getMeasureField(False);
05579         for i in xrange(7):
05580             self.assertAlmostEqual(expected1[i]*sqrt(2.),f.getIJ(i,0),10);
05581             pass
05582         pass

Definition at line 5583 of file MEDCouplingBasicsTest.py.

05583 
05584     def testSimplexize2(self):
05585         m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
05586         m.convertToPolyTypes([3]);
05587         f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
05588         f1.setMesh(m);
05589         arr=DataArrayDouble.New();
05590         arr1=[10.,110.,20.,120.,30.,130.,40.,140.,50.,150.]
05591         arr.setValues(arr1,5,2);
05592         f1.setArray(arr);
05593         #
05594         f1.checkCoherency();
05595         self.assertTrue(f1.simplexize(0));
05596         f1.checkCoherency();
05597         expected1=[10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.]
05598         for i in xrange(14):
05599             self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10);
05600             pass
05601         self.assertTrue(not f1.simplexize(0));
05602         for i in xrange(14):
05603             self.assertAlmostEqual(expected1[i],f1.getIJ(0,i),10);
05604             pass
05605         #
05606         pass

Definition at line 7995 of file MEDCouplingBasicsTest.py.

07995 
07996     def testSortCellsInMEDFileFrmt1(self):
07997         m,m1=MEDCouplingDataForTest.buildPointe_1();
07998         m2=m.deepCpy()
07999         da=DataArrayInt.New()
08000         da.setValues([0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13],16,1)
08001         daa=da.invertArrayN2O2O2N(16)
08002         m.renumberCells(daa,False)
08003         da2=m.sortCellsInMEDFileFrmt()
08004         self.assertEqual(da2.getValues(),[0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13])
08005         self.assertTrue(m.isEqual(m2,1e-12))
08006         self.assertTrue(da.isEqual(da2))
08007         pass

Definition at line 3520 of file MEDCouplingBasicsTest.py.

03520 
03521     def testSortPerTuple1(self):
03522         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
03523         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
03524         f1.setMesh(mesh1);
03525         array=DataArrayDouble.New();
03526         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4]
03527         array.setValues(arr1,mesh1.getNumberOfCells(),5);
03528         f1.setArray(array);
03529         f1.checkCoherency();
03530         #
03531         f1.sortPerTuple(True);
03532         f1.checkCoherency();
03533         self.assertEqual(5,f1.getNumberOfComponents());
03534         self.assertEqual(5,f1.getNumberOfTuples());
03535         for i in xrange(5):
03536             self.assertAlmostEqual(arr1[0],f1.getIJ(i,0),13);
03537             self.assertAlmostEqual(arr1[1],f1.getIJ(i,1),13);
03538             self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13);
03539             self.assertAlmostEqual(arr1[3],f1.getIJ(i,3),13);
03540             self.assertAlmostEqual(arr1[4],f1.getIJ(i,4),13);
03541             pass
03542         #
03543         f1.sortPerTuple(False);
03544         f1.checkCoherency();
03545         self.assertEqual(5,f1.getNumberOfComponents());
03546         self.assertEqual(5,f1.getNumberOfTuples());
03547         for i in xrange(5):
03548             self.assertAlmostEqual(arr1[4],f1.getIJ(i,0),13);
03549             self.assertAlmostEqual(arr1[3],f1.getIJ(i,1),13);
03550             self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13);
03551             self.assertAlmostEqual(arr1[1],f1.getIJ(i,3),13);
03552             self.assertAlmostEqual(arr1[0],f1.getIJ(i,4),13);
03553             pass
03554         #
03555         pass

Here is the caller graph for this function:

Definition at line 4754 of file MEDCouplingBasicsTest.py.

04754 
04755     def testSortPerTuple1(self):
04756         mesh1=MEDCouplingDataForTest.build2DTargetMesh_1();
04757         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
04758         f1.setMesh(mesh1);
04759         array=DataArrayDouble.New();
04760         arr1=[1.2,2.3,3.4,4.5,5.6, 1.2,3.4,4.5,5.6,2.3, 3.4,4.5,5.6,1.2,2.3, 5.6,1.2,2.3,3.4,4.5, 4.5,5.6,1.2,2.3,3.4]
04761         array.setValues(arr1,mesh1.getNumberOfCells(),5);
04762         f1.setArray(array);
04763         f1.checkCoherency();
04764         #
04765         f1.sortPerTuple(True);
04766         f1.checkCoherency();
04767         self.assertEqual(5,f1.getNumberOfComponents());
04768         self.assertEqual(5,f1.getNumberOfTuples());
04769         for i in xrange(5):
04770             self.assertAlmostEqual(arr1[0],f1.getIJ(i,0),13);
04771             self.assertAlmostEqual(arr1[1],f1.getIJ(i,1),13);
04772             self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13);
04773             self.assertAlmostEqual(arr1[3],f1.getIJ(i,3),13);
04774             self.assertAlmostEqual(arr1[4],f1.getIJ(i,4),13);
04775             pass
04776         #
04777         f1.sortPerTuple(False);
04778         f1.checkCoherency();
04779         self.assertEqual(5,f1.getNumberOfComponents());
04780         self.assertEqual(5,f1.getNumberOfTuples());
04781         for i in xrange(5):
04782             self.assertAlmostEqual(arr1[4],f1.getIJ(i,0),13);
04783             self.assertAlmostEqual(arr1[3],f1.getIJ(i,1),13);
04784             self.assertAlmostEqual(arr1[2],f1.getIJ(i,2),13);
04785             self.assertAlmostEqual(arr1[1],f1.getIJ(i,3),13);
04786             self.assertAlmostEqual(arr1[0],f1.getIJ(i,4),13);
04787             pass
04788         #
04789         pass
    

Here is the call graph for this function:

Definition at line 1439 of file MEDCouplingBasicsTest.py.

01439 
01440     def testSplitByType(self):
01441         m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
01442         v=m1.splitByType();
01443         self.assertEqual(3,len(v));
01444         m2=MEDCouplingUMesh.MergeUMeshesOnSameCoords(v);
01445         m2.setName(m1.getName());
01446         self.assertTrue(m1.isEqual(m2,1.e-12));
01447         pass

Definition at line 2897 of file MEDCouplingBasicsTest.py.

02897 
02898     def testSubstractInPlaceDM1(self):
02899         mesh1=MEDCouplingDataForTest.build2DTargetMesh_3();
02900         mesh2=MEDCouplingDataForTest.build2DTargetMesh_3();
02901         f1=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
02902         f1.setMesh(mesh1);
02903         array=DataArrayDouble.New();
02904         arr=[7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.,13.,113.,14.,114.,15.,115.,16.,116.]
02905         array.setValues(arr,mesh1.getNumberOfCells(),2);
02906         f1.setArray(array);
02907         #
02908         self.assertEqual(10,f1.getNumberOfTuples());
02909         self.assertEqual(2,f1.getNumberOfComponents());
02910         self.assertEqual(20,f1.getNumberOfValues());
02911         #
02912         renum=[0,2,3,1,4,5,6,8,7,9]
02913         mesh2.renumberCells(renum,False);
02914         #
02915         f2=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
02916         f2.setMesh(mesh2);
02917         array=DataArrayDouble.New();
02918         arr2=[7.1,107.1,10.1,110.1,8.1,108.1,9.1,109.1,11.1,111.1,12.1,112.1,13.1,113.1,15.1,115.1,14.1,114.1,16.1,116.1]
02919         array.setValues(arr2,mesh2.getNumberOfCells(),2);
02920         f2.setArray(array);
02921         #
02922         f1.substractInPlaceDM(f2,10,1e-12);
02923         f1.applyFunc(1,"abs(x+y+0.2)");
02924         self.assertAlmostEqual(0.,f1.getMaxValue(),13);
02925         pass

Definition at line 9867 of file MEDCouplingBasicsTest.py.

09867 
09868     def testSwigDADISub1(self):
09869         mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1();
09870         bary=mesh3D.getBarycenterAndOwner()
09871         bary=bary[:,:2]
09872         pts=bary.getDifferentValues(1e-12)
09873         expected=[[0,6,12],[1,7,13],[2,8,14],[3,9,15],[4,10,16],[5,11,17]]
09874         for pos,pt in enumerate(pts):
09875             bary2=bary[:,:2]
09876             bary2[:]-=pt
09877             norm=bary2.magnitude()
09878             self.assertEqual(expected[pos],norm.getIdsInRange(-1.,1e-5).getValues())
09879             pass
09880         expected2=[[3.,54.],[-141.,180.],[21.,54.],[39.,72.],[-15.,90.],[21.,90.]]
09881         for pos,pt in enumerate(pts):
09882             bary2=bary[:,:2]
09883             bary2[:]+=pt
09884             self.assertAlmostEqual(expected2[pos][0],bary2.accumulate()[0],12);
09885             self.assertAlmostEqual(expected2[pos][1],bary2.accumulate()[1],12);
09886             pass
09887         expected3=[[-3.,22.5],[45.,337.5],[-9., 22.5],[-15.,67.5],[3.,112.5],[-9.,112.5]]
09888         for pos,pt in enumerate(pts):
09889             bary2=bary[:,:2]
09890             bary2[:]*=pt
09891             self.assertAlmostEqual(expected3[pos][0],bary2.accumulate()[0],12);
09892             self.assertAlmostEqual(expected3[pos][1],bary2.accumulate()[1],12);
09893             pass
09894         expected4=[[-12.,90.],[0.8,6.],[-4,90.],[-2.4,30.],[12.,18],[-4,18.]]
09895         for pos,pt in enumerate(pts):
09896             bary2=bary[:,:2]
09897             bary2[:]/=pt
09898             self.assertAlmostEqual(expected4[pos][0],bary2.accumulate()[0],12);
09899             self.assertAlmostEqual(expected4[pos][1],bary2.accumulate()[1],12);
09900             pass
09901         #
09902         d=DataArrayInt.New([1,2,0,1,0,2],3,2)
09903         e=DataArrayInt.New([1,11,101,2,12,102,3,13,103,4,14,104],4,3)
09904         expected5=[[1,11,101,77,77,77,77,77,77,4,14,104],[77,77,77,77,77,77,3,13,103,4,14,104],[77,77,77,2,12,102,77,77,77,4,14,104]]
09905         expected6=[[1,77,77,2,77,77,3,77,77,4,77,77],[77,77,101,77,77,102,77,77,103,77,77,104],[77,11,77,77,12,77,77,13,77,77,14,77]]
09906         for pos,tup in enumerate(d):
09907             f=e[:]
09908             self.assertTrue(isinstance(f,DataArrayInt))
09909             f[tup]=77
09910             self.assertEqual(expected5[pos],f.getValues())
09911             self.assertEqual(6*[77],f[tup].getValues())
09912             f=e[:]
09913             f[:,tup]=77
09914             self.assertEqual(expected6[pos],f.getValues())
09915             self.assertEqual(8*[77],f[:,tup].getValues())
09916             pass
09917         #
09918         e=e.convertToDblArr()
09919         for pos,tup in enumerate(d):
09920             f=e[:]
09921             self.assertTrue(isinstance(f,DataArrayDouble))
09922             f[tup]=77.
09923             self.assertEqual(expected5[pos],f.convertToIntArr().getValues())
09924             self.assertEqual(6*[77],f[tup].convertToIntArr().getValues())
09925             f=e[:]
09926             f[:,tup]=77.
09927             self.assertEqual(expected6[pos],f.convertToIntArr().getValues())
09928             self.assertEqual(8*[77],f[:,tup].convertToIntArr().getValues())
09929             pass
09930         pass

Definition at line 6541 of file MEDCouplingBasicsTest.py.

06541 
06542     def testSwigDADOp(self):
06543         da=DataArrayDouble.New()
06544         da.alloc(12,1)
06545         da.iota(7.)
06546         da1=DataArrayDouble.New()
06547         da1.alloc(12,1)
06548         da1.iota(8.)
06549         da2=da+da1
06550         self.assertEqual([15., 17., 19., 21., 23., 25., 27., 29., 31., 33., 35., 37.],da2.getValues())
06551         da2=da+3
06552         da3=3+da
06553         self.assertTrue(da2.isEqual(da3,1e-12))
06554         da2=da-1.
06555         self.assertEqual([6.0, 7.0, 8.0, 9.0, 10.0, 1