Back to index

salome-med  6.5.0
MEDCouplingBasicsTest4.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDCouplingBasicsTest4.hxx"
00021 #include "MEDCouplingUMesh.hxx"
00022 #include "MEDCouplingCMesh.hxx"
00023 #include "MEDCouplingExtrudedMesh.hxx"
00024 #include "MEDCouplingFieldDouble.hxx"
00025 #include "MEDCouplingMemArray.hxx"
00026 #include "MEDCouplingGaussLocalization.hxx"
00027 #include "MEDCouplingMultiFields.hxx"
00028 #include "MEDCouplingFieldOverTime.hxx"
00029 
00030 #include <cmath>
00031 #include <functional>
00032 #include <iterator>
00033 
00034 using namespace ParaMEDMEM;
00035 
00036 void MEDCouplingBasicsTest4::testDescriptionInMeshTimeUnit1()
00037 {
00038   static const char text1[]="totoTTEDD";
00039   MEDCouplingUMesh *m=build2DTargetMesh_1();
00040   m->setDescription(text1);
00041   CPPUNIT_ASSERT(std::string(m->getDescription())==text1);
00042   MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCpy();
00043   CPPUNIT_ASSERT(m->isEqual(m2,1e-12));
00044   CPPUNIT_ASSERT(std::string(m2->getDescription())==text1);
00045   m2->setDescription("ggg");
00046   CPPUNIT_ASSERT(!m->isEqual(m2,1e-12));
00047   m2->decrRef();
00048   //
00049   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
00050   f->setTimeUnit(text1);
00051   CPPUNIT_ASSERT(std::string(f->getTimeUnit())==text1);
00052   MEDCouplingFieldDouble *f2=f->deepCpy();
00053   CPPUNIT_ASSERT(std::string(f2->getTimeUnit())==text1);
00054   f2->decrRef();
00055   //
00056   f->decrRef();
00057   m->decrRef();
00058 }
00059 
00060 void MEDCouplingBasicsTest4::testMultiFields1()
00061 {
00062   MEDCouplingMultiFields *mfs=buildMultiFields_1();
00063   std::vector<MEDCouplingMesh *> ms=mfs->getMeshes();
00064   std::vector<int> refs;
00065   std::vector<MEDCouplingMesh *> dms=mfs->getDifferentMeshes(refs);
00066   std::vector<DataArrayDouble *> das=mfs->getArrays();
00067   std::vector< std::vector<int> > refs2;
00068   std::vector<DataArrayDouble *> das2=mfs->getDifferentArrays(refs2);
00069   //
00070   CPPUNIT_ASSERT_EQUAL(5,(int)ms.size());
00071   CPPUNIT_ASSERT_EQUAL(2,(int)dms.size());
00072   CPPUNIT_ASSERT_EQUAL(6,(int)das.size());
00073   CPPUNIT_ASSERT_EQUAL(5,(int)das2.size());
00074   //
00075   MEDCouplingMultiFields *mfs2=mfs->deepCpy();
00076   CPPUNIT_ASSERT(mfs->isEqual(mfs2,1e-12,1e-12));
00077   mfs2->decrRef();
00078   //
00079   mfs->decrRef();
00080 }
00081 
00082 void MEDCouplingBasicsTest4::testFieldOverTime1()
00083 {
00084   std::vector<MEDCouplingFieldDouble *> fs=buildMultiFields_2();
00085   CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception);
00086   MEDCouplingFieldDouble *f4bis=fs[4]->buildNewTimeReprFromThis(ONE_TIME,false);
00087   fs[4]->decrRef();
00088   fs[4]=f4bis;
00089   CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception);
00090   f4bis->setTime(2.7,20,21);
00091   MEDCouplingFieldOverTime *fot=MEDCouplingFieldOverTime::New(fs);
00092   MEDCouplingDefinitionTime dt=fot->getDefinitionTimeZone();
00093   std::vector<double> hs=dt.getHotSpotsTime();
00094   CPPUNIT_ASSERT_EQUAL(6,(int)hs.size());
00095   const double expected1[]={0.2,0.7,1.2,1.35,1.7,2.7};
00096   for(int i=0;i<6;i++)
00097     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],hs[i],1e-12);
00098   int meshId,arrId,arrIdInField,fieldId;
00099   dt.getIdsOnTimeRight(0.2,meshId,arrId,arrIdInField,fieldId);
00100   CPPUNIT_ASSERT_EQUAL(0,meshId);
00101   CPPUNIT_ASSERT_EQUAL(0,arrId);
00102   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
00103   CPPUNIT_ASSERT_EQUAL(0,fieldId);
00104   //
00105   dt.getIdsOnTimeRight(0.7,meshId,arrId,arrIdInField,fieldId);
00106   CPPUNIT_ASSERT_EQUAL(0,meshId);
00107   CPPUNIT_ASSERT_EQUAL(1,arrId);
00108   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
00109   CPPUNIT_ASSERT_EQUAL(1,fieldId);
00110   //
00111   dt.getIdsOnTimeLeft(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING left here
00112   CPPUNIT_ASSERT_EQUAL(0,meshId);
00113   CPPUNIT_ASSERT_EQUAL(2,arrId);
00114   CPPUNIT_ASSERT_EQUAL(1,arrIdInField);
00115   CPPUNIT_ASSERT_EQUAL(1,fieldId);
00116   //
00117   dt.getIdsOnTimeRight(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING right again here
00118   CPPUNIT_ASSERT_EQUAL(1,meshId);
00119   CPPUNIT_ASSERT_EQUAL(3,arrId);
00120   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
00121   CPPUNIT_ASSERT_EQUAL(2,fieldId);
00122   //
00123   dt.getIdsOnTimeRight(1.35,meshId,arrId,arrIdInField,fieldId);
00124   CPPUNIT_ASSERT_EQUAL(1,meshId);
00125   CPPUNIT_ASSERT_EQUAL(3,arrId);
00126   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
00127   CPPUNIT_ASSERT_EQUAL(2,fieldId);
00128   //
00129   dt.getIdsOnTimeRight(1.7,meshId,arrId,arrIdInField,fieldId);
00130   CPPUNIT_ASSERT_EQUAL(0,meshId);
00131   CPPUNIT_ASSERT_EQUAL(3,arrId);
00132   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
00133   CPPUNIT_ASSERT_EQUAL(3,fieldId);
00134   //
00135   dt.getIdsOnTimeRight(2.7,meshId,arrId,arrIdInField,fieldId);
00136   CPPUNIT_ASSERT_EQUAL(1,meshId);
00137   CPPUNIT_ASSERT_EQUAL(4,arrId);
00138   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
00139   CPPUNIT_ASSERT_EQUAL(4,fieldId);
00140   //
00141   MEDCouplingDefinitionTime dt2;
00142   CPPUNIT_ASSERT(!dt2.isEqual(dt));
00143   dt2.assign(dt);
00144   dt2.assign(dt);//to check memory management
00145   CPPUNIT_ASSERT(dt2.isEqual(dt));
00146   //
00147   MEDCouplingDefinitionTime dt3;
00148   std::vector<int> tmp1;
00149   std::vector<double> tmp2;
00150   CPPUNIT_ASSERT(!dt2.isEqual(dt3));
00151   dt2.getTinySerializationInformation(tmp1,tmp2);
00152   dt3.unserialize(tmp1,tmp2);
00153   CPPUNIT_ASSERT(dt2.isEqual(dt3));
00154   //
00155   for(std::vector<MEDCouplingFieldDouble *>::iterator it=fs.begin();it!=fs.end();it++)
00156     (*it)->decrRef();
00157   fot->decrRef();
00158 }
00159 
00160 void MEDCouplingBasicsTest4::testDAICheckAndPreparePermutation1()
00161 {
00162   const int vals1[]={9,10,0,6,4,11,3,7};
00163   const int expect1[]={5,6,0,3,2,7,1,4};
00164   const int vals2[]={9,10,0,6,10,11,3,7};
00165   DataArrayInt *da=DataArrayInt::New();
00166   da->alloc(8,1);
00167   std::copy(vals1,vals1+8,da->getPointer());
00168   DataArrayInt *da2=da->checkAndPreparePermutation();
00169   CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
00170   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
00171   for(int i=0;i<8;i++)
00172     CPPUNIT_ASSERT_EQUAL(expect1[i],da2->getIJ(i,0));
00173   da2->decrRef();
00174   da->decrRef();
00175   //
00176   da=DataArrayInt::New();
00177   da->alloc(8,1);
00178   da->iota(0);
00179   da2=da->checkAndPreparePermutation();
00180   CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
00181   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
00182   CPPUNIT_ASSERT(da2->isIdentity());
00183   da2->decrRef();
00184   da->decrRef();
00185   //
00186   da=DataArrayInt::New();
00187   da->alloc(8,1);
00188   std::copy(vals2,vals2+8,da->getPointer());
00189   CPPUNIT_ASSERT_THROW(da->checkAndPreparePermutation(),INTERP_KERNEL::Exception);
00190   da->decrRef();
00191 }
00192 
00193 void MEDCouplingBasicsTest4::testDAIChangeSurjectiveFormat1()
00194 {
00195   const int vals1[8]={0,3,2,3,2,2,1,2};
00196   const int expected1[5]={0,1,2,6,8};
00197   const int expected2[8]={0,  6,  2,4,5,7,  1,3};
00198   DataArrayInt *da=DataArrayInt::New();
00199   da->alloc(8,1);
00200   std::copy(vals1,vals1+8,da->getPointer());
00201   //
00202   DataArrayInt *da2,*da2I;
00203   da->changeSurjectiveFormat(4,da2,da2I);
00204   CPPUNIT_ASSERT_EQUAL(5,da2I->getNumberOfTuples());
00205   CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
00206   CPPUNIT_ASSERT(std::equal(expected1,expected1+5,da2I->getConstPointer()));
00207   CPPUNIT_ASSERT(std::equal(expected2,expected2+8,da2->getConstPointer()));
00208   da2->decrRef();
00209   da2I->decrRef();
00210   //
00211   CPPUNIT_ASSERT_THROW(da->changeSurjectiveFormat(3,da2,da2I),INTERP_KERNEL::Exception);
00212   //
00213   da->decrRef();
00214 }
00215 
00216 void MEDCouplingBasicsTest4::testUMeshGetCellIdsLyingOnNodes1()
00217 {
00218   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
00219   const int nodeIds1[5]={1,2,3,4,6};
00220   const int nodeIds2[2]={6,7};
00221   DataArrayInt *da=m->getCellIdsLyingOnNodes(nodeIds1,nodeIds1+5,true);
00222   CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfTuples());
00223   CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
00224   CPPUNIT_ASSERT_EQUAL(1,da->getIJ(0,0));
00225   da->decrRef();
00226   da=m->getCellIdsLyingOnNodes(nodeIds2,nodeIds2+2,false);
00227   CPPUNIT_ASSERT_EQUAL(2,da->getNumberOfTuples());
00228   CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
00229   CPPUNIT_ASSERT_EQUAL(3,da->getIJ(0,0));
00230   CPPUNIT_ASSERT_EQUAL(4,da->getIJ(1,0));
00231   da->decrRef();
00232   //
00233   m->decrRef();
00234 }
00235 
00236 void MEDCouplingBasicsTest4::testUMeshFindCellsIdsOnBoundary1()
00237 {
00238   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
00239   DataArrayInt *da5=m->findCellsIdsOnBoundary();
00240   CPPUNIT_ASSERT_EQUAL(5,da5->getNumberOfTuples());
00241   CPPUNIT_ASSERT(da5->isIdentity());
00242   //
00243   da5->decrRef();
00244   m->decrRef();
00245 }
00246 
00247 void MEDCouplingBasicsTest4::testMeshSetTime1()
00248 {
00249   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
00250   MEDCouplingUMesh *m2=build3DSurfTargetMesh_1();
00251   //
00252   CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
00253   m1->setTime(3.14,6,7);
00254   int tmp1,tmp2;
00255   double tmp3=m1->getTime(tmp1,tmp2);
00256   CPPUNIT_ASSERT_EQUAL(6,tmp1);
00257   CPPUNIT_ASSERT_EQUAL(7,tmp2);
00258   CPPUNIT_ASSERT_DOUBLES_EQUAL(3.14,tmp3,1e-12);
00259   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
00260   m2->setTime(3.14,6,7);
00261   CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
00262   m1->setTimeUnit("ms");
00263   CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="ms");
00264   m1->setTimeUnit("us");
00265   CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="us");
00266   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
00267   m2->setTimeUnit("us");
00268   CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
00269   m2->setTime(3.14,6,8);
00270   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
00271   m2->setTime(3.14,7,7);
00272   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
00273   m2->setTime(3.15,6,7);
00274   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
00275   //
00276   m1->setTime(10.34,55,12);
00277   MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->deepCpy();
00278   CPPUNIT_ASSERT(m1->isEqual(m3,1e-12));
00279   tmp3=m3->getTime(tmp1,tmp2);
00280   CPPUNIT_ASSERT_EQUAL(55,tmp1);
00281   CPPUNIT_ASSERT_EQUAL(12,tmp2);
00282   CPPUNIT_ASSERT_DOUBLES_EQUAL(10.34,tmp3,1e-12);
00283   //
00284   m3->decrRef();
00285   m1->decrRef();
00286   m2->decrRef();
00287   // testing CMesh
00288   const double coo1[4]={0.,1.,2.,3.5};
00289   DataArrayDouble *a=DataArrayDouble::New();
00290   a->alloc(4,1);
00291   std::copy(coo1,coo1+4,a->getPointer());
00292   MEDCouplingCMesh *b=MEDCouplingCMesh::New();
00293   b->setCoordsAt(0,a);
00294   a->decrRef();
00295   //
00296   b->setTime(5.67,8,100);
00297   tmp3=b->getTime(tmp1,tmp2);
00298   CPPUNIT_ASSERT_EQUAL(8,tmp1);
00299   CPPUNIT_ASSERT_EQUAL(100,tmp2);
00300   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12);
00301   MEDCouplingCMesh *c=(MEDCouplingCMesh *)b->deepCpy();
00302   CPPUNIT_ASSERT(c->isEqual(b,1e-12));
00303   tmp3=c->getTime(tmp1,tmp2);
00304   CPPUNIT_ASSERT_EQUAL(8,tmp1);
00305   CPPUNIT_ASSERT_EQUAL(100,tmp2);
00306   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12);
00307   c->decrRef();
00308   b->decrRef();
00309 }
00310 
00311 void MEDCouplingBasicsTest4::testApplyFuncTwo1()
00312 {
00313   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
00314   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
00315   f1->setMesh(m1);
00316   //
00317   const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.};
00318   DataArrayDouble *da=DataArrayDouble::New();
00319   da->alloc(5,3);
00320   std::copy(vals,vals+15,da->getPointer());
00321   f1->setArray(da);
00322   //
00323   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"y+z"),INTERP_KERNEL::Exception);
00324   da->setInfoOnComponent(0,"x [m]");
00325   da->setInfoOnComponent(1,"y [mm]");
00326   da->setInfoOnComponent(2,"z [km]");
00327   
00328   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"x+y+zz+zzz"),INTERP_KERNEL::Exception);
00329   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"toto(x+y)"),INTERP_KERNEL::Exception);
00330   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"x/0"),INTERP_KERNEL::Exception);
00331   
00332   DataArrayDouble *da2=da->applyFunc2(1,"y+z");
00333   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
00334   CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples());
00335   const double expected1[5]={32.,34.,36.,38.,40.};
00336   for(int i=0;i<5;i++)
00337     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12);
00338   da2->decrRef();
00339   da2=da->applyFunc(1,"y+z");
00340   const double expected2[5]={12.,14.,16.,18.,20.};
00341   for(int i=0;i<5;i++)
00342     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],da2->getIJ(0,i),1e-12);
00343   da2->decrRef();
00344   //
00345   CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents());
00346   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
00347   f1->applyFunc2(1,"y+z");
00348   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
00349   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
00350   for(int i=0;i<5;i++)
00351     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
00352   //
00353   da->decrRef();
00354   f1->decrRef();
00355   m1->decrRef();
00356 }
00357 
00358 void MEDCouplingBasicsTest4::testApplyFuncThree1()
00359 {
00360   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
00361   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
00362   f1->setMesh(m1);
00363   //
00364   const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.};
00365   DataArrayDouble *da=DataArrayDouble::New();
00366   da->alloc(5,3);
00367   std::copy(vals,vals+15,da->getPointer());
00368   f1->setArray(da);
00369   //
00370   std::vector<std::string> vs(3);
00371   vs[0]="x"; vs[1]="Y"; vs[2]="z";
00372   CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"y+z"),INTERP_KERNEL::Exception);
00373   CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"x+Y+z+zz+zzz"),INTERP_KERNEL::Exception);
00374   CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"x/0."),INTERP_KERNEL::Exception);
00375   vs[1]="y";
00376   DataArrayDouble *da2=da->applyFunc3(1,vs,"y+z");
00377   const double expected1[5]={32.,34.,36.,38.,40.};
00378   for(int i=0;i<5;i++)
00379     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12);
00380   da2->decrRef();
00381   f1->setArray(da);
00382   CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents());
00383   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
00384   f1->applyFunc3(1,vs,"y+z");
00385   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
00386   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
00387   for(int i=0;i<5;i++)
00388     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
00389   //
00390   da->decrRef();
00391   f1->decrRef();
00392   m1->decrRef();
00393 }
00394 
00395 void MEDCouplingBasicsTest4::testFillFromAnalyticTwo1()
00396 {
00397   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
00398   CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic2(ON_NODES,1,"y+z"),INTERP_KERNEL::Exception);
00399   m1->getCoords()->setInfoOnComponent(0,"x [m]");
00400   m1->getCoords()->setInfoOnComponent(1,"y");
00401   m1->getCoords()->setInfoOnComponent(2,"z");
00402   MEDCouplingFieldDouble *f1=m1->fillFromAnalytic2(ON_NODES,1,"y+z");
00403   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
00404   CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
00405   const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2};
00406   for(int i=0;i<9;i++)
00407     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
00408   f1->decrRef();
00409   m1->decrRef();
00410 }
00411 
00412 void MEDCouplingBasicsTest4::testFillFromAnalyticThree1()
00413 {
00414   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
00415   std::vector<std::string> vs(3);
00416   vs[0]="x"; vs[1]="Y"; vs[2]="z";
00417   CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z"),INTERP_KERNEL::Exception);
00418   vs[1]="y";
00419   MEDCouplingFieldDouble *f1=m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z");
00420   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
00421   CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
00422   const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2};
00423   for(int i=0;i<9;i++)
00424     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
00425   f1->decrRef();
00426   m1->decrRef();
00427 }
00428 
00429 void MEDCouplingBasicsTest4::testDAUnitVar1()
00430 {
00431   DataArrayDouble *da=DataArrayDouble::New();
00432   da->alloc(1,3);
00433   da->setInfoOnComponent(0,"XPS [m]");
00434   std::string st1,st2;
00435   st1=da->getVarOnComponent(0);
00436   CPPUNIT_ASSERT(st1=="XPS");
00437   st2=da->getUnitOnComponent(0);
00438   CPPUNIT_ASSERT(st2=="m");
00439   //
00440   da->setInfoOnComponent(0,"XPS         [m]");
00441   st1=da->getVarOnComponent(0);
00442   CPPUNIT_ASSERT(st1=="XPS");
00443   st2=da->getUnitOnComponent(0);
00444   CPPUNIT_ASSERT(st2=="m");
00445   //
00446   da->setInfoOnComponent(0,"XPP         [m]");
00447   st1=da->getVarOnComponent(0);
00448   CPPUNIT_ASSERT(st1=="XPP");
00449   st2=da->getUnitOnComponent(0);
00450   CPPUNIT_ASSERT(st2=="m");
00451   //
00452   da->setInfoOnComponent(0,"XPP kdep  kefer   [ m  ]");
00453   st1=da->getVarOnComponent(0);
00454   CPPUNIT_ASSERT(st1=="XPP kdep  kefer");
00455   st2=da->getUnitOnComponent(0);
00456   CPPUNIT_ASSERT(st2==" m  ");
00457   //
00458   da->setInfoOnComponent(0,"     XPP k[  dep  k]efer   [ m^ 2/s^3*kJ  ]");
00459   st1=da->getVarOnComponent(0);
00460   CPPUNIT_ASSERT(st1=="     XPP k[  dep  k]efer");
00461   st2=da->getUnitOnComponent(0);
00462   CPPUNIT_ASSERT(st2==" m^ 2/s^3*kJ  ");
00463   //
00464   da->setInfoOnComponent(0,"     XPP kefer   ");
00465   st1=da->getVarOnComponent(0);
00466   CPPUNIT_ASSERT(st1=="     XPP kefer   ");
00467   st2=da->getUnitOnComponent(0);
00468   CPPUNIT_ASSERT(st2=="");
00469   //
00470   da->setInfoOnComponent(0,"temperature( bof)");
00471   st1=da->getVarOnComponent(0);
00472   CPPUNIT_ASSERT(st1=="temperature( bof)");
00473   st2=da->getUnitOnComponent(0);
00474   CPPUNIT_ASSERT(st2=="");
00475   //
00476   da->setInfoOnComponent(0,"kkk [m]");
00477   da->setInfoOnComponent(1,"ppp   [m^2/kJ]");
00478   da->setInfoOnComponent(2,"abcde   [MW/s]");
00479   //
00480   std::vector<std::string> vs;
00481   vs=da->getVarsOnComponent();
00482   CPPUNIT_ASSERT_EQUAL(3,(int)vs.size());
00483   CPPUNIT_ASSERT(vs[0]=="kkk");
00484   CPPUNIT_ASSERT(vs[1]=="ppp");
00485   CPPUNIT_ASSERT(vs[2]=="abcde");
00486   vs=da->getUnitsOnComponent();
00487   CPPUNIT_ASSERT_EQUAL(3,(int)vs.size());
00488   CPPUNIT_ASSERT(vs[0]=="m");
00489   CPPUNIT_ASSERT(vs[1]=="m^2/kJ");
00490   CPPUNIT_ASSERT(vs[2]=="MW/s");
00491   //
00492   da->decrRef();
00493 }
00494 
00495 void MEDCouplingBasicsTest4::testGaussCoordinates1()
00496 {
00497   //Testing 1D cell types
00498   MEDCouplingUMesh *m1=build1DMultiTypes_1();
00499   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
00500   f->setMesh(m1);
00501   std::vector<double> wg1(1); wg1[0]=0.3;
00502   std::vector<double> gsCoo1(1); gsCoo1[0]=0.2;
00503   std::vector<double> refCoo1(2); refCoo1[0]=-1.0; refCoo1[1]=1.0;
00504   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG2,refCoo1,gsCoo1,wg1);
00505   std::vector<double> wg2(wg1);
00506   std::vector<double> gsCoo2(1); gsCoo2[0]=0.2;
00507   std::vector<double> refCoo2(3); refCoo2[0]=-1.0; refCoo2[1]=1.0; refCoo2[2]=0.0;
00508   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG3,refCoo2,gsCoo2,wg2);
00509   //
00510   DataArrayDouble *resToTest=f->getLocalizationOfDiscr();
00511   CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
00512   CPPUNIT_ASSERT_EQUAL(2,resToTest->getNumberOfTuples());
00513   const double expected1[6]={0.6,0.6,0.6, 0.6,0.6,0.6};
00514   for(int i=0;i<6;i++)
00515     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],resToTest->getIJ(0,i),1e-14);
00516   resToTest->decrRef();
00517   //
00518   m1->decrRef();
00519   f->decrRef();
00520   //Testing 2D cell types
00521   MEDCouplingUMesh *m2=build2DMultiTypes_1();
00522   f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
00523   f->setMesh(m2);
00524   std::vector<double> wg3(2); wg3[0]=0.3; wg3[1]=0.3;
00525   const double tria3CooGauss[4]={ 0.1, 0.8, 0.2, 0.7 };
00526   std::vector<double> gsCoo3(tria3CooGauss,tria3CooGauss+4);
00527   const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 };
00528   std::vector<double> refCoo3(tria3CooRef,tria3CooRef+6);
00529   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,refCoo3,gsCoo3,wg3);
00530   std::vector<double> wg4(3); wg4[0]=0.3; wg4[1]=0.3; wg4[2]=0.3;
00531   const double tria6CooGauss[6]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 };
00532   std::vector<double> gsCoo4(tria6CooGauss,tria6CooGauss+6);
00533   const double tria6CooRef[12]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5};
00534   std::vector<double> refCoo4(tria6CooRef,tria6CooRef+12);
00535   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,refCoo4,gsCoo4,wg4);
00536   std::vector<double> wg5(4); wg5[0]=0.3; wg5[1]=0.3; wg5[2]=0.3; wg5[3]=0.3;
00537   const double quad4CooGauss[8]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 };
00538   std::vector<double> gsCoo5(quad4CooGauss,quad4CooGauss+8);
00539   const double quad4CooRef[8]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0};
00540   std::vector<double> refCoo5(quad4CooRef,quad4CooRef+8);
00541   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,refCoo5,gsCoo5,wg5);
00542   std::vector<double> wg6(4); wg6[0]=0.3; wg6[1]=0.3; wg6[2]=0.3; wg6[3]=0.3;
00543   const double quad8CooGauss[8]={ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 };
00544   std::vector<double> gsCoo6(quad8CooGauss,quad8CooGauss+8);
00545   const double quad8CooRef[16]={ -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};
00546   std::vector<double> refCoo6(quad8CooRef,quad8CooRef+16);
00547   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD8,refCoo6,gsCoo6,wg6);
00548   //
00549   resToTest=f->getLocalizationOfDiscr();
00550   CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
00551   CPPUNIT_ASSERT_EQUAL(13,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
00552   const double expected2[39]={5.1,1.55,0.0, 4.7,1.65,0.0, //TRI3
00553                               2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,//TRI6
00554                               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
00555                               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
00556   for(int i=0;i<39;i++)
00557     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],resToTest->getIJ(0,i),1e-14);
00558   resToTest->decrRef();
00559   //
00560   m2->decrRef();
00561   f->decrRef();
00562   //Testing 3D cell types
00563   MEDCouplingUMesh *m3=build3DMultiTypes_1();
00564   f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
00565   f->setMesh(m3);
00566   //
00567   std::vector<double> wg7(1); wg7[0]=0.3;
00568   const double tetra4CooGauss[3]={0.34, 0.16, 0.21};
00569   std::vector<double> gsCoo7(tetra4CooGauss,tetra4CooGauss+3);
00570   const double tetra4CooRef[12]={0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0};
00571   std::vector<double> refCoo7(tetra4CooRef,tetra4CooRef+12);
00572   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA4,refCoo7,gsCoo7,wg7);
00573   std::vector<double> wg8(1); wg8[0]=0.3;
00574   const double tetra10CooGauss[3]={0.2, 0.3, 0.1};
00575   std::vector<double> gsCoo8(tetra10CooGauss,tetra10CooGauss+3);
00576   const double tetra10CooRef[30]={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};
00577   std::vector<double> refCoo8(tetra10CooRef,tetra10CooRef+30);
00578   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA10,refCoo8,gsCoo8,wg8);
00579   std::vector<double> wg9(1); wg9[0]=0.3;
00580   const double pyra5CooGauss[3]={0.2, 0.3, 0.1};
00581   std::vector<double> gsCoo9(pyra5CooGauss,pyra5CooGauss+3);
00582   const double pyra5CooRef[15]={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};
00583   std::vector<double> refCoo9(pyra5CooRef,pyra5CooRef+15);
00584   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA5,refCoo9,gsCoo9,wg9);
00585   std::vector<double> wg10(1); wg10[0]=0.3;
00586   const double pyra13CooGauss[3]={0.1, 0.2, 0.7};
00587   std::vector<double> gsCoo10(pyra13CooGauss,pyra13CooGauss+3);
00588   const double pyra13CooRef[39]={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};
00589   std::vector<double> refCoo10(pyra13CooRef,pyra13CooRef+39);
00590   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA13,refCoo10,gsCoo10,wg10);
00591   std::vector<double> wg11(1); wg11[0]=0.3;
00592   const double penta6CooGauss[3]={0.2, 0.3, 0.1};
00593   std::vector<double> gsCoo11(penta6CooGauss,penta6CooGauss+3);
00594   const double penta6CooRef[18]={-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};
00595   std::vector<double> refCoo11(penta6CooRef,penta6CooRef+18);
00596   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA6,refCoo11,gsCoo11,wg11);
00597   std::vector<double> wg12(1); wg12[0]=0.3;
00598   const double penta15CooGauss[3]={0.2, 0.3,0.15};
00599   std::vector<double> gsCoo12(penta15CooGauss,penta15CooGauss+3);
00600   const double penta15CooRef[45]={-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};
00601   std::vector<double> refCoo12(penta15CooRef,penta15CooRef+45);
00602   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA15,refCoo12,gsCoo12,wg12);
00603   std::vector<double> wg13(1); wg13[0]=0.3;
00604   const double hexa8CooGauss[3]={0.2,0.3,0.15};
00605   std::vector<double> gsCoo13(hexa8CooGauss,hexa8CooGauss+3);
00606   const double hexa8CooRef[24]={-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};
00607   std::vector<double> refCoo13(hexa8CooRef,hexa8CooRef+24);
00608   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA8,refCoo13,gsCoo13,wg13);
00609   std::vector<double> wg14(1); wg14[0]=0.3;
00610   const double hexa20CooGauss[3]={0.11,0.3,0.55};
00611   std::vector<double> gsCoo14(hexa20CooGauss,hexa20CooGauss+3);
00612   const double hexa20CooRef[60]={-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};
00613   std::vector<double> refCoo14(hexa20CooRef,hexa20CooRef+60);
00614   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA20,refCoo14,gsCoo14,wg14);
00615   //
00616   resToTest=f->getLocalizationOfDiscr();
00617   CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
00618   CPPUNIT_ASSERT_EQUAL(8,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
00619   const double expected3[24]={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};
00620   for(int i=0;i<24;i++)
00621     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],resToTest->getIJ(0,i),1e-14);
00622   resToTest->decrRef();
00623   //
00624   m3->decrRef();
00625   f->decrRef();
00626 }
00627 
00631 void MEDCouplingBasicsTest4::testQ1Localization1()
00632 {
00633   MEDCouplingUMesh *m=buildHexa8Mesh_1();
00634   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
00635   DataArrayDouble *da=DataArrayDouble::New();
00636   const double vals1[27]={1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0};
00637   da->alloc(27,1);
00638   std::copy(vals1,vals1+27,da->getPointer());
00639   f->setMesh(m);
00640   f->setArray(da);
00641   da->decrRef();
00642   //
00643   const double point1[3]={0.25,0.75,0.25};
00644   //const double points1[6]={0.25,0.75,0.25,1.0,1.0,1.0};
00645   double res1[3];
00646   f->getValueOn(point1,res1);
00647   //
00648   f->decrRef();
00649   m->decrRef();
00650 }
00651 
00652 void MEDCouplingBasicsTest4::testP2Localization1()
00653 {
00654   MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2",2);
00655   const double coords[12]={0.,2.,3.5,0.,4.5,1.5,1.2,0.32,3.4,1.,2.1,2.4};
00656   const int conn[6]={0,1,2,3,4,5};
00657   DataArrayDouble *coo=DataArrayDouble::New();
00658   coo->alloc(6,2);
00659   std::copy(coords,coords+12,coo->getPointer());
00660   m->setCoords(coo);
00661   coo->decrRef();
00662   m->allocateCells(1);
00663   m->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn);
00664   m->finishInsertingCells();
00665   //
00666   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
00667   f->setMesh(m);
00668   DataArrayDouble *da=DataArrayDouble::New();
00669   da->alloc(6,3);
00670   const double vals1[18]={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};
00671   std::copy(vals1,vals1+18,da->getPointer());
00672   f->setArray(da);
00673   da->decrRef();
00674   //
00675   const double loc[2]={2.27,1.3};
00676   DataArrayDouble *locs=f->getValueOnMulti(loc,1);
00677   const double expected1[3]={6.0921164547752236, 7.1921164547752232, 8.2921164547752255};
00678   for(int i=0;i<3;i++)
00679     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12);
00680   locs->decrRef();
00681   //
00682   m->decrRef();
00683   f->decrRef();
00684 }
00685 
00686 void MEDCouplingBasicsTest4::testP2Localization2()
00687 {
00688   MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2_2",3);
00689   const double coords[30]={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};
00690   const int conn[10]={0,1,2,3,4,5,6,7,8,9};
00691   DataArrayDouble *coo=DataArrayDouble::New();
00692   coo->alloc(10,3);
00693   std::copy(coords,coords+30,coo->getPointer());
00694   m->setCoords(coo);
00695   coo->decrRef();
00696   m->allocateCells(1);
00697   m->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn);
00698   m->finishInsertingCells();
00699   //
00700   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
00701   f->setMesh(m);
00702   DataArrayDouble *da=DataArrayDouble::New();
00703   da->alloc(10,1);
00704   const double vals1[10]={1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2};
00705   std::copy(vals1,vals1+10,da->getPointer());
00706   f->setArray(da);
00707   da->decrRef();
00708   //
00709   const double loc[3]={0.64637931739890486, -0.16185896817550552, 0.22678966365273748};
00710   DataArrayDouble *locs=f->getValueOnMulti(loc,1);
00711   const double expected1[1]={10.0844021968047};
00712   for(int i=0;i<1;i++)
00713     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12);
00714   locs->decrRef();
00715   //
00716   m->decrRef();
00717   f->decrRef();
00718 }
00719 
00720 void MEDCouplingBasicsTest4::testGetValueOn2()
00721 {
00722   MEDCouplingUMesh *m=build2DTargetMesh_1();
00723   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
00724   f->setMesh(m);
00725   DataArrayDouble *arr=DataArrayDouble::New();
00726   int nbOfCells=m->getNumberOfCells();
00727   arr->alloc(nbOfCells,3);
00728   f->setArray(arr);
00729   arr->decrRef();
00730   const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.};
00731   std::copy(values1,values1+15,arr->getPointer());
00732   const double loc[10]={-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45};
00733   f->checkCoherency();
00734   DataArrayDouble *locs=f->getValueOnMulti(loc,5);
00735   CPPUNIT_ASSERT_EQUAL(5,locs->getNumberOfTuples());
00736   CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
00737   for(int j=0;j<15;j++)
00738     CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[j],locs->getIJ(0,j),1e-12);
00739   locs->decrRef();
00740   f->decrRef();
00741   // Testing ON_NODES
00742   f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
00743   f->setMesh(m);
00744   arr=DataArrayDouble::New();
00745   int nbOfNodes=m->getNumberOfNodes();
00746   arr->alloc(nbOfNodes,3);
00747   f->setArray(arr);
00748   arr->decrRef();
00749   const double values2[27]={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.};
00750   std::copy(values2,values2+27,arr->getPointer());
00751   const double loc2[8]={0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432};
00752   const double expected2[12]={9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272};
00753   f->checkCoherency();
00754   locs=f->getValueOnMulti(loc2,4);
00755   CPPUNIT_ASSERT_EQUAL(4,locs->getNumberOfTuples());
00756   CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
00757   for(int i=0;i<12;i++)
00758     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],locs->getIJ(0,i),1e-12);
00759   f->decrRef();
00760   locs->decrRef();
00761   //
00762   m->decrRef();
00763 }
00764 
00765 void MEDCouplingBasicsTest4::testDAIGetIdsNotEqual1()
00766 {
00767   DataArrayInt *d=DataArrayInt::New();
00768   const int vals1[10]={2,3,5,6,8,5,5,6,1,-5};
00769   d->alloc(10,1);
00770   std::copy(vals1,vals1+10,d->getPointer());
00771   DataArrayInt *d2=d->getIdsNotEqual(5);
00772   CPPUNIT_ASSERT_EQUAL(7,d2->getNumberOfTuples());
00773   CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents());
00774   const int expected1[7]={0,1,3,4,7,8,9};
00775   for(int i=0;i<7;i++)
00776     CPPUNIT_ASSERT_EQUAL(expected1[i],d2->getIJ(0,i));
00777   d->rearrange(2);
00778   CPPUNIT_ASSERT_THROW(d->getIdsNotEqual(5),INTERP_KERNEL::Exception);
00779   const int vals2[3]={-4,5,6};
00780   std::vector<int> vals3(vals2,vals2+3);
00781   d->rearrange(1);
00782   DataArrayInt *d3=d->getIdsNotEqualList(vals3);
00783   CPPUNIT_ASSERT_EQUAL(5,d3->getNumberOfTuples());
00784   CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents());
00785   const int expected2[5]={0,1,4,8,9};
00786   for(int i=0;i<5;i++)
00787     CPPUNIT_ASSERT_EQUAL(expected2[i],d3->getIJ(0,i));
00788   d3->decrRef();
00789   d->decrRef();
00790   d2->decrRef();
00791 }
00792 
00793 void MEDCouplingBasicsTest4::testDAIComputeOffsets1()
00794 {
00795   DataArrayInt *d=DataArrayInt::New();
00796   const int vals1[6]={3,5,1,2,0,8};
00797   const int expected1[6]={0,3,8,9,11,11};
00798   d->alloc(6,1);
00799   std::copy(vals1,vals1+6,d->getPointer());
00800   d->computeOffsets();
00801   CPPUNIT_ASSERT_EQUAL(6,d->getNumberOfTuples());
00802   CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
00803   for(int i=0;i<6;i++)
00804     CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
00805   d->decrRef();
00806 }
00807 
00808 void MEDCouplingBasicsTest4::testUMeshHexagonPrism1()
00809 {
00810   const double coords[36]={
00811     0.8660254037844386, 0.5, 0.0, 0.0, 1.0, 0.0, -0.8660254037844386, 0.5, 0.0, -0.8660254037844386, -0.5, 0.0, 0.0, -1.0, 0.0, 0.8660254037844386, -0.5, 0.0,
00812     0.8660254037844386, 0.5, 2.0, 0.0, 1.0, 2.0, -0.8660254037844386, 0.5, 2.0, -0.8660254037844386, -0.5, 2.0, 0.0, -1.0, 2.0, 0.8660254037844386, -0.5, 2.0
00813   };
00814   const int conn[12]={1,2,3,4,5,0,7,8,9,10,11,6};
00815   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("MyFirstHexagonalPrism",3);
00816   DataArrayDouble *coo=DataArrayDouble::New();
00817   coo->alloc(12,3);
00818   std::copy(coords,coords+36,coo->getPointer());
00819   mesh->setCoords(coo);
00820   mesh->allocateCells(1);
00821   mesh->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn);
00822   mesh->finishInsertingCells();
00823   coo->decrRef();
00824   //
00825   mesh->checkCoherency();
00826   MEDCouplingFieldDouble *vols=mesh->getMeasureField(false);
00827   CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfTuples());
00828   CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfComponents());
00829   CPPUNIT_ASSERT_DOUBLES_EQUAL(-5.196152422706632,vols->getIJ(0,0),1e-12);
00830   DataArrayDouble *bary=mesh->getBarycenterAndOwner();
00831   CPPUNIT_ASSERT_EQUAL(1,bary->getNumberOfTuples());
00832   CPPUNIT_ASSERT_EQUAL(3,bary->getNumberOfComponents());
00833   const double expected1[3]={0.,0.,1.};
00834   for(int i=0;i<3;i++)
00835     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],bary->getIJ(0,i),1e-12);
00836   DataArrayInt *d1=DataArrayInt::New();
00837   DataArrayInt *d2=DataArrayInt::New();
00838   DataArrayInt *d3=DataArrayInt::New();
00839   DataArrayInt *d4=DataArrayInt::New();
00840   MEDCouplingUMesh *m2=mesh->buildDescendingConnectivity(d1,d2,d3,d4);
00841   CPPUNIT_ASSERT_EQUAL(8,m2->getNumberOfCells());
00842   const int expected4[8][6]={{1,2,3,4,5,0},{7,6,11,10,9,8},{1,7,8,2},{2,8,9,3},{3,9,10,4},{4,10,11,5},{5,11,6,0},{0,6,7,1}};
00843   const INTERP_KERNEL::NormalizedCellType expected2[8]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4};
00844   const int expected3[8]={6,6,4,4,4,4,4,4};
00845   for(int i=0;i<8;i++)
00846     {
00847       CPPUNIT_ASSERT(m2->getTypeOfCell(i)==expected2[i]);
00848       std::vector<int> v;
00849       m2->getNodeIdsOfCell(i,v);
00850       CPPUNIT_ASSERT((int)v.size()==expected3[i]);
00851       CPPUNIT_ASSERT(std::equal(expected4[i],expected4[i]+expected3[i],v.begin()));
00852     }
00853   d1->decrRef();
00854   d2->decrRef();
00855   d3->decrRef();
00856   d4->decrRef();
00857   m2->decrRef();
00858   //
00859   mesh->convertAllToPoly();
00860   CPPUNIT_ASSERT(INTERP_KERNEL::NORM_POLYHED==mesh->getTypeOfCell(0));
00861   mesh->unPolyze();
00862   CPPUNIT_ASSERT(INTERP_KERNEL::NORM_HEXGP12==mesh->getTypeOfCell(0));
00863   CPPUNIT_ASSERT_EQUAL(13,mesh->getMeshLength());
00864   //
00865   vols->decrRef();
00866   bary->decrRef();
00867   mesh->decrRef();
00868 }
00869 
00870 void MEDCouplingBasicsTest4::testDADCheckIsMonotonic()
00871 {
00872   DataArrayDouble *da=DataArrayDouble::New();
00873   const double vals[4]={-1.,1.01,2.03,6.};
00874   da->alloc(2,2);
00875   std::copy(vals,vals+4,da->getPointer());
00876   CPPUNIT_ASSERT_THROW(da->isMonotonic(true, 1e-12),INTERP_KERNEL::Exception);
00877   da->rearrange(1);
00878   CPPUNIT_ASSERT(da->isMonotonic(true, 1e-12));
00879   da->checkMonotonic(true, 1e-12);
00880   da->setIJ(2,0,6.1);
00881   CPPUNIT_ASSERT(!da->isMonotonic(true, 1e-12));
00882   CPPUNIT_ASSERT_THROW(da->checkMonotonic(true, 1e-12),INTERP_KERNEL::Exception);
00883   CPPUNIT_ASSERT_THROW(da->checkMonotonic(false, 1e-12),INTERP_KERNEL::Exception);
00884   da->setIJ(2,0,5.99);
00885   CPPUNIT_ASSERT(da->isMonotonic(true, 1e-12));
00886   CPPUNIT_ASSERT(!da->isMonotonic(true, 1e-1));
00887   da->decrRef();
00888 }
00889 
00890 void MEDCouplingBasicsTest4::testCheckCoherencyDeeper1()
00891 {
00892   MEDCouplingUMesh *m=build3DSourceMesh_1();
00893   m->checkCoherency();
00894   m->checkCoherency1();
00895   m->getNodalConnectivity()->setIJ(8,0,-1);
00896   m->checkCoherency();
00897   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
00898   m->getNodalConnectivity()->setIJ(8,0,-6);
00899   m->checkCoherency();
00900   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
00901   m->getNodalConnectivity()->setIJ(8,0,9);//9>=NbOfNodes
00902   m->checkCoherency();
00903   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
00904   m->getNodalConnectivity()->setIJ(8,0,8);//OK
00905   m->checkCoherency();
00906   m->checkCoherency1();
00907   const int elts[2]={1,5};
00908   std::vector<int> eltsV(elts,elts+2);
00909   m->convertToPolyTypes(&eltsV[0],&eltsV[0]+eltsV.size());
00910   m->checkCoherency();
00911   m->checkCoherency1();
00912   m->getNodalConnectivity()->setIJ(2,0,9);//9>=NbOfNodes
00913   m->checkCoherency();
00914   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
00915   m->getNodalConnectivity()->setIJ(2,0,-3);
00916   m->checkCoherency();
00917   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
00918   m->getNodalConnectivity()->setIJ(2,0,-1);
00919   m->checkCoherency();
00920   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);//Throw because cell#0 is not a polyhedron
00921   m->getNodalConnectivity()->setIJ(2,0,4);
00922   m->checkCoherency();
00923   m->checkCoherency1();
00924   m->getNodalConnectivity()->setIJ(7,0,-1);
00925   m->checkCoherency();
00926   m->checkCoherency1();//OK because we are in polyhedron connec
00927   m->getNodalConnectivity()->setIJ(36,0,14);
00928   m->checkCoherency();
00929   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);//Throw beacause now cell 5 is a TETRA4 (14) so mimatch of number index and static type.
00930   m->decrRef();
00931 }
00932 
00933 void MEDCouplingBasicsTest4::testUnPolyze2()
00934 {
00935   MEDCouplingUMesh *m=MEDCouplingUMesh::New("jjj",3);
00936   DataArrayDouble *coo=DataArrayDouble::New();
00937   coo->alloc(4,3);
00938   coo->rearrange(1);
00939   coo->iota(0);
00940   coo->rearrange(3);
00941   m->setCoords(coo);
00942   coo->decrRef();
00943   m->allocateCells(2);
00944   const int conn[4]={0,1,2,3};
00945   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
00946   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
00947   m->finishInsertingCells();
00948   std::vector<const MEDCouplingUMesh *> ms(4,m);
00949   MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms);
00950   std::vector<int> temp(1,2);
00951   m2->convertToPolyTypes(&temp[0],&temp[0]+temp.size());
00952   m2->unPolyze();
00953   CPPUNIT_ASSERT(INTERP_KERNEL::NORM_TETRA4==m2->getTypeOfCell(2));
00954   CPPUNIT_ASSERT_EQUAL(40,m2->getMeshLength());
00955   std::vector<int> temp2;
00956   m2->getNodeIdsOfCell(2,temp2);
00957   CPPUNIT_ASSERT(4==(int)temp2.size());
00958   CPPUNIT_ASSERT(std::equal(conn,conn+4,temp2.begin()));
00959   m2->checkCoherency1();
00960   MEDCouplingMesh *m3=m2->deepCpy();
00961   m2->unPolyze();
00962   CPPUNIT_ASSERT(m3->isEqual(m2,1e-12));
00963   m3->decrRef();
00964   m->decrRef();
00965   m2->decrRef();
00966 }
00967 
00968 void MEDCouplingBasicsTest4::testDACpyFrom1()
00969 {
00970   DataArrayDouble *d=DataArrayDouble::New();
00971   d->alloc(12,1);
00972   d->iota(14.);
00973   d->rearrange(3);
00974   d->setName("Toto");
00975   d->setInfoOnComponent(0,"X [m]");
00976   d->setInfoOnComponent(1,"Y [m]");
00977   d->setInfoOnComponent(2,"Z [m]");
00978   //
00979   DataArrayDouble *d1=DataArrayDouble::New();
00980   CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12));
00981   d1->cpyFrom(*d);
00982   CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
00983   d1->cpyFrom(*d);
00984   CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
00985   d1->rearrange(2);
00986   CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12));
00987   d1->cpyFrom(*d);
00988   CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
00989   //
00990   DataArrayInt *d2=d->convertToIntArr();
00991   DataArrayInt *d4=DataArrayInt::New();
00992   CPPUNIT_ASSERT(!d2->isEqual(*d4));
00993   d4->cpyFrom(*d2);
00994   CPPUNIT_ASSERT(d2->isEqual(*d4));
00995   d4->cpyFrom(*d2);
00996   CPPUNIT_ASSERT(d2->isEqual(*d4));
00997   d4->rearrange(2);
00998   CPPUNIT_ASSERT(!d2->isEqual(*d4));
00999   d4->cpyFrom(*d2);
01000   CPPUNIT_ASSERT(d2->isEqual(*d4));
01001   //
01002   d->decrRef();
01003   d1->decrRef();
01004   d2->decrRef();
01005   d4->decrRef();
01006 }
01007 
01008 void MEDCouplingBasicsTest4::testDAITransformWithIndArr1()
01009 {
01010   const int tab1[4]={17,18,22,19};
01011   const int tab2[12]={0,1,1,3,3,0,1,3,2,2,3,0};
01012   const int expected[12]={17,18,18,19,19,17,18,19,22,22,19,17};
01013   DataArrayInt *d=DataArrayInt::New();
01014   d->alloc(4,1);
01015   std::copy(tab1,tab1+4,d->getPointer());
01016   DataArrayInt *d1=DataArrayInt::New();
01017   d1->alloc(12,1);
01018   std::copy(tab2,tab2+12,d1->getPointer());
01019   //
01020   d1->transformWithIndArr(d->getConstPointer(),d->getConstPointer()+d->getNbOfElems());
01021   CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples());
01022   CPPUNIT_ASSERT_EQUAL(1,d1->getNumberOfComponents());
01023   for(int i=0;i<12;i++)
01024     CPPUNIT_ASSERT_EQUAL(expected[i],d1->getIJ(i,0));
01025   //
01026   d->decrRef();
01027   d1->decrRef();
01028 }
01029 
01030 void MEDCouplingBasicsTest4::testDAIBuildPermArrPerLevel1()
01031 {
01032   const int arr[12]={2,0,1,1,0,1,2,0,1,1,0,0};
01033   const int expected1[12]={10,0,5,6,1,7,11,2,8,9,3,4};
01034   DataArrayInt *da=DataArrayInt::New();
01035   da->alloc(12,1);
01036   std::copy(arr,arr+12,da->getPointer());
01037   DataArrayInt *da2=da->buildPermArrPerLevel();
01038   CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples());
01039   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
01040   for(int i=0;i<12;i++)
01041     CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0));
01042   da->decrRef();
01043   da2->decrRef();
01044 }
01045 
01046 void MEDCouplingBasicsTest4::testDAIOperations1()
01047 {
01048   const int arr1[12]={-1,-2,4,7,3,2,6,6,4,3,0,1};
01049   DataArrayInt *da=DataArrayInt::New();
01050   da->alloc(4,3);
01051   std::copy(arr1,arr1+12,da->getPointer());
01052   DataArrayInt *da1=DataArrayInt::New();
01053   da1->alloc(12,1);
01054   da1->iota(2);
01055   CPPUNIT_ASSERT_THROW(DataArrayInt::Add(da,da1),INTERP_KERNEL::Exception);//not same number of tuples/Components
01056   da1->rearrange(3);
01057   DataArrayInt *da2=DataArrayInt::Add(da,da1);
01058   CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
01059   CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
01060   const int expected1[12]={1,1,8,12,9,9,14,15,14,14,12,14};
01061   for(int i=0;i<12;i++)
01062     CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i));
01063   da2->decrRef();
01064   da1->substractEqual(da);
01065   const int expected2[12]={3,5,0,-2,3,5,2,3,6,8,12,12};
01066   for(int i=0;i<12;i++)
01067     CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i));
01068   da1->rearrange(1); da1->iota(2); da1->rearrange(3);
01069   da1->addEqual(da);
01070   for(int i=0;i<12;i++)
01071     CPPUNIT_ASSERT_EQUAL(expected1[i],da1->getIJ(0,i));
01072   da1->rearrange(1); da1->iota(2); da1->rearrange(3);
01073   da2=DataArrayInt::Multiply(da,da1);
01074   CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
01075   CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
01076   const int expected3[12]={-2,-6,16,35,18,14,48,54,40,33,0,13};
01077   for(int i=0;i<12;i++)
01078     CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i));
01079   da2->decrRef();
01080   da->divideEqual(da1);
01081   CPPUNIT_ASSERT_EQUAL(4,da->getNumberOfTuples());
01082   CPPUNIT_ASSERT_EQUAL(3,da->getNumberOfComponents());
01083   const int expected4[12]={0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
01084   for(int i=0;i<12;i++)
01085     CPPUNIT_ASSERT_EQUAL(expected4[i],da->getIJ(0,i));
01086   std::copy(arr1,arr1+12,da->getPointer());
01087   da1->multiplyEqual(da);
01088   CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
01089   CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
01090   for(int i=0;i<12;i++)
01091     CPPUNIT_ASSERT_EQUAL(expected3[i],da1->getIJ(0,i));
01092   da1->rearrange(1); da1->iota(2); da1->rearrange(3);
01093   da2=DataArrayInt::Divide(da,da1);
01094   CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
01095   CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
01096   for(int i=0;i<12;i++)
01097     CPPUNIT_ASSERT_EQUAL(expected4[i],da2->getIJ(0,i));
01098   da2->decrRef();
01099   da1->applyInv(321);
01100   CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
01101   CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
01102   const int expected5[12]={160,107,80,64,53,45,40,35,32,29,26,24};
01103   for(int i=0;i<12;i++)
01104     CPPUNIT_ASSERT_EQUAL(expected5[i],da1->getIJ(0,i));
01105   da1->applyDivideBy(2);
01106   CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
01107   CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
01108   const int expected6[12]={80,53,40,32,26,22,20,17,16,14,13,12};
01109   for(int i=0;i<12;i++)
01110     CPPUNIT_ASSERT_EQUAL(expected6[i],da1->getIJ(0,i));
01111   const int expected7[12]={3,4,5,4,5,1,6,3,2,0,6,5};
01112   da1->applyModulus(7);
01113   for(int i=0;i<12;i++)
01114     CPPUNIT_ASSERT_EQUAL(expected7[i],da1->getIJ(0,i));
01115   da1->applyLin(1,1);
01116   const int expected8[12]={3,3,3,3,3,1,3,3,0,0,3,3};
01117   da1->applyRModulus(3);
01118   for(int i=0;i<12;i++)
01119     CPPUNIT_ASSERT_EQUAL(expected8[i],da1->getIJ(0,i));
01120   //
01121   da1->decrRef();
01122   da->decrRef();
01123 }
01124 
01125 void MEDCouplingBasicsTest4::testEmulateMEDMEMBDC1()
01126 {
01127   MEDCouplingUMesh *m1=0;
01128   MEDCouplingUMesh *m=buildPointe_1(m1);
01129   DataArrayInt *da1=DataArrayInt::New();
01130   DataArrayInt *da2=DataArrayInt::New();
01131   DataArrayInt *da3=0;
01132   DataArrayInt *da4=0;
01133   DataArrayInt *da5=0;
01134   DataArrayInt *da0=0;
01135   MEDCouplingUMesh *m2=m->emulateMEDMEMBDC(m1,da1,da2,da3,da4,da5,da0);
01136   const int expected0[47]={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};
01137   const int expected1[6]={1,32,29,23,41,36};
01138   CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples());
01139   CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents());
01140   for(int i=0;i<47;i++)
01141     CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i));
01142   CPPUNIT_ASSERT_EQUAL(6,da5->getNumberOfTuples());
01143   CPPUNIT_ASSERT_EQUAL(1,da5->getNumberOfComponents());
01144   for(int i=0;i<6;i++)
01145     CPPUNIT_ASSERT_EQUAL(expected1[i],da5->getIJ(0,i));
01146   const int expected2[70]={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};
01147   CPPUNIT_ASSERT_EQUAL(70,da1->getNumberOfTuples());
01148   CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
01149   for(int i=0;i<70;i++)
01150     CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i));
01151   const int expected3[17]={0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70};
01152   CPPUNIT_ASSERT_EQUAL(17,da2->getNumberOfTuples());
01153   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
01154   for(int i=0;i<17;i++)
01155     CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i));
01156   const int expected4[48]={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};
01157   //const int expected4[48]={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};
01158   CPPUNIT_ASSERT_EQUAL(48,da4->getNumberOfTuples());
01159   CPPUNIT_ASSERT_EQUAL(1,da4->getNumberOfComponents());
01160   for(int i=0;i<48;i++)
01161     CPPUNIT_ASSERT_EQUAL(expected4[i],da4->getIJ(0,i));
01162   const int expected5[70]={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};
01163   CPPUNIT_ASSERT_EQUAL(70,da3->getNumberOfTuples());
01164   CPPUNIT_ASSERT_EQUAL(1,da3->getNumberOfComponents());
01165   for(int i=0;i<70;i++)
01166     CPPUNIT_ASSERT_EQUAL(expected5[i],da3->getIJ(0,i));
01167   //
01168   da0->decrRef();
01169   da1->decrRef();
01170   da2->decrRef();
01171   da3->decrRef();
01172   da4->decrRef();
01173   da5->decrRef();
01174   //
01175   m2->decrRef();
01176   m1->decrRef();
01177   m->decrRef();
01178 }
01179 
01180 void MEDCouplingBasicsTest4::testGetLevArrPerCellTypes1()
01181 {
01182   MEDCouplingUMesh *m1=0;
01183   MEDCouplingUMesh *m=buildPointe_1(m1);
01184   m1->decrRef();
01185   DataArrayInt *d0=DataArrayInt::New();
01186   DataArrayInt *d1=DataArrayInt::New();
01187   DataArrayInt *d2=DataArrayInt::New();
01188   DataArrayInt *d3=DataArrayInt::New();
01189   m1=m->buildDescendingConnectivity(d0,d1,d2,d3);
01190   d0->decrRef(); d1->decrRef(); d2->decrRef(); d3->decrRef();
01191   INTERP_KERNEL::NormalizedCellType order[2]={INTERP_KERNEL::NORM_TRI3,INTERP_KERNEL::NORM_QUAD4};
01192   DataArrayInt *da1=0;
01193   DataArrayInt *da0=m1->getLevArrPerCellTypes(order,order+2,da1);
01194   const int expected0[47]={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};
01195   const int expected1[47]={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};
01196   CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples());
01197   CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents());
01198   for(int i=0;i<47;i++)
01199     CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i));
01200   CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples());
01201   CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
01202   CPPUNIT_ASSERT_EQUAL(36,da1->getIJ(0,0));//36 TRI3
01203   CPPUNIT_ASSERT_EQUAL(11,da1->getIJ(1,0));//11 QUAD4
01204   //
01205   DataArrayInt *da2=da0->buildPermArrPerLevel();
01206   //
01207   CPPUNIT_ASSERT_EQUAL(47,da2->getNumberOfTuples());
01208   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
01209   for(int i=0;i<47;i++)
01210     CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i));
01211   da2->decrRef();
01212   da0->decrRef();
01213   da1->decrRef();
01214   //
01215   m->decrRef();
01216   m1->decrRef();
01217 }
01218 
01219 void MEDCouplingBasicsTest4::testSortCellsInMEDFileFrmt1()
01220 {
01221   MEDCouplingUMesh *m1=0;
01222   MEDCouplingUMesh *m=buildPointe_1(m1);
01223   MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCpy();
01224   m->setCoords(0);
01225   const int vals[16]={0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13};
01226   DataArrayInt *da=DataArrayInt::New();
01227   da->alloc(16,1);
01228   std::copy(vals,vals+16,da->getPointer());
01229   DataArrayInt *daa=da->invertArrayN2O2O2N(16);
01230   m->renumberCells(daa->getConstPointer(),false);
01231   daa->decrRef();
01232   DataArrayInt *da2=m->sortCellsInMEDFileFrmt();
01233   CPPUNIT_ASSERT(m2->isEqual(m2,1e-12));
01234   CPPUNIT_ASSERT(da->isEqual(*da2));
01235   m2->decrRef();
01236   da2->decrRef();
01237   da->decrRef();
01238   m1->decrRef();
01239   m->decrRef();
01240 }
01241 
01242 void MEDCouplingBasicsTest4::testBuildPartAndReduceNodes1()
01243 {
01244   MEDCouplingMesh *m=build2DTargetMesh_1();
01245   const int arr[2]={1,0};
01246   DataArrayInt *da;
01247   MEDCouplingMesh *m2=m->buildPartAndReduceNodes(arr,arr+2,da);
01248   CPPUNIT_ASSERT_EQUAL(5,m2->getNumberOfNodes());
01249   CPPUNIT_ASSERT_EQUAL(2,m2->getNumberOfCells());
01250   MEDCouplingFieldDouble *f=m2->getMeasureField(true);
01251   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,f->getArray()->getIJ(0,0),1e-12);
01252   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,f->getArray()->getIJ(1,0),1e-12);
01253   f->decrRef();
01254   da->decrRef();
01255   m2->decrRef();
01256   m->decrRef();
01257 }
01258 
01259 void MEDCouplingBasicsTest4::testDAITransformWithIndArrR1()
01260 {
01261   const int tab1[6]={2,4,5,3,6,7};
01262   const int tab2[12]={-1,-1,0,1,2,3,4,5,-1,-1,-1,-1};
01263   const int expected[6]={0,3,1,2,4,5};
01264   DataArrayInt *d=DataArrayInt::New();
01265   d->alloc(6,1);
01266   std::copy(tab1,tab1+6,d->getPointer());
01267   DataArrayInt *d1=DataArrayInt::New();
01268   d1->alloc(12,1);
01269   std::copy(tab2,tab2+12,d1->getPointer());
01270   //
01271   DataArrayInt *d3=d->transformWithIndArrR(d1->getConstPointer(),d1->getConstPointer()+d1->getNbOfElems());
01272   CPPUNIT_ASSERT_EQUAL(6,d3->getNumberOfTuples());
01273   CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents());
01274   for(int i=0;i<6;i++)
01275     CPPUNIT_ASSERT_EQUAL(expected[i],d3->getIJ(i,0));
01276   d3->decrRef();
01277   //
01278   d->decrRef();
01279   d1->decrRef();
01280 }
01281 
01282 void MEDCouplingBasicsTest4::testDAISplitByValueRange1()
01283 {
01284   const int val1[9]={6,5,0,3,2,7,8,1,4};
01285   const int val2[3]={0,4,9};
01286   DataArrayInt *d=DataArrayInt::New();
01287   d->alloc(9,1);
01288   std::copy(val1,val1+9,d->getPointer());
01289   DataArrayInt *ee=0,*f=0,*g=0;
01290   d->splitByValueRange(val2,val2+3,ee,f,g);
01291   CPPUNIT_ASSERT_EQUAL(9,ee->getNumberOfTuples());
01292   CPPUNIT_ASSERT_EQUAL(1,ee->getNumberOfComponents());
01293   CPPUNIT_ASSERT_EQUAL(9,f->getNumberOfTuples());
01294   CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
01295   CPPUNIT_ASSERT_EQUAL(2,g->getNumberOfTuples());
01296   CPPUNIT_ASSERT_EQUAL(1,g->getNumberOfComponents());
01297   //
01298   const int expected1[9]={1,1,0,0,0,1,1,0,1};
01299   const int expected2[9]={2,1,0,3,2,3,4,1,0};
01300   for(int i=0;i<9;i++)
01301     {
01302       CPPUNIT_ASSERT_EQUAL(expected1[i],ee->getIJ(i,0));
01303       CPPUNIT_ASSERT_EQUAL(expected2[i],f->getIJ(i,0));
01304     }
01305   CPPUNIT_ASSERT_EQUAL(0,g->getIJ(0,0));
01306   CPPUNIT_ASSERT_EQUAL(1,g->getIJ(1,0));
01307   //
01308   ee->decrRef();
01309   f->decrRef();
01310   g->decrRef();
01311   //
01312   d->setIJ(6,0,9);
01313   CPPUNIT_ASSERT_THROW(d->splitByValueRange(val2,val2+3,ee,f,g),INTERP_KERNEL::Exception);
01314   //
01315   d->decrRef();
01316 }
01317 
01318 void MEDCouplingBasicsTest4::testUMeshSplitProfilePerType1()
01319 {
01320   const int val0[5]={2,0,1,3,4};
01321   MEDCouplingUMesh *m=build2DTargetMesh_1();
01322   m->renumberCells(val0,false);
01323   std::vector<int> code;
01324   std::vector<DataArrayInt *> idsInPflPerType;
01325   std::vector<DataArrayInt *> pfls;
01326   //
01327   const int val1[3]={0,2,3};
01328   DataArrayInt *d=DataArrayInt::New();
01329   d->alloc(3,1);
01330   d->setName("sup");
01331   std::copy(val1,val1+3,d->getPointer());
01332   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
01333   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
01334   CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
01335   const int expected1[6]={3,1,0, 4,2,1};
01336   for(int i=0;i<6;i++)
01337     CPPUNIT_ASSERT_EQUAL(expected1[i],code[i]);
01338   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples());
01339   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
01340   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getNumberOfTuples());
01341   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0));
01342   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0));
01343   idsInPflPerType[0]->decrRef();
01344   idsInPflPerType[1]->decrRef();
01345   CPPUNIT_ASSERT_EQUAL(2,(int)pfls.size());
01346   CPPUNIT_ASSERT(std::string("sup")==pfls[0]->getName());
01347   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples());
01348   CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0));
01349   CPPUNIT_ASSERT(std::string("sup")==pfls[1]->getName());
01350   CPPUNIT_ASSERT_EQUAL(2,pfls[1]->getNumberOfTuples());
01351   CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0));
01352   CPPUNIT_ASSERT_EQUAL(1,pfls[1]->getIJ(1,0));
01353   pfls[0]->decrRef();
01354   pfls[1]->decrRef();
01355   d->decrRef();
01356   idsInPflPerType.clear();
01357   pfls.clear();
01358   code.clear();
01359   //
01360   const int val2[4]={0,2,3,4};// all quad4 are selected here ! So no profile for Quads
01361   d=DataArrayInt::New();
01362   d->alloc(4,1);
01363   std::copy(val2,val2+4,d->getPointer());
01364   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
01365   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
01366   CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
01367   const int expected2[6]={3,1,0, 4,3,-1};
01368   for(int i=0;i<6;i++)
01369     CPPUNIT_ASSERT_EQUAL(expected2[i],code[i]);
01370   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples());
01371   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
01372   CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getNumberOfTuples());
01373   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0));
01374   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0));
01375   CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getIJ(2,0));
01376   idsInPflPerType[0]->decrRef();
01377   idsInPflPerType[1]->decrRef();
01378   CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size());
01379   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples());
01380   CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0));
01381   pfls[0]->decrRef();
01382   d->decrRef();
01383   idsInPflPerType.clear();
01384   pfls.clear();
01385   code.clear();
01386   //
01387   const int val3[3]={1,0,2};// all tri3 are selected here but not in the same order ! Profile requested for Tri3
01388   d=DataArrayInt::New();
01389   d->alloc(3,1);
01390   std::copy(val3,val3+3,d->getPointer());
01391   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
01392   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
01393   CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
01394   const int expected3[6]={3,2,0, 4,1,1};
01395   for(int i=0;i<6;i++)
01396     CPPUNIT_ASSERT_EQUAL(expected3[i],code[i]);
01397   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples());
01398   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
01399   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0));
01400   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getNumberOfTuples());
01401   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(0,0));
01402   idsInPflPerType[0]->decrRef();
01403   idsInPflPerType[1]->decrRef();
01404   CPPUNIT_ASSERT_EQUAL(2,(int)pfls.size());
01405   CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples());
01406   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0));
01407   CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(1,0));
01408   CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0));
01409   pfls[0]->decrRef();
01410   pfls[1]->decrRef();
01411   d->decrRef();
01412   idsInPflPerType.clear();
01413   pfls.clear();
01414   code.clear();
01415   //
01416   const int val4[2]={3,4};// all tri3 are selected here but not in the same order ! Profile requested for Tri3
01417   d=DataArrayInt::New();
01418   d->alloc(2,1);
01419   std::copy(val4,val4+2,d->getPointer());
01420   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
01421   CPPUNIT_ASSERT_EQUAL(3,(int)code.size());
01422   CPPUNIT_ASSERT_EQUAL(1,(int)idsInPflPerType.size());
01423   const int expected4[3]={4,2,0};
01424   for(int i=0;i<3;i++)
01425     CPPUNIT_ASSERT_EQUAL(expected4[i],code[i]);
01426   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples());
01427   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
01428   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0));
01429   idsInPflPerType[0]->decrRef();
01430   CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size());
01431   CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples());
01432   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0));
01433   CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getIJ(1,0));
01434   pfls[0]->decrRef();
01435   d->decrRef();
01436   idsInPflPerType.clear();
01437   pfls.clear();
01438   code.clear();
01439   //
01440   m->decrRef();
01441 }
01442 
01443 void MEDCouplingBasicsTest4::testDAIBuildExplicitArrByRanges1()
01444 {
01445   DataArrayInt *d=DataArrayInt::New();
01446   d->alloc(3,1);
01447   const int vals1[3]={0,2,3};
01448   std::copy(vals1,vals1+3,d->getPointer());
01449   DataArrayInt *e=DataArrayInt::New();
01450   e->alloc(6,1);
01451   const int vals2[6]={0,3,6,10,14,20};
01452   std::copy(vals2,vals2+6,e->getPointer());
01453   //
01454   DataArrayInt *f=d->buildExplicitArrByRanges(e);
01455   CPPUNIT_ASSERT_EQUAL(11,f->getNumberOfTuples());
01456   CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
01457   const int expected1[11]={0,1,2,6,7,8,9,10,11,12,13};
01458   for(int i=0;i<11;i++)
01459     CPPUNIT_ASSERT_EQUAL(expected1[i],f->getIJ(i,0));
01460   //
01461   f->decrRef();
01462   e->decrRef();
01463   d->decrRef();
01464 }
01465 
01466 void MEDCouplingBasicsTest4::testDAIComputeOffsets2()
01467 {
01468   DataArrayInt *d=DataArrayInt::New();
01469   const int vals1[6]={3,5,1,2,0,8};
01470   const int expected1[7]={0,3,8,9,11,11,19};
01471   d->alloc(6,1);
01472   std::copy(vals1,vals1+6,d->getPointer());
01473   d->computeOffsets2();
01474   CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples());
01475   CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
01476   for(int i=0;i<7;i++)
01477     CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
01478   d->decrRef();
01479 }
01480 
01481 void MEDCouplingBasicsTest4::testMergeField3()
01482 {
01483   MEDCouplingUMesh *m=build2DTargetMesh_1();
01484   m->getCoords()->setInfoOnComponent(0,"x [m]");
01485   m->getCoords()->setInfoOnComponent(1,"z [km]");
01486   m->setName("m");
01487   m->setDescription("desc");
01488   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
01489   f1->setName("f1");
01490   f1->setMesh(m);
01491   DataArrayDouble *arr=DataArrayDouble::New();
01492   arr->alloc(5,2);
01493   arr->setInfoOnComponent(0,"X [m]");
01494   arr->setInfoOnComponent(1,"YY [mm]");
01495   arr->fillWithValue(2.);
01496   f1->setArray(arr);
01497   arr->decrRef();
01498   m->decrRef();
01499   //
01500   std::vector<const MEDCouplingFieldDouble *> tmp(1);
01501   tmp[0]=f1;
01502   MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::MergeFields(tmp);
01503   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
01504   //
01505   f1->decrRef();
01506   f2->decrRef();
01507 }
01508 
01509 void MEDCouplingBasicsTest4::testGetDistributionOfTypes1()
01510 {
01511   MEDCouplingUMesh *m=build2DTargetMesh_1();
01512   const int tab1[5]={2,0,1,3,4};
01513   CPPUNIT_ASSERT_THROW(m->getDistributionOfTypes(),INTERP_KERNEL::Exception);
01514   m->renumberCells(tab1,false);
01515   std::vector<int> code=m->getDistributionOfTypes();
01516   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
01517   CPPUNIT_ASSERT_EQUAL(3,code[0]);
01518   CPPUNIT_ASSERT_EQUAL(2,code[1]);
01519   CPPUNIT_ASSERT_EQUAL(0,code[2]);
01520   CPPUNIT_ASSERT_EQUAL(4,code[3]);
01521   CPPUNIT_ASSERT_EQUAL(3,code[4]);
01522   CPPUNIT_ASSERT_EQUAL(0,code[5]);
01523   m->decrRef();
01524 }
01525 
01526 void MEDCouplingBasicsTest4::testNorm2_1()
01527 {
01528   MEDCouplingUMesh *m=build2DTargetMesh_1();
01529   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
01530   f->setMesh(m);
01531   m->decrRef();
01532   //
01533   DataArrayDouble *d=DataArrayDouble::New();
01534   const double tab[10]={1.2,1.3,2.2,2.3,3.2,3.3,4.2,4.3,5.2,5.3};
01535   d->alloc(5,2);
01536   std::copy(tab,tab+10,d->getPointer());
01537   f->setArray(d);
01538   d->decrRef();
01539   f->checkCoherency();
01540   //
01541   CPPUNIT_ASSERT_DOUBLES_EQUAL(11.209371079592289,f->norm2(),1e-14);
01542   //
01543   f->decrRef();
01544 }
01545 
01546 void MEDCouplingBasicsTest4::testNormMax1()
01547 {
01548   MEDCouplingUMesh *m=build2DTargetMesh_1();
01549   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
01550   f->setMesh(m);
01551   m->decrRef();
01552   //
01553   DataArrayDouble *d=DataArrayDouble::New();
01554   const double tab[10]={2.3,-1.2,6.3,-7.8,2.9,7.7,2.1,0.,3.6,-7.6};
01555   d->alloc(5,2);
01556   std::copy(tab,tab+10,d->getPointer());
01557   f->setArray(d);
01558   d->decrRef();
01559   f->checkCoherency();
01560   //
01561   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8,f->normMax(),1e-14);
01562   //
01563   f->decrRef();
01564 }
01565 
01566 void MEDCouplingBasicsTest4::testFindAndCorrectBadOriented3DExtrudedCells1()
01567 {
01568   const double coords[38*3]={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};
01569   const int conn[56]={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};
01570   const int connExp[64]={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};
01571   const int invalidCells[4]={2,3,6,7};
01572   MEDCouplingUMesh *m=MEDCouplingUMesh::New("Example",3);
01573   DataArrayDouble *coo=DataArrayDouble::New();
01574   coo->alloc(38,3);
01575   std::copy(coords,coords+114,coo->getPointer());
01576   m->setCoords(coo);
01577   coo->decrRef();
01578   m->allocateCells(8);
01579   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn);
01580   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+6);
01581   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+12);
01582   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+18);
01583   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+24);
01584   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+32);
01585   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+40);
01586   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+48);
01587   m->finishInsertingCells();
01588   //
01589   std::vector<int> v;
01590   m->findAndCorrectBadOriented3DExtrudedCells(v);
01591   CPPUNIT_ASSERT_EQUAL(4,(int)v.size());
01592   CPPUNIT_ASSERT(std::equal(v.begin(),v.end(),invalidCells));
01593   CPPUNIT_ASSERT(std::equal(connExp,connExp+64,m->getNodalConnectivity()->getConstPointer()));
01594   //
01595   m->decrRef();
01596 }
01597 
01598 void MEDCouplingBasicsTest4::testConvertExtrudedPolyhedra1()
01599 {
01600   const int conn[72]={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};
01601   MEDCouplingUMesh *m=MEDCouplingUMesh::New("Example",3);
01602   DataArrayDouble *coo=DataArrayDouble::New();
01603   coo->alloc(73,3);
01604   coo->rearrange(1); coo->iota(0); coo->rearrange(3);
01605   m->setCoords(coo);
01606   coo->decrRef();
01607   m->allocateCells(9);
01608   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
01609   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+4);
01610   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+12);
01611   m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,6,conn+16);
01612   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+22);
01613   m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,10,conn+28);
01614   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+38);
01615   m->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn+46);
01616   m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,14,conn+58);
01617   m->finishInsertingCells();
01618   //
01619   m->convertExtrudedPolyhedra();
01620   DataArrayInt *da=m->getNodalConnectivity();
01621   DataArrayInt *dai=m->getNodalConnectivityIndex();
01622   CPPUNIT_ASSERT_EQUAL(10,dai->getNbOfElems());
01623   CPPUNIT_ASSERT_EQUAL(159,da->getNbOfElems());
01624   //
01625   const int expected1[159]={14, 1, 2, 3, 4,
01626                             18, 5, 6, 7, 8, 9, 10, 11, 12,
01627                             14, 13, 14, 15, 16,
01628                             31, 17, 18, 19, -1, 20, 22, 21, -1, 17, 18, 21, 20, -1, 18, 19, 22, 21, -1, 19, 17, 20,
01629   22,
01630                             16, 23, 24, 25, 26, 27, 28,
01631                             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,
01632   -1, 33, 29, 34, 38,
01633                             18, 39, 40, 41, 42, 43, 44, 45, 46,
01634                             22, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
01635                             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};
01636   const int expected2[10]={0,5,14,19,42,49,86,95,108,159};
01637   CPPUNIT_ASSERT(std::equal(expected1,expected1+159,da->getConstPointer()));
01638   CPPUNIT_ASSERT(std::equal(expected2,expected2+10,dai->getConstPointer()));
01639   m->checkCoherency2();
01640   //
01641   m->decrRef();
01642 }
01643 
01644 void MEDCouplingBasicsTest4::testNonRegressionCopyTinyStrings()
01645 {
01646   MEDCouplingUMesh *m=build2DTargetMesh_1();
01647   MEDCouplingFieldDouble *f1=m->getMeasureField(true);
01648   f1->getArray()->setInfoOnComponent(0,"P [N/m^2]");
01649   DataArrayDouble *bary=m->getBarycenterAndOwner();
01650   MEDCouplingFieldDouble *f2=f1->buildNewTimeReprFromThis(ONE_TIME,false);
01651   f2->setArray(bary);
01652   CPPUNIT_ASSERT_THROW(f2->copyTinyAttrFrom(f1),INTERP_KERNEL::Exception);
01653   m->decrRef();
01654   f1->decrRef();
01655   bary->decrRef();
01656   f2->decrRef();
01657 }
01658 
01659 void MEDCouplingBasicsTest4::testDaDSetPartOfValuesAdv1()
01660 {
01661   const double tab1[18]={3.,4.,5., 13.,14.,15., 23.,24.,25., 33.,34.,35., 43.,44.,45., 53.,54.,55.};
01662   const double tab2[9]={6.,7.,8., 16.,17.,18., 26.,27.,28.};
01663   const int tab3[6]={4,1, 2,2, 3,0};
01664   DataArrayDouble *a=DataArrayDouble::New();
01665   a->alloc(6,3);
01666   std::copy(tab1,tab1+18,a->getPointer());
01667   DataArrayDouble *b=DataArrayDouble::New();
01668   b->alloc(3,3);
01669   std::copy(tab2,tab2+9,b->getPointer());
01670   DataArrayInt *c=DataArrayInt::New();
01671   c->alloc(3,2);
01672   std::copy(tab3,tab3+6,c->getPointer());
01673   //
01674   a->setPartOfValuesAdv(b,c);
01675   const double expected1[18]={3.,4.,5., 13.,14.,15., 26.,27.,28., 6.,7.,8., 16.,17.,18., 53.,54.,55.};
01676   std::equal(expected1,expected1+18,a->getConstPointer());
01677   //
01678   a->decrRef();
01679   b->decrRef();
01680   c->decrRef();
01681 }
01682 
01683 void MEDCouplingBasicsTest4::testUMeshBuildSetInstanceFromThis1()
01684 {
01685   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
01686   MEDCouplingUMesh *m2=m->buildSetInstanceFromThis(3);
01687   CPPUNIT_ASSERT_EQUAL(m->getNodalConnectivity(),m2->getNodalConnectivity());
01688   CPPUNIT_ASSERT_EQUAL(m->getNodalConnectivityIndex(),m2->getNodalConnectivityIndex());
01689   CPPUNIT_ASSERT_EQUAL(m->getCoords(),m2->getCoords());
01690   m2->decrRef();
01691   m->decrRef();
01692   //
01693   m=MEDCouplingUMesh::New("toto",2);
01694   m2=m->buildSetInstanceFromThis(3);
01695   CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfNodes());
01696   CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfCells());
01697   m->decrRef();
01698   m2->decrRef();
01699 }
01700 
01701 void MEDCouplingBasicsTest4::testUMeshMergeMeshesCVW1()
01702 {
01703   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
01704   MEDCouplingUMesh *m2=MEDCouplingUMesh::New("toto",2);
01705   MEDCouplingUMesh *m3=MEDCouplingUMesh::MergeUMeshes(m,m2);
01706   m3->setName(m->getName());
01707   CPPUNIT_ASSERT(m->isEqual(m3,1e-12));
01708   m3->decrRef();
01709   m->decrRef();
01710   m2->decrRef();
01711 }
01712 
01713 void MEDCouplingBasicsTest4::testChangeUnderlyingMeshWithCMesh1()
01714 {
01715   MEDCouplingCMesh* mesh=MEDCouplingCMesh::New();
01716   DataArrayDouble* coordsX=DataArrayDouble::New();
01717   double arrX[4] = { -1., 1., 2., 4. };
01718   coordsX->useArray(arrX,false, CPP_DEALLOC,4,1);
01719   DataArrayDouble* coordsY=DataArrayDouble::New();
01720   double arrY[4] = { -2., 2., 4., 8. };
01721   coordsY->useArray(arrY,false, CPP_DEALLOC,4,1);
01722   DataArrayDouble* coordsZ=DataArrayDouble::New();
01723   double arrZ[4] = { -3., 3., 6., 12. };
01724   coordsZ->useArray(arrZ,false, CPP_DEALLOC,4,1);
01725   mesh->setCoords(coordsX,coordsY,coordsZ);
01726   coordsX->decrRef();
01727   coordsY->decrRef();
01728   coordsZ->decrRef();
01729   MEDCouplingMesh *mesh2=mesh->deepCpy();
01730   //
01731   static const int ids1[9]={0,1,2,10,11,12,20,21,22};
01732   for(const int *myId=ids1;myId!=ids1+9;myId++)
01733     {
01734       MEDCouplingFieldDouble *f=mesh->getMeasureField(true);
01735       f->changeUnderlyingMesh(mesh2,*myId,1e-12);
01736       f->decrRef();
01737     }
01738   mesh2->setName("uuuu");
01739   for(const int *myId=ids1+1;myId!=ids1+9;myId++)
01740     {
01741       MEDCouplingFieldDouble *f=mesh->getMeasureField(true);
01742       f->changeUnderlyingMesh(mesh2,*myId,1e-12);
01743       f->decrRef();
01744     }
01745   //
01746   mesh2->decrRef();
01747   mesh->decrRef();
01748 }
01749 
01750 void MEDCouplingBasicsTest4::testDADFindCommonTuples1()
01751 {
01752   DataArrayDouble *da=DataArrayDouble::New();
01753   da->alloc(6,1);
01754   const double array1[6]={2.3,1.2,1.3,2.3,2.301,0.8};
01755   std::copy(array1,array1+6,da->getPointer());
01756   DataArrayInt *c=0,*cI=0;
01757   // nbOftuples=1
01758   da->findCommonTuples(1e-2,-1,c,cI);
01759   const int expected1[3]={0,3,4};
01760   const int expected2[2]={0,3};
01761   CPPUNIT_ASSERT_EQUAL(3,c->getNbOfElems());
01762   CPPUNIT_ASSERT_EQUAL(2,cI->getNbOfElems());
01763   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
01764   CPPUNIT_ASSERT(std::equal(expected2,expected2+2,cI->getConstPointer()));
01765   c->decrRef();
01766   cI->decrRef();
01767   //
01768   da->findCommonTuples(2e-1,-1,c,cI);
01769   const int expected3[5]={0,3,4,1,2};
01770   const int expected4[3]={0,3,5};
01771   CPPUNIT_ASSERT_EQUAL(5,c->getNbOfElems());
01772   CPPUNIT_ASSERT_EQUAL(3,cI->getNbOfElems());
01773   CPPUNIT_ASSERT(std::equal(expected3,expected3+5,c->getConstPointer()));
01774   CPPUNIT_ASSERT(std::equal(expected4,expected4+3,cI->getConstPointer()));
01775   c->decrRef();
01776   cI->decrRef();
01777   // nbOftuples=2
01778   da->alloc(6,2);
01779   const double array2[12]={2.3,2.3,1.2,1.2,1.3,1.3,2.3,2.3,2.301,2.301,0.8,0.8};
01780   std::copy(array2,array2+12,da->getPointer());
01781   da->findCommonTuples(1e-2,-1,c,cI);
01782   CPPUNIT_ASSERT_EQUAL(3,c->getNbOfElems());
01783   CPPUNIT_ASSERT_EQUAL(2,cI->getNbOfElems());
01784   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
01785   CPPUNIT_ASSERT(std::equal(expected2,expected2+2,cI->getConstPointer()));
01786   c->decrRef();
01787   cI->decrRef();
01788   //
01789   da->findCommonTuples(2e-1,-1,c,cI);
01790   CPPUNIT_ASSERT_EQUAL(5,c->getNbOfElems());
01791   CPPUNIT_ASSERT_EQUAL(3,cI->getNbOfElems());
01792   CPPUNIT_ASSERT(std::equal(expected3,expected3+5,c->getConstPointer()));
01793   CPPUNIT_ASSERT(std::equal(expected4,expected4+3,cI->getConstPointer()));
01794   c->decrRef();
01795   cI->decrRef();
01796   // nbOftuples=3
01797   da->alloc(6,3);
01798   const double array3[18]={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};
01799   std::copy(array3,array3+18,da->getPointer());
01800   da->findCommonTuples(1e-2,-1,c,cI);
01801   CPPUNIT_ASSERT_EQUAL(3,c->getNbOfElems());
01802   CPPUNIT_ASSERT_EQUAL(2,cI->getNbOfElems());
01803   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
01804   CPPUNIT_ASSERT(std::equal(expected2,expected2+2,cI->getConstPointer()));
01805   c->decrRef();
01806   cI->decrRef();
01807   //
01808   da->findCommonTuples(2e-1,-1,c,cI);
01809   CPPUNIT_ASSERT_EQUAL(5,c->getNbOfElems());
01810   CPPUNIT_ASSERT_EQUAL(3,cI->getNbOfElems());
01811   CPPUNIT_ASSERT(std::equal(expected3,expected3+5,c->getConstPointer()));
01812   CPPUNIT_ASSERT(std::equal(expected4,expected4+3,cI->getConstPointer()));
01813   c->decrRef();
01814   cI->decrRef();
01815   //
01816   const double array11[6]={2.3,1.2,1.3,2.4,2.5,0.8};
01817   da->alloc(6,1);
01818   std::copy(array11,array11+6,da->getPointer());
01819   // nbOftuples=1, no common groups
01820   da->findCommonTuples(1e-2,-1,c,cI);
01821   CPPUNIT_ASSERT_EQUAL(0,c->getNbOfElems());
01822   CPPUNIT_ASSERT_EQUAL(1,cI->getNbOfElems());
01823   CPPUNIT_ASSERT_EQUAL(0,cI->getIJ(0,0));
01824   
01825   da->alloc(6,4);  //bad NumberOfComponents
01826   CPPUNIT_ASSERT_THROW(da->findCommonTuples(1e-2,-1,c,cI),INTERP_KERNEL::Exception);
01827   
01828   c->decrRef();
01829   cI->decrRef();
01830   da->decrRef();
01831 }
01832 
01833 void MEDCouplingBasicsTest4::testDABack1()
01834 {
01835   DataArrayDouble *da=DataArrayDouble::New();
01836   da->alloc(6,1);
01837   const double array1[6]={2.3,1.2,1.3,2.3,2.301,0.8};
01838   std::copy(array1,array1+6,da->getPointer());
01839   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.8,da->back(),1e-14);
01840   da->rearrange(2);
01841   CPPUNIT_ASSERT_THROW(da->back(),INTERP_KERNEL::Exception);
01842   da->alloc(0,1);
01843   CPPUNIT_ASSERT_THROW(da->back(),INTERP_KERNEL::Exception);
01844   da->decrRef();
01845   //
01846   DataArrayInt *da2=DataArrayInt::New();
01847   da2->alloc(4,1);
01848   const int array2[4]={4,7,8,2};
01849   std::copy(array2,array2+4,da2->getPointer());
01850   CPPUNIT_ASSERT_EQUAL(2,da2->back());
01851   da2->rearrange(2);
01852   CPPUNIT_ASSERT_THROW(da2->back(),INTERP_KERNEL::Exception);
01853   da2->alloc(0,1);
01854   CPPUNIT_ASSERT_THROW(da2->back(),INTERP_KERNEL::Exception);
01855   da2->decrRef();
01856 }
01857 
01858 void MEDCouplingBasicsTest4::testDADGetDifferentValues1()
01859 {
01860   DataArrayDouble *da=DataArrayDouble::New();
01861   da->alloc(6,1);
01862   const double array1[6]={2.3,1.2,1.3,2.3,2.301,0.8};
01863   std::copy(array1,array1+6,da->getPointer());
01864   //
01865   const double expected1[4]={2.301,1.2,1.3,0.8};
01866   DataArrayDouble *dv=da->getDifferentValues(1e-2);
01867   CPPUNIT_ASSERT_EQUAL(4,dv->getNbOfElems());
01868   for(int i=0;i<4;i++)
01869     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],dv->getIJ(i,0),1e-14);
01870   dv->decrRef();
01871   //
01872   dv=da->getDifferentValues(2e-1);
01873   const double expected2[3]={2.301,1.3,0.8};
01874   CPPUNIT_ASSERT_EQUAL(3,dv->getNbOfElems());
01875   for(int i=0;i<3;i++)
01876     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],dv->getIJ(i,0),1e-14);
01877   dv->decrRef();
01878   da->decrRef();
01879 }
01880 
01881 void MEDCouplingBasicsTest4::testDAIBuildOld2NewArrayFromSurjectiveFormat2()
01882 {
01883   const int arr[5]={0,3, 5,7,9};
01884   const int arrI[3]={0,2,5};
01885   DataArrayInt *a=DataArrayInt::New();
01886   a->alloc(5,1);
01887   std::copy(arr,arr+5,a->getPointer());
01888   DataArrayInt *b=DataArrayInt::New();
01889   b->alloc(3,1);
01890   std::copy(arrI,arrI+3,b->getPointer());
01891   int newNbTuple=-1;
01892   DataArrayInt *ret=DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(10,a,b,newNbTuple);
01893   const int expected[10]={0,1,2,0,3,4,5,4,6,4};
01894   CPPUNIT_ASSERT_EQUAL(10,ret->getNbOfElems());
01895   CPPUNIT_ASSERT_EQUAL(7,newNbTuple);
01896   CPPUNIT_ASSERT_EQUAL(1,ret->getNumberOfComponents());
01897   CPPUNIT_ASSERT(std::equal(expected,expected+10,ret->getConstPointer()));
01898   ret->decrRef();
01899   b->decrRef();
01900   a->decrRef();
01901 }
01902 
01903 void MEDCouplingBasicsTest4::testDADIReverse1()
01904 {
01905   const int arr[6]={0,3,5,7,9,2};
01906   DataArrayInt *a=DataArrayInt::New();
01907   a->alloc(6,1);
01908   std::copy(arr,arr+6,a->getPointer());
01909   CPPUNIT_ASSERT_EQUAL(2,a->back());
01910   a->reverse();
01911   for(int i=0;i<6;i++)
01912     CPPUNIT_ASSERT_EQUAL(arr[5-i],a->getIJ(i,0));
01913   a->alloc(5,1);
01914   std::copy(arr,arr+5,a->getPointer());
01915   a->reverse();
01916   for(int i=0;i<5;i++)
01917     CPPUNIT_ASSERT_EQUAL(arr[4-i],a->getIJ(i,0));
01918   a->decrRef();
01919   //
01920   const double arr2[6]={0.,3.,5.,7.,9.,2.};
01921    DataArrayDouble *b=DataArrayDouble::New();
01922    b->alloc(6,1);
01923    std::copy(arr2,arr2+6,b->getPointer());
01924    b->reverse();
01925    for(int i=0;i<6;i++)
01926      CPPUNIT_ASSERT_DOUBLES_EQUAL(arr2[5-i],b->getIJ(i,0),1e-14);
01927    b->alloc(5,1);
01928    std::copy(arr,arr+5,b->getPointer());
01929    CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,b->back(),1e-14);
01930    b->reverse();
01931    for(int i=0;i<5;i++)
01932      CPPUNIT_ASSERT_DOUBLES_EQUAL(arr2[4-i],b->getIJ(i,0),1e-14);
01933    b->decrRef();
01934 }
01935 
01936 void MEDCouplingBasicsTest4::testGetNodeIdsInUse1()
01937 {
01938   MEDCouplingUMesh *m0=build2DTargetMesh_1();
01939   const int CellIds[2]={1,2};
01940   MEDCouplingUMesh *m1=static_cast<MEDCouplingUMesh *>(m0->buildPartOfMySelf(CellIds,CellIds+2,true));
01941   int newNbOfNodes=-1;
01942   DataArrayInt *arr=m1->getNodeIdsInUse(newNbOfNodes);
01943   const int expected[9]={-1,0,1,-1,2,3,-1,-1,-1};
01944   CPPUNIT_ASSERT_EQUAL(4,newNbOfNodes);
01945   CPPUNIT_ASSERT_EQUAL(9,arr->getNbOfElems());
01946   CPPUNIT_ASSERT(std::equal(expected,expected+9,arr->getConstPointer()));
01947   DataArrayInt *arr2=arr->invertArrayO2N2N2O(newNbOfNodes);
01948   CPPUNIT_ASSERT_EQUAL(4,arr2->getNbOfElems());
01949   const int expected2[4]={1,2,4,5};
01950   CPPUNIT_ASSERT(std::equal(expected2,expected2+4,arr2->getConstPointer()));
01951   arr2->decrRef();
01952   arr->decrRef();
01953   m1->decrRef();
01954   m0->decrRef();
01955 }
01956 
01957 void MEDCouplingBasicsTest4::testBuildDescendingConnec2()
01958 {
01959   MEDCouplingUMesh *mesh=build2DTargetMesh_1();
01960   DataArrayInt *desc=DataArrayInt::New();
01961   DataArrayInt *descIndx=DataArrayInt::New();
01962   DataArrayInt *revDesc=DataArrayInt::New();
01963   DataArrayInt *revDescIndx=DataArrayInt::New();
01964   //
01965   MEDCouplingUMesh *mesh2=mesh->buildDescendingConnectivity2(desc,descIndx,revDesc,revDescIndx);
01966   mesh2->checkCoherency();
01967   CPPUNIT_ASSERT_EQUAL(1,mesh2->getMeshDimension());
01968   CPPUNIT_ASSERT_EQUAL(13,mesh2->getNumberOfCells());
01969   CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples());
01970   CPPUNIT_ASSERT_EQUAL(6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples());
01971   CPPUNIT_ASSERT_EQUAL(18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples());
01972   CPPUNIT_ASSERT_EQUAL(18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples());
01973   const int expected1[18]={1,2,3,4,-3,5,6, 7,8,-5,9,10,-2,11, 12,13,-7,-10};
01974   CPPUNIT_ASSERT(std::equal(expected1,expected1+18,desc->getConstPointer()));
01975   const int expected2[6]={0,4,7,10,14,18};
01976   CPPUNIT_ASSERT(std::equal(expected2,expected2+6,descIndx->getConstPointer()));
01977   const int expected3[14]={0,1,3,5,6,8,9,11,12,13,15,16,17,18};
01978   CPPUNIT_ASSERT(std::equal(expected3,expected3+14,revDescIndx->getConstPointer()));
01979   const int expected4[18]={0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4};
01980   CPPUNIT_ASSERT(std::equal(expected4,expected4+18,revDesc->getConstPointer()));
01981   DataArrayInt *conn=mesh2->getNodalConnectivity();
01982   DataArrayInt *connIndex=mesh2->getNodalConnectivityIndex();
01983   const int expected5[14]={0,3,6,9,12,15,18,21,24,27,30,33,36,39};
01984   CPPUNIT_ASSERT(std::equal(expected5,expected5+14,connIndex->getConstPointer()));
01985   const int expected6[39]={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};
01986   CPPUNIT_ASSERT(std::equal(expected6,expected6+39,conn->getConstPointer()));
01987   //
01988   desc->decrRef();
01989   descIndx->decrRef();
01990   revDesc->decrRef();
01991   revDescIndx->decrRef();
01992   mesh2->decrRef();
01993   mesh->decrRef();
01994 }
01995 
01996 void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp1()
01997 {
01998   MEDCouplingCMesh *m1c=MEDCouplingCMesh::New();
01999   DataArrayDouble *coordX=DataArrayDouble::New();
02000   const double arrX[4]={-1., 1., 2., 4.};
02001   coordX->alloc(4,1);
02002   std::copy(arrX,arrX+4,coordX->getPointer());
02003   m1c->setCoordsAt(0,coordX);
02004   DataArrayDouble *coordY=DataArrayDouble::New();
02005   const double arrY[4]={-2., 2., 4., 8.};
02006   coordY->alloc(4,1);
02007   std::copy(arrY,arrY+4,coordY->getPointer());
02008   m1c->setCoordsAt(1,coordY);
02009   MEDCouplingUMesh *m1=m1c->buildUnstructured();
02010   const int subPart1[3]={3,4,5};
02011   MEDCouplingUMesh *m1bis=static_cast<MEDCouplingUMesh *>(m1->buildPartOfMySelf(subPart1,subPart1+3,false));
02012   MEDCouplingUMesh *m2tmp=static_cast<MEDCouplingUMesh *>(m1->deepCpy());
02013   const int subPart2[3]={0,1,2};
02014   MEDCouplingUMesh *m2=static_cast<MEDCouplingUMesh *>(m2tmp->buildPartOfMySelf(subPart2,subPart2+3,false));
02015   const double vec[2]={0.5,0.5};
02016   m2->translate(vec);
02017   // End of construction of input meshes m1bis and m2 -> start of specific part of the test
02018   DataArrayInt *d1=0,*d2=0;
02019   MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1bis,m2,1e-10,d1,d2);
02020   const int expected1[5]={0,1,1,2,2};
02021   const int expected2[5]={0,0,1,1,2};
02022   CPPUNIT_ASSERT_EQUAL(5,d1->getNumberOfTuples());
02023   CPPUNIT_ASSERT_EQUAL(5,d2->getNumberOfTuples());
02024   CPPUNIT_ASSERT_EQUAL(5,m3->getNumberOfCells());
02025   CPPUNIT_ASSERT_EQUAL(22,m3->getNumberOfNodes());
02026   CPPUNIT_ASSERT_EQUAL(2,m3->getSpaceDimension());
02027   CPPUNIT_ASSERT(std::equal(expected1,expected1+5,d1->getConstPointer()));
02028   CPPUNIT_ASSERT(std::equal(expected2,expected2+5,d2->getConstPointer()));
02029   const int expected3[25]={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};
02030   const int expected4[6]={0,5,10,15,20,25};
02031   const double expected5[44]={-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};
02032   CPPUNIT_ASSERT_EQUAL(25,m3->getNodalConnectivity()->getNumberOfTuples());
02033   CPPUNIT_ASSERT_EQUAL(6,m3->getNodalConnectivityIndex()->getNumberOfTuples());
02034   CPPUNIT_ASSERT(std::equal(expected3,expected3+25,m3->getNodalConnectivity()->getConstPointer()));
02035   CPPUNIT_ASSERT(std::equal(expected4,expected4+6,m3->getNodalConnectivityIndex()->getConstPointer()));
02036   for(int i=0;i<44;i++)
02037     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m3->getCoords()->getIJ(0,i),1e-12);
02038   d1->decrRef();
02039   d2->decrRef();
02040   m3->decrRef();
02041   //
02042   m2->decrRef();
02043   m2tmp->decrRef();
02044   m1bis->decrRef();
02045   m1->decrRef();
02046   coordX->decrRef();
02047   coordY->decrRef();
02048   m1c->decrRef();
02049 }
02050 
02051 void MEDCouplingBasicsTest4::testFindNodesOnLine1()
02052 {
02053   MEDCouplingUMesh *mesh=build2DTargetMesh_1();
02054   const double pt[2]={-0.3,-0.3};
02055   const double pt2[3]={0.,0.,0.};
02056   const double pt3[3]={-0.3,0.,0.};
02057   const double vec[2]={0.,1.};
02058   const double vec2[3]={1.,0.,0.};
02059   const double vec3[3]={0.,1.,1.};
02060   const int expected1[3]={0,3,6};
02061   std::vector<int> res;
02062   mesh->findNodesOnLine(pt,vec,1e-12,res);
02063   CPPUNIT_ASSERT_EQUAL(3,(int)res.size());
02064   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,res.begin()));
02065   res.clear();
02066   //
02067   mesh->changeSpaceDimension(3);
02068   mesh->rotate(pt2,vec2,M_PI/4.);
02069   mesh->findNodesOnLine(pt3,vec3,1e-12,res);
02070   CPPUNIT_ASSERT_EQUAL(3,(int)res.size());
02071   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,res.begin()));
02072   //
02073   mesh->decrRef();
02074 }
02075 
02076 void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp2()
02077 {
02078   MEDCouplingCMesh *m1c=MEDCouplingCMesh::New();
02079   DataArrayDouble *coordsX1=DataArrayDouble::New();
02080   const double arrX1[4]={ 0., 1., 1.5, 2. };
02081   coordsX1->alloc(4,1);
02082   std::copy(arrX1,arrX1+4,coordsX1->getPointer());
02083   m1c->setCoordsAt(0,coordsX1);
02084   DataArrayDouble *coordsY1=DataArrayDouble::New();
02085   const double arrY1[3]={ 0., 1.5, 3.};
02086   coordsY1->alloc(3,1);
02087   std::copy(arrY1,arrY1+3,coordsY1->getPointer());
02088   m1c->setCoordsAt(1,coordsY1);
02089   MEDCouplingUMesh *m1=m1c->buildUnstructured();
02090   //
02091   MEDCouplingCMesh *m2c=MEDCouplingCMesh::New();
02092   DataArrayDouble *coordsX2=DataArrayDouble::New();
02093   const double arrX2[3]={ 0., 1., 2. };
02094   coordsX2->alloc(3,1);
02095   std::copy(arrX2,arrX2+3,coordsX2->getPointer());
02096   m2c->setCoordsAt(0,coordsX2);
02097   DataArrayDouble *coordsY2=DataArrayDouble::New();
02098   coordsY2->alloc(3,1);
02099   const double arrY2[3]={ 0., 1., 3.};
02100   std::copy(arrY2,arrY2+3,coordsY2->getPointer());
02101   m2c->setCoordsAt(1,coordsY2);
02102   MEDCouplingUMesh *m2=m2c->buildUnstructured();
02103   //
02104   DataArrayInt *d1=0,*d2=0;
02105   MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2);
02106   const int expected1[9]={0,0,1,1,2,2,3,4,5};
02107   const int expected2[9]={0,2,1,3,1,3,2,3,3};
02108   CPPUNIT_ASSERT_EQUAL(9,d1->getNumberOfTuples());
02109   CPPUNIT_ASSERT_EQUAL(9,d2->getNumberOfTuples());
02110   CPPUNIT_ASSERT_EQUAL(9,m3->getNumberOfCells());
02111   CPPUNIT_ASSERT_EQUAL(22,m3->getNumberOfNodes());
02112   CPPUNIT_ASSERT_EQUAL(2,m3->getSpaceDimension());
02113   CPPUNIT_ASSERT(std::equal(expected1,expected1+9,d1->getConstPointer()));
02114   CPPUNIT_ASSERT(std::equal(expected2,expected2+9,d2->getConstPointer()));
02115   const int expected3[45]={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};
02116   const int expected4[10]={0,5,10,15,20,25,30,35,40,45};
02117   const double expected5[44]={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};
02118   CPPUNIT_ASSERT_EQUAL(45,m3->getNodalConnectivity()->getNumberOfTuples());
02119   CPPUNIT_ASSERT_EQUAL(10,m3->getNodalConnectivityIndex()->getNumberOfTuples());
02120   CPPUNIT_ASSERT(std::equal(expected3,expected3+45,m3->getNodalConnectivity()->getConstPointer()));
02121   CPPUNIT_ASSERT(std::equal(expected4,expected4+10,m3->getNodalConnectivityIndex()->getConstPointer()));
02122   for(int i=0;i<44;i++)
02123     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m3->getCoords()->getIJ(0,i),1e-12);
02124   d1->decrRef();
02125   d2->decrRef();
02126   m3->decrRef();
02127   //
02128   m1c->decrRef();
02129   coordsX1->decrRef();
02130   coordsY1->decrRef();
02131   m1->decrRef();
02132   m2c->decrRef();
02133   coordsX2->decrRef();
02134   coordsY2->decrRef();
02135   m2->decrRef();
02136 }
02137 
02138 void MEDCouplingBasicsTest4::testBuildPartOfMySelfSafe1()
02139 {
02140   MEDCouplingUMesh *mesh=build2DTargetMesh_1();
02141   const int input1[4]={0,-1,4,2};
02142   const int input2[4]={0,4,5,4};
02143   CPPUNIT_ASSERT_THROW(mesh->buildPartOfMySelf(input1,input1+4,true),INTERP_KERNEL::Exception);
02144   CPPUNIT_ASSERT_THROW(mesh->buildPartOfMySelf(input2,input2+4,true),INTERP_KERNEL::Exception);
02145   mesh->decrRef();
02146 }
02147 
02148 void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp3()
02149 {
02150   double m1Coords[50]={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};
02151   int m1Conn[56]={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};
02152   MEDCouplingUMesh *m1=MEDCouplingUMesh::New();
02153   m1->setMeshDimension(2);
02154   m1->allocateCells(8);
02155   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn);
02156   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+6);
02157   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+14);
02158   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+20);
02159   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+28);
02160   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+34);
02161   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+42);
02162   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+48);
02163   m1->finishInsertingCells();
02164   DataArrayDouble *myCoords1=DataArrayDouble::New();
02165   myCoords1->alloc(25,2);
02166   std::copy(m1Coords,m1Coords+50,myCoords1->getPointer());
02167   m1->setCoords(myCoords1);
02168   myCoords1->decrRef();
02169   //
02170   double m2Coords[30]={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.};
02171   int m2Conn[32]={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};
02172   MEDCouplingUMesh *m2=MEDCouplingUMesh::New();
02173   m2->setMeshDimension(2);
02174   m2->allocateCells(8);
02175   for(int i=0;i<8;i++)
02176     m2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,m2Conn+4*i);
02177   m2->finishInsertingCells();
02178   DataArrayDouble *myCoords2=DataArrayDouble::New();
02179   myCoords2->alloc(15,2);
02180   std::copy(m2Coords,m2Coords+30,myCoords2->getPointer());
02181   m2->setCoords(myCoords2);
02182   myCoords2->decrRef();
02183   //
02184   DataArrayInt *d1=0,*d2=0;
02185   MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2);
02186   m3->unPolyze();
02187   const int expected1[12]={0,1,1,2,3,3,4,5,5,6,7,7};
02188   const int expected2[12]={0,0,1,2,2,3,4,4,5,6,6,7};
02189   CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples());
02190   CPPUNIT_ASSERT_EQUAL(12,d2->getNumberOfTuples());
02191   CPPUNIT_ASSERT_EQUAL(12,m3->getNumberOfCells());
02192   CPPUNIT_ASSERT_EQUAL(88,m3->getNumberOfNodes());
02193   CPPUNIT_ASSERT_EQUAL(2,m3->getSpaceDimension());
02194   CPPUNIT_ASSERT(std::equal(expected1,expected1+12,d1->getConstPointer()));
02195   CPPUNIT_ASSERT(std::equal(expected2,expected2+12,d2->getConstPointer()));
02196   const int expected3[100]={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};
02197   const int expected4[13]={0,7,16,25,32,41,50,57,66,75,82,91,100};
02198   const double expected5[176]={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};
02199   CPPUNIT_ASSERT_EQUAL(100,m3->getNodalConnectivity()->getNumberOfTuples());
02200   CPPUNIT_ASSERT_EQUAL(13,m3->getNodalConnectivityIndex()->getNumberOfTuples());
02201   CPPUNIT_ASSERT(std::equal(expected3,expected3+100,m3->getNodalConnectivity()->getConstPointer()));
02202   CPPUNIT_ASSERT(std::equal(expected4,expected4+13,m3->getNodalConnectivityIndex()->getConstPointer()));
02203   for(int i=0;i<176;i++)
02204     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m3->getCoords()->getIJ(0,i),1e-12);
02205   d1->decrRef();
02206   d2->decrRef();
02207   m3->decrRef();
02208   //
02209   m1->decrRef();
02210   m2->decrRef();
02211 }