From b7ab581d29daeeb96988304481ffa0e917e29fac Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 27 Apr 2012 10:51:05 +0000 Subject: [PATCH] Correction of bug in DataArrayOperator with DataArrayTuple. --- src/MEDCoupling_Swig/MEDCoupling.i | 86 +++++++++---------- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 35 ++++++++ 2 files changed, 78 insertions(+), 43 deletions(-) diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 23e2511a9..744c4697f 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -2946,7 +2946,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Add(self,aaa); } default: @@ -2974,7 +2974,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Add(self,aaa); } default: @@ -3005,7 +3005,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); self->addEqual(aaa); return self; } @@ -3044,7 +3044,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Substract(self,aaa); } case 4: @@ -3077,7 +3077,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Substract(aaa,self); } case 4: @@ -3113,7 +3113,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); self->substractEqual(aaa); return self; } @@ -3152,7 +3152,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Multiply(self,aaa); } case 4: @@ -3185,7 +3185,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Multiply(self,aaa); } case 4: @@ -3221,7 +3221,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); self->multiplyEqual(aaa); return self; } @@ -3262,7 +3262,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Divide(self,aaa); } case 4: @@ -3295,7 +3295,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); return DataArrayDouble::Divide(aaa,self); } case 4: @@ -3333,7 +3333,7 @@ namespace ParaMEDMEM } case 3: { - MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaa=aa->buildDADouble(1,self->getNumberOfComponents()); self->divideEqual(aaa); return self; } @@ -4263,7 +4263,7 @@ namespace ParaMEDMEM self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1); return self; default: @@ -4287,7 +4287,7 @@ namespace ParaMEDMEM self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1); return self; default: @@ -4311,7 +4311,7 @@ namespace ParaMEDMEM self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1); return self; default: @@ -4335,7 +4335,7 @@ namespace ParaMEDMEM self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1); return self; default: @@ -4359,7 +4359,7 @@ namespace ParaMEDMEM self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1); return self; default: @@ -4383,7 +4383,7 @@ namespace ParaMEDMEM self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1); return self; default: @@ -4407,7 +4407,7 @@ namespace ParaMEDMEM self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1); return self; default: @@ -4431,7 +4431,7 @@ namespace ParaMEDMEM self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1); return self; default: @@ -4455,7 +4455,7 @@ namespace ParaMEDMEM self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size()); return self; default: @@ -4479,7 +4479,7 @@ namespace ParaMEDMEM self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size()); return self; default: @@ -4512,7 +4512,7 @@ namespace ParaMEDMEM self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size()); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size()); return self; default: @@ -4536,7 +4536,7 @@ namespace ParaMEDMEM self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size()); return self; default: @@ -4560,7 +4560,7 @@ namespace ParaMEDMEM self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second); return self; default: @@ -4584,7 +4584,7 @@ namespace ParaMEDMEM self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second); return self; default: @@ -4608,7 +4608,7 @@ namespace ParaMEDMEM self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second); return self; default: @@ -4632,7 +4632,7 @@ namespace ParaMEDMEM self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); return self; case 4: - tmp=dd1->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + tmp=dd1->buildDAInt(1,self->getNumberOfComponents()); self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second); return self; default: @@ -4675,7 +4675,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Add(self,aaaa); } default: @@ -4703,7 +4703,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Add(self,aaaa); } default: @@ -4740,7 +4740,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); self->addEqual(aaaa); return self; } @@ -4773,7 +4773,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Substract(self,aaaa); } default: @@ -4801,7 +4801,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Substract(aaaa,self); } default: @@ -4838,7 +4838,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); self->substractEqual(aaaa); return self; } @@ -4871,7 +4871,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Multiply(self,aaaa); } default: @@ -4899,7 +4899,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Multiply(self,aaaa); } default: @@ -4936,7 +4936,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); self->multiplyEqual(aaaa); return self; } @@ -4969,7 +4969,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Divide(self,aaaa); } default: @@ -4997,7 +4997,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Divide(aaaa,self); } default: @@ -5034,7 +5034,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); self->divideEqual(aaaa); return self; } @@ -5067,7 +5067,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Modulus(self,aaaa); } default: @@ -5099,7 +5099,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); return DataArrayInt::Modulus(aaaa,self); } default: @@ -5130,7 +5130,7 @@ namespace ParaMEDMEM } case 4: { - MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(self->getNumberOfTuples(),self->getNumberOfComponents()); + MEDCouplingAutoRefCountObjectPtr aaaa=aaa->buildDAInt(1,self->getNumberOfComponents()); self->modulusEqual(aaaa); return self; } diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 926f58c1a..054a87c5b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -9864,6 +9864,41 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertAlmostEqual(9.12,da[1,2],12) pass + def testSwigDADISub1(self): + mesh3D,mesh2D=MEDCouplingDataForTest.build3DExtrudedUMesh_1(); + bary=mesh3D.getBarycenterAndOwner() + bary=bary[:,:2] + pts=bary.getDifferentValues(1e-12) + expected=[[0,6,12],[1,7,13],[2,8,14],[3,9,15],[4,10,16],[5,11,17]] + for pos,pt in enumerate(pts): + bary2=bary[:,:2] + bary2[:]-=pt + norm=bary2.magnitude() + self.assertEqual(expected[pos],norm.getIdsInRange(-1.,1e-5).getValues()) + pass + expected2=[[3.,54.],[-141.,180.],[21.,54.],[39.,72.],[-15.,90.],[21.,90.]] + for pos,pt in enumerate(pts): + bary2=bary[:,:2] + bary2[:]+=pt + self.assertAlmostEqual(expected2[pos][0],bary2.accumulate()[0],12); + self.assertAlmostEqual(expected2[pos][1],bary2.accumulate()[1],12); + pass + expected3=[[-3.,22.5],[45.,337.5],[-9., 22.5],[-15.,67.5],[3.,112.5],[-9.,112.5]] + for pos,pt in enumerate(pts): + bary2=bary[:,:2] + bary2[:]*=pt + self.assertAlmostEqual(expected3[pos][0],bary2.accumulate()[0],12); + self.assertAlmostEqual(expected3[pos][1],bary2.accumulate()[1],12); + pass + expected4=[[-12.,90.],[0.8,6.],[-4,90.],[-2.4,30.],[12.,18],[-4,18.]] + for pos,pt in enumerate(pts): + bary2=bary[:,:2] + bary2[:]/=pt + self.assertAlmostEqual(expected4[pos][0],bary2.accumulate()[0],12); + self.assertAlmostEqual(expected4[pos][1],bary2.accumulate()[1],12); + pass + pass + def setUp(self): pass pass -- 2.39.2