Salome HOME
f781b061a3bc1b506d6676dbe4ae303e185370ef
[modules/med.git] / src / MEDCoupling / Test / MEDCouplingBasicsTest4.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDCouplingBasicsTest4.hxx"
22 #include "MEDCouplingUMesh.hxx"
23 #include "MEDCouplingCMesh.hxx"
24 #include "MEDCouplingExtrudedMesh.hxx"
25 #include "MEDCouplingFieldDouble.hxx"
26 #include "MEDCouplingMemArray.hxx"
27 #include "MEDCouplingGaussLocalization.hxx"
28 #include "MEDCouplingMultiFields.hxx"
29 #include "MEDCouplingFieldOverTime.hxx"
30
31 #include <cmath>
32 #include <functional>
33 #include <iterator>
34
35 using namespace ParaMEDMEM;
36
37 void MEDCouplingBasicsTest4::testDescriptionInMeshTimeUnit1()
38 {
39   static const char text1[]="totoTTEDD";
40   MEDCouplingUMesh *m=build2DTargetMesh_1();
41   m->setDescription(text1);
42   CPPUNIT_ASSERT(std::string(m->getDescription())==text1);
43   MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCpy();
44   CPPUNIT_ASSERT(m->isEqual(m2,1e-12));
45   CPPUNIT_ASSERT(std::string(m2->getDescription())==text1);
46   m2->setDescription("ggg");
47   CPPUNIT_ASSERT(!m->isEqual(m2,1e-12));
48   m2->decrRef();
49   //
50   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
51   f->setTimeUnit(text1);
52   CPPUNIT_ASSERT(std::string(f->getTimeUnit())==text1);
53   MEDCouplingFieldDouble *f2=f->deepCpy();
54   CPPUNIT_ASSERT(std::string(f2->getTimeUnit())==text1);
55   f2->decrRef();
56   //
57   f->decrRef();
58   m->decrRef();
59 }
60
61 void MEDCouplingBasicsTest4::testMultiFields1()
62 {
63   MEDCouplingMultiFields *mfs=buildMultiFields_1();
64   std::vector<MEDCouplingMesh *> ms=mfs->getMeshes();
65   std::vector<int> refs;
66   std::vector<MEDCouplingMesh *> dms=mfs->getDifferentMeshes(refs);
67   std::vector<DataArrayDouble *> das=mfs->getArrays();
68   std::vector< std::vector<int> > refs2;
69   std::vector<DataArrayDouble *> das2=mfs->getDifferentArrays(refs2);
70   //
71   CPPUNIT_ASSERT_EQUAL(5,(int)ms.size());
72   CPPUNIT_ASSERT_EQUAL(2,(int)dms.size());
73   CPPUNIT_ASSERT_EQUAL(6,(int)das.size());
74   CPPUNIT_ASSERT_EQUAL(5,(int)das2.size());
75   //
76   MEDCouplingMultiFields *mfs2=mfs->deepCpy();
77   CPPUNIT_ASSERT(mfs->isEqual(mfs2,1e-12,1e-12));
78   mfs2->decrRef();
79   //
80   mfs->decrRef();
81 }
82
83 void MEDCouplingBasicsTest4::testFieldOverTime1()
84 {
85   std::vector<MEDCouplingFieldDouble *> fs=buildMultiFields_2();
86   CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception);
87   MEDCouplingFieldDouble *f4bis=fs[4]->buildNewTimeReprFromThis(ONE_TIME,false);
88   fs[4]->decrRef();
89   fs[4]=f4bis;
90   CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception);
91   f4bis->setTime(2.7,20,21);
92   MEDCouplingFieldOverTime *fot=MEDCouplingFieldOverTime::New(fs);
93   MEDCouplingDefinitionTime dt=fot->getDefinitionTimeZone();
94   std::vector<double> hs=dt.getHotSpotsTime();
95   CPPUNIT_ASSERT_EQUAL(6,(int)hs.size());
96   const double expected1[]={0.2,0.7,1.2,1.35,1.7,2.7};
97   for(int i=0;i<6;i++)
98     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],hs[i],1e-12);
99   int meshId,arrId,arrIdInField,fieldId;
100   dt.getIdsOnTimeRight(0.2,meshId,arrId,arrIdInField,fieldId);
101   CPPUNIT_ASSERT_EQUAL(0,meshId);
102   CPPUNIT_ASSERT_EQUAL(0,arrId);
103   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
104   CPPUNIT_ASSERT_EQUAL(0,fieldId);
105   //
106   dt.getIdsOnTimeRight(0.7,meshId,arrId,arrIdInField,fieldId);
107   CPPUNIT_ASSERT_EQUAL(0,meshId);
108   CPPUNIT_ASSERT_EQUAL(1,arrId);
109   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
110   CPPUNIT_ASSERT_EQUAL(1,fieldId);
111   //
112   dt.getIdsOnTimeLeft(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING left here
113   CPPUNIT_ASSERT_EQUAL(0,meshId);
114   CPPUNIT_ASSERT_EQUAL(2,arrId);
115   CPPUNIT_ASSERT_EQUAL(1,arrIdInField);
116   CPPUNIT_ASSERT_EQUAL(1,fieldId);
117   //
118   dt.getIdsOnTimeRight(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING right again here
119   CPPUNIT_ASSERT_EQUAL(1,meshId);
120   CPPUNIT_ASSERT_EQUAL(3,arrId);
121   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
122   CPPUNIT_ASSERT_EQUAL(2,fieldId);
123   //
124   dt.getIdsOnTimeRight(1.35,meshId,arrId,arrIdInField,fieldId);
125   CPPUNIT_ASSERT_EQUAL(1,meshId);
126   CPPUNIT_ASSERT_EQUAL(3,arrId);
127   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
128   CPPUNIT_ASSERT_EQUAL(2,fieldId);
129   //
130   dt.getIdsOnTimeRight(1.7,meshId,arrId,arrIdInField,fieldId);
131   CPPUNIT_ASSERT_EQUAL(0,meshId);
132   CPPUNIT_ASSERT_EQUAL(3,arrId);
133   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
134   CPPUNIT_ASSERT_EQUAL(3,fieldId);
135   //
136   dt.getIdsOnTimeRight(2.7,meshId,arrId,arrIdInField,fieldId);
137   CPPUNIT_ASSERT_EQUAL(1,meshId);
138   CPPUNIT_ASSERT_EQUAL(4,arrId);
139   CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
140   CPPUNIT_ASSERT_EQUAL(4,fieldId);
141   //
142   MEDCouplingDefinitionTime dt2;
143   CPPUNIT_ASSERT(!dt2.isEqual(dt));
144   dt2.assign(dt);
145   dt2.assign(dt);//to check memory management
146   CPPUNIT_ASSERT(dt2.isEqual(dt));
147   //
148   MEDCouplingDefinitionTime dt3;
149   std::vector<int> tmp1;
150   std::vector<double> tmp2;
151   CPPUNIT_ASSERT(!dt2.isEqual(dt3));
152   dt2.getTinySerializationInformation(tmp1,tmp2);
153   dt3.unserialize(tmp1,tmp2);
154   CPPUNIT_ASSERT(dt2.isEqual(dt3));
155   //
156   for(std::vector<MEDCouplingFieldDouble *>::iterator it=fs.begin();it!=fs.end();it++)
157     (*it)->decrRef();
158   fot->decrRef();
159 }
160
161 void MEDCouplingBasicsTest4::testDAICheckAndPreparePermutation1()
162 {
163   const int vals1[]={9,10,0,6,4,11,3,7};
164   const int expect1[]={5,6,0,3,2,7,1,4};
165   const int vals2[]={9,10,0,6,10,11,3,7};
166   DataArrayInt *da=DataArrayInt::New();
167   da->alloc(8,1);
168   std::copy(vals1,vals1+8,da->getPointer());
169   DataArrayInt *da2=da->checkAndPreparePermutation();
170   CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
171   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
172   for(int i=0;i<8;i++)
173     CPPUNIT_ASSERT_EQUAL(expect1[i],da2->getIJ(i,0));
174   da2->decrRef();
175   da->decrRef();
176   //
177   da=DataArrayInt::New();
178   da->alloc(8,1);
179   da->iota(0);
180   da2=da->checkAndPreparePermutation();
181   CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
182   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
183   CPPUNIT_ASSERT(da2->isIdentity());
184   da2->decrRef();
185   da->decrRef();
186   //
187   da=DataArrayInt::New();
188   da->alloc(8,1);
189   std::copy(vals2,vals2+8,da->getPointer());
190   CPPUNIT_ASSERT_THROW(da->checkAndPreparePermutation(),INTERP_KERNEL::Exception);
191   da->decrRef();
192 }
193
194 void MEDCouplingBasicsTest4::testDAIChangeSurjectiveFormat1()
195 {
196   const int vals1[8]={0,3,2,3,2,2,1,2};
197   const int expected1[5]={0,1,2,6,8};
198   const int expected2[8]={0,  6,  2,4,5,7,  1,3};
199   DataArrayInt *da=DataArrayInt::New();
200   da->alloc(8,1);
201   std::copy(vals1,vals1+8,da->getPointer());
202   //
203   DataArrayInt *da2,*da2I;
204   da->changeSurjectiveFormat(4,da2,da2I);
205   CPPUNIT_ASSERT_EQUAL(5,da2I->getNumberOfTuples());
206   CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
207   CPPUNIT_ASSERT(std::equal(expected1,expected1+5,da2I->getConstPointer()));
208   CPPUNIT_ASSERT(std::equal(expected2,expected2+8,da2->getConstPointer()));
209   da2->decrRef();
210   da2I->decrRef();
211   //
212   CPPUNIT_ASSERT_THROW(da->changeSurjectiveFormat(3,da2,da2I),INTERP_KERNEL::Exception);
213   //
214   da->decrRef();
215 }
216
217 void MEDCouplingBasicsTest4::testUMeshGetCellIdsLyingOnNodes1()
218 {
219   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
220   const int nodeIds1[5]={1,2,3,4,6};
221   const int nodeIds2[2]={6,7};
222   DataArrayInt *da=m->getCellIdsLyingOnNodes(nodeIds1,nodeIds1+5,true);
223   CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfTuples());
224   CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
225   CPPUNIT_ASSERT_EQUAL(1,da->getIJ(0,0));
226   da->decrRef();
227   da=m->getCellIdsLyingOnNodes(nodeIds2,nodeIds2+2,false);
228   CPPUNIT_ASSERT_EQUAL(2,da->getNumberOfTuples());
229   CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
230   CPPUNIT_ASSERT_EQUAL(3,da->getIJ(0,0));
231   CPPUNIT_ASSERT_EQUAL(4,da->getIJ(1,0));
232   da->decrRef();
233   //
234   m->decrRef();
235 }
236
237 void MEDCouplingBasicsTest4::testUMeshFindCellIdsOnBoundary1()
238 {
239   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
240   DataArrayInt *da5=m->findCellIdsOnBoundary();
241   CPPUNIT_ASSERT_EQUAL(5,da5->getNumberOfTuples());
242   CPPUNIT_ASSERT(da5->isIdentity());
243   //
244   da5->decrRef();
245   m->decrRef();
246 }
247
248 void MEDCouplingBasicsTest4::testMeshSetTime1()
249 {
250   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
251   MEDCouplingUMesh *m2=build3DSurfTargetMesh_1();
252   //
253   CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
254   m1->setTime(3.14,6,7);
255   int tmp1,tmp2;
256   double tmp3=m1->getTime(tmp1,tmp2);
257   CPPUNIT_ASSERT_EQUAL(6,tmp1);
258   CPPUNIT_ASSERT_EQUAL(7,tmp2);
259   CPPUNIT_ASSERT_DOUBLES_EQUAL(3.14,tmp3,1e-12);
260   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
261   m2->setTime(3.14,6,7);
262   CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
263   m1->setTimeUnit("ms");
264   CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="ms");
265   m1->setTimeUnit("us");
266   CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="us");
267   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
268   m2->setTimeUnit("us");
269   CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
270   m2->setTime(3.14,6,8);
271   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
272   m2->setTime(3.14,7,7);
273   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
274   m2->setTime(3.15,6,7);
275   CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
276   //
277   m1->setTime(10.34,55,12);
278   MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->deepCpy();
279   CPPUNIT_ASSERT(m1->isEqual(m3,1e-12));
280   tmp3=m3->getTime(tmp1,tmp2);
281   CPPUNIT_ASSERT_EQUAL(55,tmp1);
282   CPPUNIT_ASSERT_EQUAL(12,tmp2);
283   CPPUNIT_ASSERT_DOUBLES_EQUAL(10.34,tmp3,1e-12);
284   //
285   m3->decrRef();
286   m1->decrRef();
287   m2->decrRef();
288   // testing CMesh
289   const double coo1[4]={0.,1.,2.,3.5};
290   DataArrayDouble *a=DataArrayDouble::New();
291   a->alloc(4,1);
292   std::copy(coo1,coo1+4,a->getPointer());
293   MEDCouplingCMesh *b=MEDCouplingCMesh::New();
294   b->setCoordsAt(0,a);
295   a->decrRef();
296   //
297   b->setTime(5.67,8,100);
298   tmp3=b->getTime(tmp1,tmp2);
299   CPPUNIT_ASSERT_EQUAL(8,tmp1);
300   CPPUNIT_ASSERT_EQUAL(100,tmp2);
301   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12);
302   MEDCouplingCMesh *c=(MEDCouplingCMesh *)b->deepCpy();
303   CPPUNIT_ASSERT(c->isEqual(b,1e-12));
304   tmp3=c->getTime(tmp1,tmp2);
305   CPPUNIT_ASSERT_EQUAL(8,tmp1);
306   CPPUNIT_ASSERT_EQUAL(100,tmp2);
307   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12);
308   c->decrRef();
309   b->decrRef();
310 }
311
312 void MEDCouplingBasicsTest4::testApplyFuncTwo1()
313 {
314   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
315   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
316   f1->setMesh(m1);
317   //
318   const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.};
319   DataArrayDouble *da=DataArrayDouble::New();
320   da->alloc(5,3);
321   std::copy(vals,vals+15,da->getPointer());
322   f1->setArray(da);
323   //
324   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"y+z"),INTERP_KERNEL::Exception);
325   da->setInfoOnComponent(0,"x [m]");
326   da->setInfoOnComponent(1,"y [mm]");
327   da->setInfoOnComponent(2,"z [km]");
328   
329   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"x+y+zz+zzz"),INTERP_KERNEL::Exception);
330   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"toto(x+y)"),INTERP_KERNEL::Exception);
331   CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"x/0"),INTERP_KERNEL::Exception);
332   
333   DataArrayDouble *da2=da->applyFunc2(1,"y+z");
334   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
335   CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples());
336   const double expected1[5]={32.,34.,36.,38.,40.};
337   for(int i=0;i<5;i++)
338     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12);
339   da2->decrRef();
340   da2=da->applyFunc(1,"y+z");
341   const double expected2[5]={12.,14.,16.,18.,20.};
342   for(int i=0;i<5;i++)
343     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],da2->getIJ(0,i),1e-12);
344   da2->decrRef();
345   //
346   CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents());
347   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
348   f1->applyFunc2(1,"y+z");
349   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
350   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
351   for(int i=0;i<5;i++)
352     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
353   //
354   da->decrRef();
355   f1->decrRef();
356   m1->decrRef();
357 }
358
359 void MEDCouplingBasicsTest4::testApplyFuncThree1()
360 {
361   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
362   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
363   f1->setMesh(m1);
364   //
365   const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.};
366   DataArrayDouble *da=DataArrayDouble::New();
367   da->alloc(5,3);
368   std::copy(vals,vals+15,da->getPointer());
369   f1->setArray(da);
370   //
371   std::vector<std::string> vs(3);
372   vs[0]="x"; vs[1]="Y"; vs[2]="z";
373   CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"y+z"),INTERP_KERNEL::Exception);
374   CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"x+Y+z+zz+zzz"),INTERP_KERNEL::Exception);
375   CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"x/0."),INTERP_KERNEL::Exception);
376   vs[1]="y";
377   DataArrayDouble *da2=da->applyFunc3(1,vs,"y+z");
378   const double expected1[5]={32.,34.,36.,38.,40.};
379   for(int i=0;i<5;i++)
380     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12);
381   da2->decrRef();
382   std::vector<std::string> vs2(4); vs2[0]="x"; vs2[1]="y"; vs2[2]="z"; vs2[3]="a";
383   CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs2,"x+a"),INTERP_KERNEL::Exception);
384   f1->setArray(da);
385   CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents());
386   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
387   f1->applyFunc3(1,vs,"y+z");
388   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
389   CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
390   for(int i=0;i<5;i++)
391     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
392   //
393   da->decrRef();
394   f1->decrRef();
395   m1->decrRef();
396 }
397
398 void MEDCouplingBasicsTest4::testFillFromAnalyticTwo1()
399 {
400   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
401   CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic2(ON_NODES,1,"y+z"),INTERP_KERNEL::Exception);
402   m1->getCoords()->setInfoOnComponent(0,"x [m]");
403   m1->getCoords()->setInfoOnComponent(1,"y");
404   m1->getCoords()->setInfoOnComponent(2,"z");
405   MEDCouplingFieldDouble *f1=m1->fillFromAnalytic2(ON_NODES,1,"y+z");
406   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
407   CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
408   const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2};
409   for(int i=0;i<9;i++)
410     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
411   f1->decrRef();
412   m1->decrRef();
413 }
414
415 void MEDCouplingBasicsTest4::testFillFromAnalyticThree1()
416 {
417   MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
418   std::vector<std::string> vs(3);
419   vs[0]="x"; vs[1]="Y"; vs[2]="z";
420   CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z"),INTERP_KERNEL::Exception);
421   vs[1]="y";
422   MEDCouplingFieldDouble *f1=m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z");
423   CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
424   CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
425   const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2};
426   for(int i=0;i<9;i++)
427     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
428   f1->decrRef();
429   m1->decrRef();
430 }
431
432 void MEDCouplingBasicsTest4::testDAUnitVar1()
433 {
434   DataArrayDouble *da=DataArrayDouble::New();
435   da->alloc(1,3);
436   da->setInfoOnComponent(0,"XPS [m]");
437   std::string st1,st2;
438   st1=da->getVarOnComponent(0);
439   CPPUNIT_ASSERT(st1=="XPS");
440   st2=da->getUnitOnComponent(0);
441   CPPUNIT_ASSERT(st2=="m");
442   //
443   da->setInfoOnComponent(0,"XPS         [m]");
444   st1=da->getVarOnComponent(0);
445   CPPUNIT_ASSERT(st1=="XPS");
446   st2=da->getUnitOnComponent(0);
447   CPPUNIT_ASSERT(st2=="m");
448   //
449   da->setInfoOnComponent(0,"XPP         [m]");
450   st1=da->getVarOnComponent(0);
451   CPPUNIT_ASSERT(st1=="XPP");
452   st2=da->getUnitOnComponent(0);
453   CPPUNIT_ASSERT(st2=="m");
454   //
455   da->setInfoOnComponent(0,"XPP kdep  kefer   [ m  ]");
456   st1=da->getVarOnComponent(0);
457   CPPUNIT_ASSERT(st1=="XPP kdep  kefer");
458   st2=da->getUnitOnComponent(0);
459   CPPUNIT_ASSERT(st2==" m  ");
460   //
461   da->setInfoOnComponent(0,"     XPP k[  dep  k]efer   [ m^ 2/s^3*kJ  ]");
462   st1=da->getVarOnComponent(0);
463   CPPUNIT_ASSERT(st1=="     XPP k[  dep  k]efer");
464   st2=da->getUnitOnComponent(0);
465   CPPUNIT_ASSERT(st2==" m^ 2/s^3*kJ  ");
466   //
467   da->setInfoOnComponent(0,"     XPP kefer   ");
468   st1=da->getVarOnComponent(0);
469   CPPUNIT_ASSERT(st1=="     XPP kefer   ");
470   st2=da->getUnitOnComponent(0);
471   CPPUNIT_ASSERT(st2=="");
472   //
473   da->setInfoOnComponent(0,"temperature( bof)");
474   st1=da->getVarOnComponent(0);
475   CPPUNIT_ASSERT(st1=="temperature( bof)");
476   st2=da->getUnitOnComponent(0);
477   CPPUNIT_ASSERT(st2=="");
478   //
479   da->setInfoOnComponent(0,"kkk [m]");
480   da->setInfoOnComponent(1,"ppp   [m^2/kJ]");
481   da->setInfoOnComponent(2,"abcde   [MW/s]");
482   //
483   std::vector<std::string> vs;
484   vs=da->getVarsOnComponent();
485   CPPUNIT_ASSERT_EQUAL(3,(int)vs.size());
486   CPPUNIT_ASSERT(vs[0]=="kkk");
487   CPPUNIT_ASSERT(vs[1]=="ppp");
488   CPPUNIT_ASSERT(vs[2]=="abcde");
489   vs=da->getUnitsOnComponent();
490   CPPUNIT_ASSERT_EQUAL(3,(int)vs.size());
491   CPPUNIT_ASSERT(vs[0]=="m");
492   CPPUNIT_ASSERT(vs[1]=="m^2/kJ");
493   CPPUNIT_ASSERT(vs[2]=="MW/s");
494   //
495   da->decrRef();
496 }
497
498 void MEDCouplingBasicsTest4::testGaussCoordinates1()
499 {
500   //Testing 1D cell types
501   MEDCouplingUMesh *m1=build1DMultiTypes_1();
502   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
503   f->setMesh(m1);
504   std::vector<double> wg1(1); wg1[0]=0.3;
505   std::vector<double> gsCoo1(1); gsCoo1[0]=0.2;
506   std::vector<double> refCoo1(2); refCoo1[0]=-1.0; refCoo1[1]=1.0;
507   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG2,refCoo1,gsCoo1,wg1);
508   std::vector<double> wg2(wg1);
509   std::vector<double> gsCoo2(1); gsCoo2[0]=0.2;
510   std::vector<double> refCoo2(3); refCoo2[0]=-1.0; refCoo2[1]=1.0; refCoo2[2]=0.0;
511   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG3,refCoo2,gsCoo2,wg2);
512   //
513   DataArrayDouble *resToTest=f->getLocalizationOfDiscr();
514   CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
515   CPPUNIT_ASSERT_EQUAL(2,resToTest->getNumberOfTuples());
516   const double expected1[6]={0.6,0.6,0.6, 0.6,0.6,0.6};
517   for(int i=0;i<6;i++)
518     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],resToTest->getIJ(0,i),1e-14);
519   resToTest->decrRef();
520   //
521   m1->decrRef();
522   f->decrRef();
523   //Testing 2D cell types
524   MEDCouplingUMesh *m2=build2DMultiTypes_1();
525   f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
526   f->setMesh(m2);
527   std::vector<double> wg3(2); wg3[0]=0.3; wg3[1]=0.3;
528   const double tria3CooGauss[4]={ 0.1, 0.8, 0.2, 0.7 };
529   std::vector<double> gsCoo3(tria3CooGauss,tria3CooGauss+4);
530   const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 };
531   std::vector<double> refCoo3(tria3CooRef,tria3CooRef+6);
532   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,refCoo3,gsCoo3,wg3);
533   std::vector<double> wg4(3); wg4[0]=0.3; wg4[1]=0.3; wg4[2]=0.3;
534   const double tria6CooGauss[6]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 };
535   std::vector<double> gsCoo4(tria6CooGauss,tria6CooGauss+6);
536   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};
537   std::vector<double> refCoo4(tria6CooRef,tria6CooRef+12);
538   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,refCoo4,gsCoo4,wg4);
539   std::vector<double> wg5(4); wg5[0]=0.3; wg5[1]=0.3; wg5[2]=0.3; wg5[3]=0.3;
540   const double quad4CooGauss[8]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 };
541   std::vector<double> gsCoo5(quad4CooGauss,quad4CooGauss+8);
542   const double quad4CooRef[8]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0};
543   std::vector<double> refCoo5(quad4CooRef,quad4CooRef+8);
544   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,refCoo5,gsCoo5,wg5);
545   std::vector<double> wg6(4); wg6[0]=0.3; wg6[1]=0.3; wg6[2]=0.3; wg6[3]=0.3;
546   const double quad8CooGauss[8]={ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 };
547   std::vector<double> gsCoo6(quad8CooGauss,quad8CooGauss+8);
548   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};
549   std::vector<double> refCoo6(quad8CooRef,quad8CooRef+16);
550   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD8,refCoo6,gsCoo6,wg6);
551   //
552   resToTest=f->getLocalizationOfDiscr();
553   CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
554   CPPUNIT_ASSERT_EQUAL(13,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
555   const double expected2[39]={5.1,1.55,0.0, 4.7,1.65,0.0, //TRI3
556                               2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,//TRI6
557                               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
558                               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
559   for(int i=0;i<39;i++)
560     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],resToTest->getIJ(0,i),1e-14);
561   resToTest->decrRef();
562   //
563   m2->decrRef();
564   f->decrRef();
565   //Testing 3D cell types
566   MEDCouplingUMesh *m3=build3DMultiTypes_1();
567   f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
568   f->setMesh(m3);
569   //
570   std::vector<double> wg7(1); wg7[0]=0.3;
571   const double tetra4CooGauss[3]={0.34, 0.16, 0.21};
572   std::vector<double> gsCoo7(tetra4CooGauss,tetra4CooGauss+3);
573   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};
574   std::vector<double> refCoo7(tetra4CooRef,tetra4CooRef+12);
575   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA4,refCoo7,gsCoo7,wg7);
576   std::vector<double> wg8(1); wg8[0]=0.3;
577   const double tetra10CooGauss[3]={0.2, 0.3, 0.1};
578   std::vector<double> gsCoo8(tetra10CooGauss,tetra10CooGauss+3);
579   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};
580   std::vector<double> refCoo8(tetra10CooRef,tetra10CooRef+30);
581   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA10,refCoo8,gsCoo8,wg8);
582   std::vector<double> wg9(1); wg9[0]=0.3;
583   const double pyra5CooGauss[3]={0.2, 0.3, 0.1};
584   std::vector<double> gsCoo9(pyra5CooGauss,pyra5CooGauss+3);
585   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};
586   std::vector<double> refCoo9(pyra5CooRef,pyra5CooRef+15);
587   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA5,refCoo9,gsCoo9,wg9);
588   std::vector<double> wg10(1); wg10[0]=0.3;
589   const double pyra13CooGauss[3]={0.1, 0.2, 0.7};
590   std::vector<double> gsCoo10(pyra13CooGauss,pyra13CooGauss+3);
591   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};
592   std::vector<double> refCoo10(pyra13CooRef,pyra13CooRef+39);
593   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA13,refCoo10,gsCoo10,wg10);
594   std::vector<double> wg11(1); wg11[0]=0.3;
595   const double penta6CooGauss[3]={0.2, 0.3, 0.1};
596   std::vector<double> gsCoo11(penta6CooGauss,penta6CooGauss+3);
597   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};
598   std::vector<double> refCoo11(penta6CooRef,penta6CooRef+18);
599   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA6,refCoo11,gsCoo11,wg11);
600   std::vector<double> wg12(1); wg12[0]=0.3;
601   const double penta15CooGauss[3]={0.2, 0.3,0.15};
602   std::vector<double> gsCoo12(penta15CooGauss,penta15CooGauss+3);
603   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};
604   std::vector<double> refCoo12(penta15CooRef,penta15CooRef+45);
605   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA15,refCoo12,gsCoo12,wg12);
606   std::vector<double> wg13(1); wg13[0]=0.3;
607   const double hexa8CooGauss[3]={0.2,0.3,0.15};
608   std::vector<double> gsCoo13(hexa8CooGauss,hexa8CooGauss+3);
609   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};
610   std::vector<double> refCoo13(hexa8CooRef,hexa8CooRef+24);
611   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA8,refCoo13,gsCoo13,wg13);
612   std::vector<double> wg14(1); wg14[0]=0.3;
613   const double hexa20CooGauss[3]={0.11,0.3,0.55};
614   std::vector<double> gsCoo14(hexa20CooGauss,hexa20CooGauss+3);
615   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};
616   std::vector<double> refCoo14(hexa20CooRef,hexa20CooRef+60);
617   f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA20,refCoo14,gsCoo14,wg14);
618   //
619   resToTest=f->getLocalizationOfDiscr();
620   CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
621   CPPUNIT_ASSERT_EQUAL(8,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
622   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};
623   for(int i=0;i<24;i++)
624     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],resToTest->getIJ(0,i),1e-14);
625   resToTest->decrRef();
626   //
627   m3->decrRef();
628   f->decrRef();
629 }
630
631 /*!
632  * Not activated test ! To be implemented !
633  */
634 void MEDCouplingBasicsTest4::testQ1Localization1()
635 {
636   MEDCouplingUMesh *m=buildHexa8Mesh_1();
637   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
638   DataArrayDouble *da=DataArrayDouble::New();
639   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};
640   da->alloc(27,1);
641   std::copy(vals1,vals1+27,da->getPointer());
642   f->setMesh(m);
643   f->setArray(da);
644   da->decrRef();
645   //
646   const double point1[3]={0.25,0.75,0.25};
647   //const double points1[6]={0.25,0.75,0.25,1.0,1.0,1.0};
648   double res1[3];
649   f->getValueOn(point1,res1);
650   //
651   f->decrRef();
652   m->decrRef();
653 }
654
655 void MEDCouplingBasicsTest4::testP2Localization1()
656 {
657   MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2",2);
658   const double coords[12]={0.,2.,3.5,0.,4.5,1.5,1.2,0.32,3.4,1.,2.1,2.4};
659   const int conn[6]={0,1,2,3,4,5};
660   DataArrayDouble *coo=DataArrayDouble::New();
661   coo->alloc(6,2);
662   std::copy(coords,coords+12,coo->getPointer());
663   m->setCoords(coo);
664   coo->decrRef();
665   m->allocateCells(1);
666   m->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn);
667   m->finishInsertingCells();
668   //
669   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
670   f->setMesh(m);
671   DataArrayDouble *da=DataArrayDouble::New();
672   da->alloc(6,3);
673   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};
674   std::copy(vals1,vals1+18,da->getPointer());
675   f->setArray(da);
676   da->decrRef();
677   //
678   const double loc[2]={2.27,1.3};
679   DataArrayDouble *locs=f->getValueOnMulti(loc,1);
680   const double expected1[3]={6.0921164547752236, 7.1921164547752232, 8.2921164547752255};
681   for(int i=0;i<3;i++)
682     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12);
683   locs->decrRef();
684   //
685   m->decrRef();
686   f->decrRef();
687 }
688
689 void MEDCouplingBasicsTest4::testP2Localization2()
690 {
691   MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2_2",3);
692   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};
693   const int conn[10]={0,1,2,3,4,5,6,7,8,9};
694   DataArrayDouble *coo=DataArrayDouble::New();
695   coo->alloc(10,3);
696   std::copy(coords,coords+30,coo->getPointer());
697   m->setCoords(coo);
698   coo->decrRef();
699   m->allocateCells(1);
700   m->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn);
701   m->finishInsertingCells();
702   //
703   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
704   f->setMesh(m);
705   DataArrayDouble *da=DataArrayDouble::New();
706   da->alloc(10,1);
707   const double vals1[10]={1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2};
708   std::copy(vals1,vals1+10,da->getPointer());
709   f->setArray(da);
710   da->decrRef();
711   //
712   const double loc[3]={0.64637931739890486, -0.16185896817550552, 0.22678966365273748};
713   DataArrayDouble *locs=f->getValueOnMulti(loc,1);
714   const double expected1[1]={10.0844021968047};
715   for(int i=0;i<1;i++)
716     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12);
717   locs->decrRef();
718   //
719   m->decrRef();
720   f->decrRef();
721 }
722
723 void MEDCouplingBasicsTest4::testGetValueOn2()
724 {
725   MEDCouplingUMesh *m=build2DTargetMesh_1();
726   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
727   f->setMesh(m);
728   DataArrayDouble *arr=DataArrayDouble::New();
729   int nbOfCells=m->getNumberOfCells();
730   arr->alloc(nbOfCells,3);
731   f->setArray(arr);
732   arr->decrRef();
733   const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.};
734   std::copy(values1,values1+15,arr->getPointer());
735   const double loc[10]={-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45};
736   f->checkCoherency();
737   DataArrayDouble *locs=f->getValueOnMulti(loc,5);
738   CPPUNIT_ASSERT_EQUAL(5,locs->getNumberOfTuples());
739   CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
740   for(int j=0;j<15;j++)
741     CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[j],locs->getIJ(0,j),1e-12);
742   locs->decrRef();
743   f->decrRef();
744   // Testing ON_NODES
745   f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
746   f->setMesh(m);
747   arr=DataArrayDouble::New();
748   int nbOfNodes=m->getNumberOfNodes();
749   arr->alloc(nbOfNodes,3);
750   f->setArray(arr);
751   arr->decrRef();
752   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.};
753   std::copy(values2,values2+27,arr->getPointer());
754   const double loc2[8]={0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432};
755   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};
756   f->checkCoherency();
757   locs=f->getValueOnMulti(loc2,4);
758   CPPUNIT_ASSERT_EQUAL(4,locs->getNumberOfTuples());
759   CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
760   for(int i=0;i<12;i++)
761     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],locs->getIJ(0,i),1e-12);
762   f->decrRef();
763   locs->decrRef();
764   //
765   m->decrRef();
766 }
767
768 void MEDCouplingBasicsTest4::testDAIGetIdsNotEqual1()
769 {
770   DataArrayInt *d=DataArrayInt::New();
771   const int vals1[10]={2,3,5,6,8,5,5,6,1,-5};
772   d->alloc(10,1);
773   std::copy(vals1,vals1+10,d->getPointer());
774   DataArrayInt *d2=d->getIdsNotEqual(5);
775   CPPUNIT_ASSERT_EQUAL(7,d2->getNumberOfTuples());
776   CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents());
777   const int expected1[7]={0,1,3,4,7,8,9};
778   for(int i=0;i<7;i++)
779     CPPUNIT_ASSERT_EQUAL(expected1[i],d2->getIJ(0,i));
780   d->rearrange(2);
781   CPPUNIT_ASSERT_THROW(d->getIdsNotEqual(5),INTERP_KERNEL::Exception);
782   const int vals2[3]={-4,5,6};
783   std::vector<int> vals3(vals2,vals2+3);
784   d->rearrange(1);
785   DataArrayInt *d3=d->getIdsNotEqualList(&vals3[0],&vals3[0]+vals3.size());
786   CPPUNIT_ASSERT_EQUAL(5,d3->getNumberOfTuples());
787   CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents());
788   const int expected2[5]={0,1,4,8,9};
789   for(int i=0;i<5;i++)
790     CPPUNIT_ASSERT_EQUAL(expected2[i],d3->getIJ(0,i));
791   d3->decrRef();
792   d->decrRef();
793   d2->decrRef();
794 }
795
796 void MEDCouplingBasicsTest4::testDAIComputeOffsets1()
797 {
798   DataArrayInt *d=DataArrayInt::New();
799   const int vals1[6]={3,5,1,2,0,8};
800   const int expected1[6]={0,3,8,9,11,11};
801   d->alloc(6,1);
802   std::copy(vals1,vals1+6,d->getPointer());
803   d->computeOffsets();
804   CPPUNIT_ASSERT_EQUAL(6,d->getNumberOfTuples());
805   CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
806   for(int i=0;i<6;i++)
807     CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
808   d->decrRef();
809 }
810
811 void MEDCouplingBasicsTest4::testUMeshHexagonPrism1()
812 {
813   const double coords[36]={
814     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,
815     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
816   };
817   const int conn[12]={1,2,3,4,5,0,7,8,9,10,11,6};
818   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("MyFirstHexagonalPrism",3);
819   DataArrayDouble *coo=DataArrayDouble::New();
820   coo->alloc(12,3);
821   std::copy(coords,coords+36,coo->getPointer());
822   mesh->setCoords(coo);
823   mesh->allocateCells(1);
824   mesh->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn);
825   mesh->finishInsertingCells();
826   coo->decrRef();
827   //
828   mesh->checkCoherency();
829   MEDCouplingFieldDouble *vols=mesh->getMeasureField(false);
830   CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfTuples());
831   CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfComponents());
832   CPPUNIT_ASSERT_DOUBLES_EQUAL(-5.196152422706632,vols->getIJ(0,0),1e-12);
833   DataArrayDouble *bary=mesh->getBarycenterAndOwner();
834   CPPUNIT_ASSERT_EQUAL(1,bary->getNumberOfTuples());
835   CPPUNIT_ASSERT_EQUAL(3,bary->getNumberOfComponents());
836   const double expected1[3]={0.,0.,1.};
837   for(int i=0;i<3;i++)
838     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],bary->getIJ(0,i),1e-12);
839   DataArrayInt *d1=DataArrayInt::New();
840   DataArrayInt *d2=DataArrayInt::New();
841   DataArrayInt *d3=DataArrayInt::New();
842   DataArrayInt *d4=DataArrayInt::New();
843   MEDCouplingUMesh *m2=mesh->buildDescendingConnectivity(d1,d2,d3,d4);
844   CPPUNIT_ASSERT_EQUAL(8,m2->getNumberOfCells());
845   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}};
846   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};
847   const int expected3[8]={6,6,4,4,4,4,4,4};
848   for(int i=0;i<8;i++)
849     {
850       CPPUNIT_ASSERT(m2->getTypeOfCell(i)==expected2[i]);
851       std::vector<int> v;
852       m2->getNodeIdsOfCell(i,v);
853       CPPUNIT_ASSERT((int)v.size()==expected3[i]);
854       CPPUNIT_ASSERT(std::equal(expected4[i],expected4[i]+expected3[i],v.begin()));
855     }
856   d1->decrRef();
857   d2->decrRef();
858   d3->decrRef();
859   d4->decrRef();
860   m2->decrRef();
861   //
862   mesh->convertAllToPoly();
863   CPPUNIT_ASSERT(INTERP_KERNEL::NORM_POLYHED==mesh->getTypeOfCell(0));
864   mesh->unPolyze();
865   CPPUNIT_ASSERT(INTERP_KERNEL::NORM_HEXGP12==mesh->getTypeOfCell(0));
866   CPPUNIT_ASSERT_EQUAL(13,mesh->getMeshLength());
867   //
868   vols->decrRef();
869   bary->decrRef();
870   mesh->decrRef();
871 }
872
873 void MEDCouplingBasicsTest4::testDADCheckIsMonotonic()
874 {
875   DataArrayDouble *da=DataArrayDouble::New();
876   const double vals[4]={-1.,1.01,2.03,6.};
877   da->alloc(2,2);
878   std::copy(vals,vals+4,da->getPointer());
879   CPPUNIT_ASSERT_THROW(da->isMonotonic(true, 1e-12),INTERP_KERNEL::Exception);
880   da->rearrange(1);
881   CPPUNIT_ASSERT(da->isMonotonic(true, 1e-12));
882   da->checkMonotonic(true, 1e-12);
883   da->setIJ(2,0,6.1);
884   CPPUNIT_ASSERT(!da->isMonotonic(true, 1e-12));
885   CPPUNIT_ASSERT_THROW(da->checkMonotonic(true, 1e-12),INTERP_KERNEL::Exception);
886   CPPUNIT_ASSERT_THROW(da->checkMonotonic(false, 1e-12),INTERP_KERNEL::Exception);
887   da->setIJ(2,0,5.99);
888   CPPUNIT_ASSERT(da->isMonotonic(true, 1e-12));
889   CPPUNIT_ASSERT(!da->isMonotonic(true, 1e-1));
890   da->decrRef();
891 }
892
893 void MEDCouplingBasicsTest4::testCheckCoherencyDeeper1()
894 {
895   MEDCouplingUMesh *m=build3DSourceMesh_1();
896   m->checkCoherency();
897   m->checkCoherency1();
898   m->getNodalConnectivity()->setIJ(8,0,-1);
899   m->checkCoherency();
900   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
901   m->getNodalConnectivity()->setIJ(8,0,-6);
902   m->checkCoherency();
903   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
904   m->getNodalConnectivity()->setIJ(8,0,9);//9>=NbOfNodes
905   m->checkCoherency();
906   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
907   m->getNodalConnectivity()->setIJ(8,0,8);//OK
908   m->checkCoherency();
909   m->checkCoherency1();
910   const int elts[2]={1,5};
911   std::vector<int> eltsV(elts,elts+2);
912   m->convertToPolyTypes(&eltsV[0],&eltsV[0]+eltsV.size());
913   m->checkCoherency();
914   m->checkCoherency1();
915   m->getNodalConnectivity()->setIJ(2,0,9);//9>=NbOfNodes
916   m->checkCoherency();
917   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
918   m->getNodalConnectivity()->setIJ(2,0,-3);
919   m->checkCoherency();
920   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
921   m->getNodalConnectivity()->setIJ(2,0,-1);
922   m->checkCoherency();
923   CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);//Throw because cell#0 is not a polyhedron
924   m->getNodalConnectivity()->setIJ(2,0,4);
925   m->checkCoherency();
926   m->checkCoherency1();
927   m->getNodalConnectivity()->setIJ(7,0,-1);
928   m->checkCoherency();
929   m->checkCoherency1();//OK because we are in polyhedron connec
930   m->getNodalConnectivity()->setIJ(36,0,14);
931   m->checkCoherency();
932   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.
933   m->decrRef();
934 }
935
936 void MEDCouplingBasicsTest4::testUnPolyze2()
937 {
938   MEDCouplingUMesh *m=MEDCouplingUMesh::New("jjj",3);
939   DataArrayDouble *coo=DataArrayDouble::New();
940   coo->alloc(4,3);
941   coo->rearrange(1);
942   coo->iota(0);
943   coo->rearrange(3);
944   m->setCoords(coo);
945   coo->decrRef();
946   m->allocateCells(2);
947   const int conn[4]={0,1,2,3};
948   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
949   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
950   m->finishInsertingCells();
951   std::vector<const MEDCouplingUMesh *> ms(4,m);
952   MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms);
953   std::vector<int> temp(1,2);
954   m2->convertToPolyTypes(&temp[0],&temp[0]+temp.size());
955   m2->unPolyze();
956   CPPUNIT_ASSERT(INTERP_KERNEL::NORM_TETRA4==m2->getTypeOfCell(2));
957   CPPUNIT_ASSERT_EQUAL(40,m2->getMeshLength());
958   std::vector<int> temp2;
959   m2->getNodeIdsOfCell(2,temp2);
960   CPPUNIT_ASSERT(4==(int)temp2.size());
961   CPPUNIT_ASSERT(std::equal(conn,conn+4,temp2.begin()));
962   m2->checkCoherency1();
963   MEDCouplingMesh *m3=m2->deepCpy();
964   m2->unPolyze();
965   CPPUNIT_ASSERT(m3->isEqual(m2,1e-12));
966   m3->decrRef();
967   m->decrRef();
968   m2->decrRef();
969 }
970
971 void MEDCouplingBasicsTest4::testDACpyFrom1()
972 {
973   DataArrayDouble *d=DataArrayDouble::New();
974   d->alloc(12,1);
975   d->iota(14.);
976   d->rearrange(3);
977   d->setName("Toto");
978   d->setInfoOnComponent(0,"X [m]");
979   d->setInfoOnComponent(1,"Y [m]");
980   d->setInfoOnComponent(2,"Z [m]");
981   //
982   DataArrayDouble *d1=DataArrayDouble::New();
983   CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12));
984   d1->cpyFrom(*d);
985   CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
986   d1->cpyFrom(*d);
987   CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
988   d1->rearrange(2);
989   CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12));
990   d1->cpyFrom(*d);
991   CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
992   //
993   DataArrayInt *d2=d->convertToIntArr();
994   DataArrayInt *d4=DataArrayInt::New();
995   CPPUNIT_ASSERT(!d2->isEqual(*d4));
996   d4->cpyFrom(*d2);
997   CPPUNIT_ASSERT(d2->isEqual(*d4));
998   d4->cpyFrom(*d2);
999   CPPUNIT_ASSERT(d2->isEqual(*d4));
1000   d4->rearrange(2);
1001   CPPUNIT_ASSERT(!d2->isEqual(*d4));
1002   d4->cpyFrom(*d2);
1003   CPPUNIT_ASSERT(d2->isEqual(*d4));
1004   //
1005   d->decrRef();
1006   d1->decrRef();
1007   d2->decrRef();
1008   d4->decrRef();
1009 }
1010
1011 void MEDCouplingBasicsTest4::testDAITransformWithIndArr1()
1012 {
1013   const int tab1[4]={17,18,22,19};
1014   const int tab2[12]={0,1,1,3,3,0,1,3,2,2,3,0};
1015   const int expected[12]={17,18,18,19,19,17,18,19,22,22,19,17};
1016   DataArrayInt *d=DataArrayInt::New();
1017   d->alloc(4,1);
1018   std::copy(tab1,tab1+4,d->getPointer());
1019   DataArrayInt *d1=DataArrayInt::New();
1020   d1->alloc(12,1);
1021   std::copy(tab2,tab2+12,d1->getPointer());
1022   //
1023   d1->transformWithIndArr(d->getConstPointer(),d->getConstPointer()+d->getNbOfElems());
1024   CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples());
1025   CPPUNIT_ASSERT_EQUAL(1,d1->getNumberOfComponents());
1026   for(int i=0;i<12;i++)
1027     CPPUNIT_ASSERT_EQUAL(expected[i],d1->getIJ(i,0));
1028   //
1029   d->decrRef();
1030   d1->decrRef();
1031 }
1032
1033 void MEDCouplingBasicsTest4::testDAIBuildPermArrPerLevel1()
1034 {
1035   const int arr[12]={2,0,1,1,0,1,2,0,1,1,0,0};
1036   const int expected1[12]={10,0,5,6,1,7,11,2,8,9,3,4};
1037   DataArrayInt *da=DataArrayInt::New();
1038   da->alloc(12,1);
1039   std::copy(arr,arr+12,da->getPointer());
1040   DataArrayInt *da2=da->buildPermArrPerLevel();
1041   CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples());
1042   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
1043   for(int i=0;i<12;i++)
1044     CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0));
1045   da->decrRef();
1046   da2->decrRef();
1047 }
1048
1049 void MEDCouplingBasicsTest4::testDAIOperations1()
1050 {
1051   const int arr1[12]={-1,-2,4,7,3,2,6,6,4,3,0,1};
1052   DataArrayInt *da=DataArrayInt::New();
1053   da->alloc(4,3);
1054   std::copy(arr1,arr1+12,da->getPointer());
1055   DataArrayInt *da1=DataArrayInt::New();
1056   da1->alloc(12,1);
1057   da1->iota(2);
1058   CPPUNIT_ASSERT_THROW(DataArrayInt::Add(da,da1),INTERP_KERNEL::Exception);//not same number of tuples/Components
1059   da1->rearrange(3);
1060   DataArrayInt *da2=DataArrayInt::Add(da,da1);
1061   CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
1062   CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
1063   const int expected1[12]={1,1,8,12,9,9,14,15,14,14,12,14};
1064   for(int i=0;i<12;i++)
1065     CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i));
1066   da2->decrRef();
1067   da1->substractEqual(da);
1068   const int expected2[12]={3,5,0,-2,3,5,2,3,6,8,12,12};
1069   for(int i=0;i<12;i++)
1070     CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i));
1071   da1->rearrange(1); da1->iota(2); da1->rearrange(3);
1072   da1->addEqual(da);
1073   for(int i=0;i<12;i++)
1074     CPPUNIT_ASSERT_EQUAL(expected1[i],da1->getIJ(0,i));
1075   da1->rearrange(1); da1->iota(2); da1->rearrange(3);
1076   da2=DataArrayInt::Multiply(da,da1);
1077   CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
1078   CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
1079   const int expected3[12]={-2,-6,16,35,18,14,48,54,40,33,0,13};
1080   for(int i=0;i<12;i++)
1081     CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i));
1082   da2->decrRef();
1083   da->divideEqual(da1);
1084   CPPUNIT_ASSERT_EQUAL(4,da->getNumberOfTuples());
1085   CPPUNIT_ASSERT_EQUAL(3,da->getNumberOfComponents());
1086   const int expected4[12]={0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
1087   for(int i=0;i<12;i++)
1088     CPPUNIT_ASSERT_EQUAL(expected4[i],da->getIJ(0,i));
1089   std::copy(arr1,arr1+12,da->getPointer());
1090   da1->multiplyEqual(da);
1091   CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
1092   CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
1093   for(int i=0;i<12;i++)
1094     CPPUNIT_ASSERT_EQUAL(expected3[i],da1->getIJ(0,i));
1095   da1->rearrange(1); da1->iota(2); da1->rearrange(3);
1096   da2=DataArrayInt::Divide(da,da1);
1097   CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
1098   CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
1099   for(int i=0;i<12;i++)
1100     CPPUNIT_ASSERT_EQUAL(expected4[i],da2->getIJ(0,i));
1101   da2->decrRef();
1102   da1->applyInv(321);
1103   CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
1104   CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
1105   const int expected5[12]={160,107,80,64,53,45,40,35,32,29,26,24};
1106   for(int i=0;i<12;i++)
1107     CPPUNIT_ASSERT_EQUAL(expected5[i],da1->getIJ(0,i));
1108   da1->applyDivideBy(2);
1109   CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
1110   CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
1111   const int expected6[12]={80,53,40,32,26,22,20,17,16,14,13,12};
1112   for(int i=0;i<12;i++)
1113     CPPUNIT_ASSERT_EQUAL(expected6[i],da1->getIJ(0,i));
1114   const int expected7[12]={3,4,5,4,5,1,6,3,2,0,6,5};
1115   da1->applyModulus(7);
1116   for(int i=0;i<12;i++)
1117     CPPUNIT_ASSERT_EQUAL(expected7[i],da1->getIJ(0,i));
1118   da1->applyLin(1,1);
1119   const int expected8[12]={3,3,3,3,3,1,3,3,0,0,3,3};
1120   da1->applyRModulus(3);
1121   for(int i=0;i<12;i++)
1122     CPPUNIT_ASSERT_EQUAL(expected8[i],da1->getIJ(0,i));
1123   //
1124   da1->decrRef();
1125   da->decrRef();
1126 }
1127
1128 void MEDCouplingBasicsTest4::testEmulateMEDMEMBDC1()
1129 {
1130   MEDCouplingUMesh *m1=0;
1131   MEDCouplingUMesh *m=buildPointe_1(m1);
1132   DataArrayInt *da1=DataArrayInt::New();
1133   DataArrayInt *da2=DataArrayInt::New();
1134   DataArrayInt *da3=0;
1135   DataArrayInt *da4=0;
1136   DataArrayInt *da5=0;
1137   DataArrayInt *da0=0;
1138   MEDCouplingUMesh *m2=m->emulateMEDMEMBDC(m1,da1,da2,da3,da4,da5,da0);
1139   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};
1140   const int expected1[6]={1,32,29,23,41,36};
1141   CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples());
1142   CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents());
1143   for(int i=0;i<47;i++)
1144     CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i));
1145   CPPUNIT_ASSERT_EQUAL(6,da5->getNumberOfTuples());
1146   CPPUNIT_ASSERT_EQUAL(1,da5->getNumberOfComponents());
1147   for(int i=0;i<6;i++)
1148     CPPUNIT_ASSERT_EQUAL(expected1[i],da5->getIJ(0,i));
1149   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};
1150   CPPUNIT_ASSERT_EQUAL(70,da1->getNumberOfTuples());
1151   CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
1152   for(int i=0;i<70;i++)
1153     CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i));
1154   const int expected3[17]={0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70};
1155   CPPUNIT_ASSERT_EQUAL(17,da2->getNumberOfTuples());
1156   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
1157   for(int i=0;i<17;i++)
1158     CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i));
1159   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};
1160   //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};
1161   CPPUNIT_ASSERT_EQUAL(48,da4->getNumberOfTuples());
1162   CPPUNIT_ASSERT_EQUAL(1,da4->getNumberOfComponents());
1163   for(int i=0;i<48;i++)
1164     CPPUNIT_ASSERT_EQUAL(expected4[i],da4->getIJ(0,i));
1165   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};
1166   CPPUNIT_ASSERT_EQUAL(70,da3->getNumberOfTuples());
1167   CPPUNIT_ASSERT_EQUAL(1,da3->getNumberOfComponents());
1168   for(int i=0;i<70;i++)
1169     CPPUNIT_ASSERT_EQUAL(expected5[i],da3->getIJ(0,i));
1170   //
1171   da0->decrRef();
1172   da1->decrRef();
1173   da2->decrRef();
1174   da3->decrRef();
1175   da4->decrRef();
1176   da5->decrRef();
1177   //
1178   m2->decrRef();
1179   m1->decrRef();
1180   m->decrRef();
1181 }
1182
1183 void MEDCouplingBasicsTest4::testGetLevArrPerCellTypes1()
1184 {
1185   MEDCouplingUMesh *m1=0;
1186   MEDCouplingUMesh *m=buildPointe_1(m1);
1187   m1->decrRef();
1188   DataArrayInt *d0=DataArrayInt::New();
1189   DataArrayInt *d1=DataArrayInt::New();
1190   DataArrayInt *d2=DataArrayInt::New();
1191   DataArrayInt *d3=DataArrayInt::New();
1192   m1=m->buildDescendingConnectivity(d0,d1,d2,d3);
1193   d0->decrRef(); d1->decrRef(); d2->decrRef(); d3->decrRef();
1194   INTERP_KERNEL::NormalizedCellType order[2]={INTERP_KERNEL::NORM_TRI3,INTERP_KERNEL::NORM_QUAD4};
1195   DataArrayInt *da1=0;
1196   DataArrayInt *da0=m1->getLevArrPerCellTypes(order,order+2,da1);
1197   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};
1198   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};
1199   CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples());
1200   CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents());
1201   for(int i=0;i<47;i++)
1202     CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i));
1203   CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples());
1204   CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
1205   CPPUNIT_ASSERT_EQUAL(36,da1->getIJ(0,0));//36 TRI3
1206   CPPUNIT_ASSERT_EQUAL(11,da1->getIJ(1,0));//11 QUAD4
1207   //
1208   DataArrayInt *da2=da0->buildPermArrPerLevel();
1209   //
1210   CPPUNIT_ASSERT_EQUAL(47,da2->getNumberOfTuples());
1211   CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
1212   for(int i=0;i<47;i++)
1213     CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i));
1214   da2->decrRef();
1215   da0->decrRef();
1216   da1->decrRef();
1217   //
1218   m->decrRef();
1219   m1->decrRef();
1220 }
1221
1222 void MEDCouplingBasicsTest4::testSortCellsInMEDFileFrmt1()
1223 {
1224   MEDCouplingUMesh *m1=0;
1225   MEDCouplingUMesh *m=buildPointe_1(m1);
1226   MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCpy();
1227   m->setCoords(0);
1228   const int vals[16]={0,1,2,14,3,12,4,5,15,6,7,8,9,10,11,13};
1229   DataArrayInt *da=DataArrayInt::New();
1230   da->alloc(16,1);
1231   std::copy(vals,vals+16,da->getPointer());
1232   DataArrayInt *daa=da->invertArrayN2O2O2N(16);
1233   m->renumberCells(daa->getConstPointer(),false);
1234   daa->decrRef();
1235   DataArrayInt *da2=m->sortCellsInMEDFileFrmt();
1236   CPPUNIT_ASSERT(m2->isEqual(m2,1e-12));
1237   CPPUNIT_ASSERT(da->isEqual(*da2));
1238   m2->decrRef();
1239   da2->decrRef();
1240   da->decrRef();
1241   m1->decrRef();
1242   m->decrRef();
1243 }
1244
1245 void MEDCouplingBasicsTest4::testBuildPartAndReduceNodes1()
1246 {
1247   MEDCouplingMesh *m=build2DTargetMesh_1();
1248   const int arr[2]={1,0};
1249   DataArrayInt *da;
1250   MEDCouplingMesh *m2=m->buildPartAndReduceNodes(arr,arr+2,da);
1251   CPPUNIT_ASSERT_EQUAL(5,m2->getNumberOfNodes());
1252   CPPUNIT_ASSERT_EQUAL(2,m2->getNumberOfCells());
1253   MEDCouplingFieldDouble *f=m2->getMeasureField(true);
1254   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,f->getArray()->getIJ(0,0),1e-12);
1255   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,f->getArray()->getIJ(1,0),1e-12);
1256   f->decrRef();
1257   da->decrRef();
1258   m2->decrRef();
1259   m->decrRef();
1260 }
1261
1262 void MEDCouplingBasicsTest4::testDAITransformWithIndArrR1()
1263 {
1264   const int tab1[6]={2,4,5,3,6,7};
1265   const int tab2[12]={-1,-1,0,1,2,3,4,5,-1,-1,-1,-1};
1266   const int expected[6]={0,3,1,2,4,5};
1267   DataArrayInt *d=DataArrayInt::New();
1268   d->alloc(6,1);
1269   std::copy(tab1,tab1+6,d->getPointer());
1270   DataArrayInt *d1=DataArrayInt::New();
1271   d1->alloc(12,1);
1272   std::copy(tab2,tab2+12,d1->getPointer());
1273   //
1274   DataArrayInt *d3=d->transformWithIndArrR(d1->getConstPointer(),d1->getConstPointer()+d1->getNbOfElems());
1275   CPPUNIT_ASSERT_EQUAL(6,d3->getNumberOfTuples());
1276   CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents());
1277   for(int i=0;i<6;i++)
1278     CPPUNIT_ASSERT_EQUAL(expected[i],d3->getIJ(i,0));
1279   d3->decrRef();
1280   //
1281   d->decrRef();
1282   d1->decrRef();
1283 }
1284
1285 void MEDCouplingBasicsTest4::testDAISplitByValueRange1()
1286 {
1287   const int val1[9]={6,5,0,3,2,7,8,1,4};
1288   const int val2[3]={0,4,9};
1289   DataArrayInt *d=DataArrayInt::New();
1290   d->alloc(9,1);
1291   std::copy(val1,val1+9,d->getPointer());
1292   DataArrayInt *ee=0,*f=0,*g=0;
1293   d->splitByValueRange(val2,val2+3,ee,f,g);
1294   CPPUNIT_ASSERT_EQUAL(9,ee->getNumberOfTuples());
1295   CPPUNIT_ASSERT_EQUAL(1,ee->getNumberOfComponents());
1296   CPPUNIT_ASSERT_EQUAL(9,f->getNumberOfTuples());
1297   CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
1298   CPPUNIT_ASSERT_EQUAL(2,g->getNumberOfTuples());
1299   CPPUNIT_ASSERT_EQUAL(1,g->getNumberOfComponents());
1300   //
1301   const int expected1[9]={1,1,0,0,0,1,1,0,1};
1302   const int expected2[9]={2,1,0,3,2,3,4,1,0};
1303   for(int i=0;i<9;i++)
1304     {
1305       CPPUNIT_ASSERT_EQUAL(expected1[i],ee->getIJ(i,0));
1306       CPPUNIT_ASSERT_EQUAL(expected2[i],f->getIJ(i,0));
1307     }
1308   CPPUNIT_ASSERT_EQUAL(0,g->getIJ(0,0));
1309   CPPUNIT_ASSERT_EQUAL(1,g->getIJ(1,0));
1310   //
1311   ee->decrRef();
1312   f->decrRef();
1313   g->decrRef();
1314   //
1315   d->setIJ(6,0,9);
1316   CPPUNIT_ASSERT_THROW(d->splitByValueRange(val2,val2+3,ee,f,g),INTERP_KERNEL::Exception);
1317   //
1318   d->decrRef();
1319 }
1320
1321 void MEDCouplingBasicsTest4::testUMeshSplitProfilePerType1()
1322 {
1323   const int val0[5]={2,0,1,3,4};
1324   MEDCouplingUMesh *m=build2DTargetMesh_1();
1325   m->renumberCells(val0,false);
1326   std::vector<int> code;
1327   std::vector<DataArrayInt *> idsInPflPerType;
1328   std::vector<DataArrayInt *> pfls;
1329   //
1330   const int val1[3]={0,2,3};
1331   DataArrayInt *d=DataArrayInt::New();
1332   d->alloc(3,1);
1333   d->setName("sup");
1334   std::copy(val1,val1+3,d->getPointer());
1335   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
1336   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
1337   CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
1338   const int expected1[6]={3,1,0, 4,2,1};
1339   for(int i=0;i<6;i++)
1340     CPPUNIT_ASSERT_EQUAL(expected1[i],code[i]);
1341   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples());
1342   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
1343   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getNumberOfTuples());
1344   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0));
1345   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0));
1346   idsInPflPerType[0]->decrRef();
1347   idsInPflPerType[1]->decrRef();
1348   CPPUNIT_ASSERT_EQUAL(2,(int)pfls.size());
1349   CPPUNIT_ASSERT(std::string("sup")==pfls[0]->getName());
1350   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples());
1351   CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0));
1352   CPPUNIT_ASSERT(std::string("sup")==pfls[1]->getName());
1353   CPPUNIT_ASSERT_EQUAL(2,pfls[1]->getNumberOfTuples());
1354   CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0));
1355   CPPUNIT_ASSERT_EQUAL(1,pfls[1]->getIJ(1,0));
1356   pfls[0]->decrRef();
1357   pfls[1]->decrRef();
1358   d->decrRef();
1359   idsInPflPerType.clear();
1360   pfls.clear();
1361   code.clear();
1362   //
1363   const int val2[4]={0,2,3,4};// all quad4 are selected here ! So no profile for Quads
1364   d=DataArrayInt::New();
1365   d->alloc(4,1);
1366   std::copy(val2,val2+4,d->getPointer());
1367   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
1368   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
1369   CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
1370   const int expected2[6]={3,1,0, 4,3,-1};
1371   for(int i=0;i<6;i++)
1372     CPPUNIT_ASSERT_EQUAL(expected2[i],code[i]);
1373   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples());
1374   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
1375   CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getNumberOfTuples());
1376   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0));
1377   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0));
1378   CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getIJ(2,0));
1379   idsInPflPerType[0]->decrRef();
1380   idsInPflPerType[1]->decrRef();
1381   CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size());
1382   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples());
1383   CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0));
1384   pfls[0]->decrRef();
1385   d->decrRef();
1386   idsInPflPerType.clear();
1387   pfls.clear();
1388   code.clear();
1389   //
1390   const int val3[3]={1,0,2};// all tri3 are selected here but not in the same order ! Profile requested for Tri3
1391   d=DataArrayInt::New();
1392   d->alloc(3,1);
1393   std::copy(val3,val3+3,d->getPointer());
1394   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
1395   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
1396   CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
1397   const int expected3[6]={3,2,0, 4,1,1};
1398   for(int i=0;i<6;i++)
1399     CPPUNIT_ASSERT_EQUAL(expected3[i],code[i]);
1400   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples());
1401   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
1402   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0));
1403   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getNumberOfTuples());
1404   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(0,0));
1405   idsInPflPerType[0]->decrRef();
1406   idsInPflPerType[1]->decrRef();
1407   CPPUNIT_ASSERT_EQUAL(2,(int)pfls.size());
1408   CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples());
1409   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0));
1410   CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(1,0));
1411   CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0));
1412   pfls[0]->decrRef();
1413   pfls[1]->decrRef();
1414   d->decrRef();
1415   idsInPflPerType.clear();
1416   pfls.clear();
1417   code.clear();
1418   //
1419   const int val4[2]={3,4};// all tri3 are selected here but not in the same order ! Profile requested for Tri3
1420   d=DataArrayInt::New();
1421   d->alloc(2,1);
1422   std::copy(val4,val4+2,d->getPointer());
1423   m->splitProfilePerType(d,code,idsInPflPerType,pfls);
1424   CPPUNIT_ASSERT_EQUAL(3,(int)code.size());
1425   CPPUNIT_ASSERT_EQUAL(1,(int)idsInPflPerType.size());
1426   const int expected4[3]={4,2,0};
1427   for(int i=0;i<3;i++)
1428     CPPUNIT_ASSERT_EQUAL(expected4[i],code[i]);
1429   CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples());
1430   CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
1431   CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0));
1432   idsInPflPerType[0]->decrRef();
1433   CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size());
1434   CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples());
1435   CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0));
1436   CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getIJ(1,0));
1437   pfls[0]->decrRef();
1438   d->decrRef();
1439   idsInPflPerType.clear();
1440   pfls.clear();
1441   code.clear();
1442   //
1443   m->decrRef();
1444 }
1445
1446 void MEDCouplingBasicsTest4::testDAIBuildExplicitArrByRanges1()
1447 {
1448   DataArrayInt *d=DataArrayInt::New();
1449   d->alloc(3,1);
1450   const int vals1[3]={0,2,3};
1451   std::copy(vals1,vals1+3,d->getPointer());
1452   DataArrayInt *e=DataArrayInt::New();
1453   e->alloc(6,1);
1454   const int vals2[6]={0,3,6,10,14,20};
1455   std::copy(vals2,vals2+6,e->getPointer());
1456   //
1457   DataArrayInt *f=d->buildExplicitArrByRanges(e);
1458   CPPUNIT_ASSERT_EQUAL(11,f->getNumberOfTuples());
1459   CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
1460   const int expected1[11]={0,1,2,6,7,8,9,10,11,12,13};
1461   for(int i=0;i<11;i++)
1462     CPPUNIT_ASSERT_EQUAL(expected1[i],f->getIJ(i,0));
1463   //
1464   f->decrRef();
1465   e->decrRef();
1466   d->decrRef();
1467 }
1468
1469 void MEDCouplingBasicsTest4::testDAIComputeOffsets2()
1470 {
1471   DataArrayInt *d=DataArrayInt::New();
1472   const int vals1[6]={3,5,1,2,0,8};
1473   const int expected1[7]={0,3,8,9,11,11,19};
1474   d->alloc(6,1);
1475   std::copy(vals1,vals1+6,d->getPointer());
1476   d->computeOffsets2();
1477   CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples());
1478   CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
1479   for(int i=0;i<7;i++)
1480     CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
1481   d->decrRef();
1482 }
1483
1484 void MEDCouplingBasicsTest4::testMergeField3()
1485 {
1486   MEDCouplingUMesh *m=build2DTargetMesh_1();
1487   m->getCoords()->setInfoOnComponent(0,"x [m]");
1488   m->getCoords()->setInfoOnComponent(1,"z [km]");
1489   m->setName("m");
1490   m->setDescription("desc");
1491   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
1492   f1->setName("f1");
1493   f1->setMesh(m);
1494   DataArrayDouble *arr=DataArrayDouble::New();
1495   arr->alloc(5,2);
1496   arr->setInfoOnComponent(0,"X [m]");
1497   arr->setInfoOnComponent(1,"YY [mm]");
1498   arr->fillWithValue(2.);
1499   f1->setArray(arr);
1500   arr->decrRef();
1501   m->decrRef();
1502   //
1503   std::vector<const MEDCouplingFieldDouble *> tmp(1);
1504   tmp[0]=f1;
1505   MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::MergeFields(tmp);
1506   CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
1507   //
1508   f1->decrRef();
1509   f2->decrRef();
1510 }
1511
1512 void MEDCouplingBasicsTest4::testGetDistributionOfTypes1()
1513 {
1514   MEDCouplingUMesh *m=build2DTargetMesh_1();
1515   const int tab1[5]={2,0,1,3,4};
1516   CPPUNIT_ASSERT_THROW(m->getDistributionOfTypes(),INTERP_KERNEL::Exception);
1517   m->renumberCells(tab1,false);
1518   std::vector<int> code=m->getDistributionOfTypes();
1519   CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
1520   CPPUNIT_ASSERT_EQUAL(3,code[0]);
1521   CPPUNIT_ASSERT_EQUAL(2,code[1]);
1522   CPPUNIT_ASSERT_EQUAL(0,code[2]);
1523   CPPUNIT_ASSERT_EQUAL(4,code[3]);
1524   CPPUNIT_ASSERT_EQUAL(3,code[4]);
1525   CPPUNIT_ASSERT_EQUAL(0,code[5]);
1526   m->decrRef();
1527 }
1528
1529 void MEDCouplingBasicsTest4::testNorm2_1()
1530 {
1531   MEDCouplingUMesh *m=build2DTargetMesh_1();
1532   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
1533   f->setMesh(m);
1534   m->decrRef();
1535   //
1536   DataArrayDouble *d=DataArrayDouble::New();
1537   const double tab[10]={1.2,1.3,2.2,2.3,3.2,3.3,4.2,4.3,5.2,5.3};
1538   d->alloc(5,2);
1539   std::copy(tab,tab+10,d->getPointer());
1540   f->setArray(d);
1541   d->decrRef();
1542   f->checkCoherency();
1543   //
1544   CPPUNIT_ASSERT_DOUBLES_EQUAL(11.209371079592289,f->norm2(),1e-14);
1545   //
1546   f->decrRef();
1547 }
1548
1549 void MEDCouplingBasicsTest4::testNormMax1()
1550 {
1551   MEDCouplingUMesh *m=build2DTargetMesh_1();
1552   MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
1553   f->setMesh(m);
1554   m->decrRef();
1555   //
1556   DataArrayDouble *d=DataArrayDouble::New();
1557   const double tab[10]={2.3,-1.2,6.3,-7.8,2.9,7.7,2.1,0.,3.6,-7.6};
1558   d->alloc(5,2);
1559   std::copy(tab,tab+10,d->getPointer());
1560   f->setArray(d);
1561   d->decrRef();
1562   f->checkCoherency();
1563   //
1564   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8,f->normMax(),1e-14);
1565   //
1566   f->decrRef();
1567 }
1568
1569 void MEDCouplingBasicsTest4::testFindAndCorrectBadOriented3DExtrudedCells1()
1570 {
1571   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};
1572   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};
1573   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};
1574   const int invalidCells[4]={2,3,6,7};
1575   MEDCouplingUMesh *m=MEDCouplingUMesh::New("Example",3);
1576   DataArrayDouble *coo=DataArrayDouble::New();
1577   coo->alloc(38,3);
1578   std::copy(coords,coords+114,coo->getPointer());
1579   m->setCoords(coo);
1580   coo->decrRef();
1581   m->allocateCells(8);
1582   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn);
1583   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+6);
1584   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+12);
1585   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+18);
1586   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+24);
1587   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+32);
1588   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+40);
1589   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+48);
1590   m->finishInsertingCells();
1591   //
1592   std::vector<int> v;
1593   m->findAndCorrectBadOriented3DExtrudedCells(v);
1594   CPPUNIT_ASSERT_EQUAL(4,(int)v.size());
1595   CPPUNIT_ASSERT(std::equal(v.begin(),v.end(),invalidCells));
1596   CPPUNIT_ASSERT(std::equal(connExp,connExp+64,m->getNodalConnectivity()->getConstPointer()));
1597   //
1598   m->decrRef();
1599 }
1600
1601 void MEDCouplingBasicsTest4::testConvertExtrudedPolyhedra1()
1602 {
1603   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};
1604   MEDCouplingUMesh *m=MEDCouplingUMesh::New("Example",3);
1605   DataArrayDouble *coo=DataArrayDouble::New();
1606   coo->alloc(73,3);
1607   coo->rearrange(1); coo->iota(0); coo->rearrange(3);
1608   m->setCoords(coo);
1609   coo->decrRef();
1610   m->allocateCells(9);
1611   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
1612   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+4);
1613   m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+12);
1614   m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,6,conn+16);
1615   m->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+22);
1616   m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,10,conn+28);
1617   m->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+38);
1618   m->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn+46);
1619   m->insertNextCell(INTERP_KERNEL::NORM_POLYHED,14,conn+58);
1620   m->finishInsertingCells();
1621   //
1622   m->convertExtrudedPolyhedra();
1623   DataArrayInt *da=m->getNodalConnectivity();
1624   DataArrayInt *dai=m->getNodalConnectivityIndex();
1625   CPPUNIT_ASSERT_EQUAL(10,dai->getNbOfElems());
1626   CPPUNIT_ASSERT_EQUAL(159,da->getNbOfElems());
1627   //
1628   const int expected1[159]={14, 1, 2, 3, 4,
1629                             18, 5, 6, 7, 8, 9, 10, 11, 12,
1630                             14, 13, 14, 15, 16,
1631                             31, 17, 18, 19, -1, 20, 22, 21, -1, 17, 18, 21, 20, -1, 18, 19, 22, 21, -1, 19, 17, 20,
1632   22,
1633                             16, 23, 24, 25, 26, 27, 28,
1634                             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,
1635   -1, 33, 29, 34, 38,
1636                             18, 39, 40, 41, 42, 43, 44, 45, 46,
1637                             22, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
1638                             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};
1639   const int expected2[10]={0,5,14,19,42,49,86,95,108,159};
1640   CPPUNIT_ASSERT(std::equal(expected1,expected1+159,da->getConstPointer()));
1641   CPPUNIT_ASSERT(std::equal(expected2,expected2+10,dai->getConstPointer()));
1642   m->checkCoherency2();
1643   //
1644   m->decrRef();
1645 }
1646
1647 void MEDCouplingBasicsTest4::testNonRegressionCopyTinyStrings()
1648 {
1649   MEDCouplingUMesh *m=build2DTargetMesh_1();
1650   MEDCouplingFieldDouble *f1=m->getMeasureField(true);
1651   f1->getArray()->setInfoOnComponent(0,"P [N/m^2]");
1652   DataArrayDouble *bary=m->getBarycenterAndOwner();
1653   MEDCouplingFieldDouble *f2=f1->buildNewTimeReprFromThis(ONE_TIME,false);
1654   f2->setArray(bary);
1655   CPPUNIT_ASSERT_THROW(f2->copyTinyAttrFrom(f1),INTERP_KERNEL::Exception);
1656   m->decrRef();
1657   f1->decrRef();
1658   bary->decrRef();
1659   f2->decrRef();
1660 }
1661
1662 void MEDCouplingBasicsTest4::testDaDSetPartOfValuesAdv1()
1663 {
1664   const double tab1[18]={3.,4.,5., 13.,14.,15., 23.,24.,25., 33.,34.,35., 43.,44.,45., 53.,54.,55.};
1665   const double tab2[9]={6.,7.,8., 16.,17.,18., 26.,27.,28.};
1666   const int tab3[6]={4,1, 2,2, 3,0};
1667   DataArrayDouble *a=DataArrayDouble::New();
1668   a->alloc(6,3);
1669   std::copy(tab1,tab1+18,a->getPointer());
1670   DataArrayDouble *b=DataArrayDouble::New();
1671   b->alloc(3,3);
1672   std::copy(tab2,tab2+9,b->getPointer());
1673   DataArrayInt *c=DataArrayInt::New();
1674   c->alloc(3,2);
1675   std::copy(tab3,tab3+6,c->getPointer());
1676   //
1677   a->setPartOfValuesAdv(b,c);
1678   const double expected1[18]={3.,4.,5., 13.,14.,15., 26.,27.,28., 6.,7.,8., 16.,17.,18., 53.,54.,55.};
1679   std::equal(expected1,expected1+18,a->getConstPointer());
1680   //
1681   a->decrRef();
1682   b->decrRef();
1683   c->decrRef();
1684 }
1685
1686 void MEDCouplingBasicsTest4::testUMeshBuildSetInstanceFromThis1()
1687 {
1688   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
1689   MEDCouplingUMesh *m2=m->buildSetInstanceFromThis(3);
1690   CPPUNIT_ASSERT_EQUAL(m->getNodalConnectivity(),m2->getNodalConnectivity());
1691   CPPUNIT_ASSERT_EQUAL(m->getNodalConnectivityIndex(),m2->getNodalConnectivityIndex());
1692   CPPUNIT_ASSERT_EQUAL(m->getCoords(),m2->getCoords());
1693   m2->decrRef();
1694   m->decrRef();
1695   //
1696   m=MEDCouplingUMesh::New("toto",2);
1697   m2=m->buildSetInstanceFromThis(3);
1698   CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfNodes());
1699   CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfCells());
1700   m->decrRef();
1701   m2->decrRef();
1702 }
1703
1704 void MEDCouplingBasicsTest4::testUMeshMergeMeshesCVW1()
1705 {
1706   MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
1707   MEDCouplingUMesh *m2=MEDCouplingUMesh::New("toto",2);
1708   MEDCouplingUMesh *m3=MEDCouplingUMesh::MergeUMeshes(m,m2);
1709   m3->setName(m->getName());
1710   CPPUNIT_ASSERT(m->isEqual(m3,1e-12));
1711   m3->decrRef();
1712   m->decrRef();
1713   m2->decrRef();
1714 }
1715
1716 void MEDCouplingBasicsTest4::testChangeUnderlyingMeshWithCMesh1()
1717 {
1718   MEDCouplingCMesh* mesh=MEDCouplingCMesh::New();
1719   DataArrayDouble* coordsX=DataArrayDouble::New();
1720   double arrX[4] = { -1., 1., 2., 4. };
1721   coordsX->useArray(arrX,false, CPP_DEALLOC,4,1);
1722   DataArrayDouble* coordsY=DataArrayDouble::New();
1723   double arrY[4] = { -2., 2., 4., 8. };
1724   coordsY->useArray(arrY,false, CPP_DEALLOC,4,1);
1725   DataArrayDouble* coordsZ=DataArrayDouble::New();
1726   double arrZ[4] = { -3., 3., 6., 12. };
1727   coordsZ->useArray(arrZ,false, CPP_DEALLOC,4,1);
1728   mesh->setCoords(coordsX,coordsY,coordsZ);
1729   coordsX->decrRef();
1730   coordsY->decrRef();
1731   coordsZ->decrRef();
1732   MEDCouplingMesh *mesh2=mesh->deepCpy();
1733   //
1734   static const int ids1[9]={0,1,2,10,11,12,20,21,22};
1735   for(const int *myId=ids1;myId!=ids1+9;myId++)
1736     {
1737       MEDCouplingFieldDouble *f=mesh->getMeasureField(true);
1738       f->changeUnderlyingMesh(mesh2,*myId,1e-12);
1739       f->decrRef();
1740     }
1741   mesh2->setName("uuuu");
1742   for(const int *myId=ids1+1;myId!=ids1+9;myId++)
1743     {
1744       MEDCouplingFieldDouble *f=mesh->getMeasureField(true);
1745       f->changeUnderlyingMesh(mesh2,*myId,1e-12);
1746       f->decrRef();
1747     }
1748   //
1749   mesh2->decrRef();
1750   mesh->decrRef();
1751 }
1752
1753 void MEDCouplingBasicsTest4::testDADFindCommonTuples1()
1754 {
1755   DataArrayDouble *da=DataArrayDouble::New();
1756   da->alloc(6,1);
1757   const double array1[6]={2.3,1.2,1.3,2.3,2.301,0.8};
1758   std::copy(array1,array1+6,da->getPointer());
1759   DataArrayInt *c=0,*cI=0;
1760   // nbOftuples=1
1761   da->findCommonTuples(1e-2,-1,c,cI);
1762   const int expected1[3]={0,3,4};
1763   const int expected2[2]={0,3};
1764   CPPUNIT_ASSERT_EQUAL(3,c->getNbOfElems());
1765   CPPUNIT_ASSERT_EQUAL(2,cI->getNbOfElems());
1766   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
1767   CPPUNIT_ASSERT(std::equal(expected2,expected2+2,cI->getConstPointer()));
1768   c->decrRef();
1769   cI->decrRef();
1770   //
1771   da->findCommonTuples(2e-1,-1,c,cI);
1772   const int expected3[5]={0,3,4,1,2};
1773   const int expected4[3]={0,3,5};
1774   CPPUNIT_ASSERT_EQUAL(5,c->getNbOfElems());
1775   CPPUNIT_ASSERT_EQUAL(3,cI->getNbOfElems());
1776   CPPUNIT_ASSERT(std::equal(expected3,expected3+5,c->getConstPointer()));
1777   CPPUNIT_ASSERT(std::equal(expected4,expected4+3,cI->getConstPointer()));
1778   c->decrRef();
1779   cI->decrRef();
1780   // nbOftuples=2
1781   da->alloc(6,2);
1782   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};
1783   std::copy(array2,array2+12,da->getPointer());
1784   da->findCommonTuples(1e-2,-1,c,cI);
1785   CPPUNIT_ASSERT_EQUAL(3,c->getNbOfElems());
1786   CPPUNIT_ASSERT_EQUAL(2,cI->getNbOfElems());
1787   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
1788   CPPUNIT_ASSERT(std::equal(expected2,expected2+2,cI->getConstPointer()));
1789   c->decrRef();
1790   cI->decrRef();
1791   //
1792   da->findCommonTuples(2e-1,-1,c,cI);
1793   CPPUNIT_ASSERT_EQUAL(5,c->getNbOfElems());
1794   CPPUNIT_ASSERT_EQUAL(3,cI->getNbOfElems());
1795   CPPUNIT_ASSERT(std::equal(expected3,expected3+5,c->getConstPointer()));
1796   CPPUNIT_ASSERT(std::equal(expected4,expected4+3,cI->getConstPointer()));
1797   c->decrRef();
1798   cI->decrRef();
1799   // nbOftuples=3
1800   da->alloc(6,3);
1801   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};
1802   std::copy(array3,array3+18,da->getPointer());
1803   da->findCommonTuples(1e-2,-1,c,cI);
1804   CPPUNIT_ASSERT_EQUAL(3,c->getNbOfElems());
1805   CPPUNIT_ASSERT_EQUAL(2,cI->getNbOfElems());
1806   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
1807   CPPUNIT_ASSERT(std::equal(expected2,expected2+2,cI->getConstPointer()));
1808   c->decrRef();
1809   cI->decrRef();
1810   //
1811   da->findCommonTuples(2e-1,-1,c,cI);
1812   CPPUNIT_ASSERT_EQUAL(5,c->getNbOfElems());
1813   CPPUNIT_ASSERT_EQUAL(3,cI->getNbOfElems());
1814   CPPUNIT_ASSERT(std::equal(expected3,expected3+5,c->getConstPointer()));
1815   CPPUNIT_ASSERT(std::equal(expected4,expected4+3,cI->getConstPointer()));
1816   c->decrRef();
1817   cI->decrRef();
1818   //
1819   const double array11[6]={2.3,1.2,1.3,2.4,2.5,0.8};
1820   da->alloc(6,1);
1821   std::copy(array11,array11+6,da->getPointer());
1822   // nbOftuples=1, no common groups
1823   da->findCommonTuples(1e-2,-1,c,cI);
1824   CPPUNIT_ASSERT_EQUAL(0,c->getNbOfElems());
1825   CPPUNIT_ASSERT_EQUAL(1,cI->getNbOfElems());
1826   CPPUNIT_ASSERT_EQUAL(0,cI->getIJ(0,0));
1827   
1828   da->alloc(6,4);  //bad NumberOfComponents
1829   CPPUNIT_ASSERT_THROW(da->findCommonTuples(1e-2,-1,c,cI),INTERP_KERNEL::Exception);
1830   
1831   c->decrRef();
1832   cI->decrRef();
1833   da->decrRef();
1834 }
1835
1836 void MEDCouplingBasicsTest4::testDABack1()
1837 {
1838   DataArrayDouble *da=DataArrayDouble::New();
1839   da->alloc(6,1);
1840   const double array1[6]={2.3,1.2,1.3,2.3,2.301,0.8};
1841   std::copy(array1,array1+6,da->getPointer());
1842   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.8,da->back(),1e-14);
1843   da->rearrange(2);
1844   CPPUNIT_ASSERT_THROW(da->back(),INTERP_KERNEL::Exception);
1845   da->alloc(0,1);
1846   CPPUNIT_ASSERT_THROW(da->back(),INTERP_KERNEL::Exception);
1847   da->decrRef();
1848   //
1849   DataArrayInt *da2=DataArrayInt::New();
1850   da2->alloc(4,1);
1851   const int array2[4]={4,7,8,2};
1852   std::copy(array2,array2+4,da2->getPointer());
1853   CPPUNIT_ASSERT_EQUAL(2,da2->back());
1854   da2->rearrange(2);
1855   CPPUNIT_ASSERT_THROW(da2->back(),INTERP_KERNEL::Exception);
1856   da2->alloc(0,1);
1857   CPPUNIT_ASSERT_THROW(da2->back(),INTERP_KERNEL::Exception);
1858   da2->decrRef();
1859 }
1860
1861 void MEDCouplingBasicsTest4::testDADGetDifferentValues1()
1862 {
1863   DataArrayDouble *da=DataArrayDouble::New();
1864   da->alloc(6,1);
1865   const double array1[6]={2.3,1.2,1.3,2.3,2.301,0.8};
1866   std::copy(array1,array1+6,da->getPointer());
1867   //
1868   const double expected1[4]={2.301,1.2,1.3,0.8};
1869   DataArrayDouble *dv=da->getDifferentValues(1e-2);
1870   CPPUNIT_ASSERT_EQUAL(4,dv->getNbOfElems());
1871   for(int i=0;i<4;i++)
1872     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],dv->getIJ(i,0),1e-14);
1873   dv->decrRef();
1874   //
1875   dv=da->getDifferentValues(2e-1);
1876   const double expected2[3]={2.301,1.3,0.8};
1877   CPPUNIT_ASSERT_EQUAL(3,dv->getNbOfElems());
1878   for(int i=0;i<3;i++)
1879     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],dv->getIJ(i,0),1e-14);
1880   dv->decrRef();
1881   da->decrRef();
1882 }
1883
1884 void MEDCouplingBasicsTest4::testDAIBuildOld2NewArrayFromSurjectiveFormat2()
1885 {
1886   const int arr[5]={0,3, 5,7,9};
1887   const int arrI[3]={0,2,5};
1888   DataArrayInt *a=DataArrayInt::New();
1889   a->alloc(5,1);
1890   std::copy(arr,arr+5,a->getPointer());
1891   DataArrayInt *b=DataArrayInt::New();
1892   b->alloc(3,1);
1893   std::copy(arrI,arrI+3,b->getPointer());
1894   int newNbTuple=-1;
1895   DataArrayInt *ret=DataArrayInt::BuildOld2NewArrayFromSurjectiveFormat2(10,a,b,newNbTuple);
1896   const int expected[10]={0,1,2,0,3,4,5,4,6,4};
1897   CPPUNIT_ASSERT_EQUAL(10,ret->getNbOfElems());
1898   CPPUNIT_ASSERT_EQUAL(7,newNbTuple);
1899   CPPUNIT_ASSERT_EQUAL(1,ret->getNumberOfComponents());
1900   CPPUNIT_ASSERT(std::equal(expected,expected+10,ret->getConstPointer()));
1901   ret->decrRef();
1902   b->decrRef();
1903   a->decrRef();
1904 }
1905
1906 void MEDCouplingBasicsTest4::testDADIReverse1()
1907 {
1908   const int arr[6]={0,3,5,7,9,2};
1909   DataArrayInt *a=DataArrayInt::New();
1910   a->alloc(6,1);
1911   std::copy(arr,arr+6,a->getPointer());
1912   CPPUNIT_ASSERT_EQUAL(2,a->back());
1913   a->reverse();
1914   for(int i=0;i<6;i++)
1915     CPPUNIT_ASSERT_EQUAL(arr[5-i],a->getIJ(i,0));
1916   a->alloc(5,1);
1917   std::copy(arr,arr+5,a->getPointer());
1918   a->reverse();
1919   for(int i=0;i<5;i++)
1920     CPPUNIT_ASSERT_EQUAL(arr[4-i],a->getIJ(i,0));
1921   a->decrRef();
1922   //
1923   const double arr2[6]={0.,3.,5.,7.,9.,2.};
1924    DataArrayDouble *b=DataArrayDouble::New();
1925    b->alloc(6,1);
1926    std::copy(arr2,arr2+6,b->getPointer());
1927    b->reverse();
1928    for(int i=0;i<6;i++)
1929      CPPUNIT_ASSERT_DOUBLES_EQUAL(arr2[5-i],b->getIJ(i,0),1e-14);
1930    b->alloc(5,1);
1931    std::copy(arr,arr+5,b->getPointer());
1932    CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,b->back(),1e-14);
1933    b->reverse();
1934    for(int i=0;i<5;i++)
1935      CPPUNIT_ASSERT_DOUBLES_EQUAL(arr2[4-i],b->getIJ(i,0),1e-14);
1936    b->decrRef();
1937 }
1938
1939 void MEDCouplingBasicsTest4::testGetNodeIdsInUse1()
1940 {
1941   MEDCouplingUMesh *m0=build2DTargetMesh_1();
1942   const int CellIds[2]={1,2};
1943   MEDCouplingUMesh *m1=static_cast<MEDCouplingUMesh *>(m0->buildPartOfMySelf(CellIds,CellIds+2,true));
1944   int newNbOfNodes=-1;
1945   DataArrayInt *arr=m1->getNodeIdsInUse(newNbOfNodes);
1946   const int expected[9]={-1,0,1,-1,2,3,-1,-1,-1};
1947   CPPUNIT_ASSERT_EQUAL(4,newNbOfNodes);
1948   CPPUNIT_ASSERT_EQUAL(9,arr->getNbOfElems());
1949   CPPUNIT_ASSERT(std::equal(expected,expected+9,arr->getConstPointer()));
1950   DataArrayInt *arr2=arr->invertArrayO2N2N2O(newNbOfNodes);
1951   CPPUNIT_ASSERT_EQUAL(4,arr2->getNbOfElems());
1952   const int expected2[4]={1,2,4,5};
1953   CPPUNIT_ASSERT(std::equal(expected2,expected2+4,arr2->getConstPointer()));
1954   arr2->decrRef();
1955   arr->decrRef();
1956   m1->decrRef();
1957   m0->decrRef();
1958 }
1959
1960 void MEDCouplingBasicsTest4::testBuildDescendingConnec2()
1961 {
1962   MEDCouplingUMesh *mesh=build2DTargetMesh_1();
1963   DataArrayInt *desc=DataArrayInt::New();
1964   DataArrayInt *descIndx=DataArrayInt::New();
1965   DataArrayInt *revDesc=DataArrayInt::New();
1966   DataArrayInt *revDescIndx=DataArrayInt::New();
1967   //
1968   MEDCouplingUMesh *mesh2=mesh->buildDescendingConnectivity2(desc,descIndx,revDesc,revDescIndx);
1969   mesh2->checkCoherency();
1970   CPPUNIT_ASSERT_EQUAL(1,mesh2->getMeshDimension());
1971   CPPUNIT_ASSERT_EQUAL(13,mesh2->getNumberOfCells());
1972   CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(14,revDescIndx->getNumberOfTuples());
1973   CPPUNIT_ASSERT_EQUAL(6,descIndx->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(6,descIndx->getNumberOfTuples());
1974   CPPUNIT_ASSERT_EQUAL(18,desc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,desc->getNumberOfTuples());
1975   CPPUNIT_ASSERT_EQUAL(18,revDesc->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(18,revDesc->getNumberOfTuples());
1976   const int expected1[18]={1,2,3,4,-3,5,6, 7,8,-5,9,10,-2,11, 12,13,-7,-10};
1977   CPPUNIT_ASSERT(std::equal(expected1,expected1+18,desc->getConstPointer()));
1978   const int expected2[6]={0,4,7,10,14,18};
1979   CPPUNIT_ASSERT(std::equal(expected2,expected2+6,descIndx->getConstPointer()));
1980   const int expected3[14]={0,1,3,5,6,8,9,11,12,13,15,16,17,18};
1981   CPPUNIT_ASSERT(std::equal(expected3,expected3+14,revDescIndx->getConstPointer()));
1982   const int expected4[18]={0, 0,3, 0,1, 0, 1,2, 1, 2,4, 2, 3, 3,4, 3, 4, 4};
1983   CPPUNIT_ASSERT(std::equal(expected4,expected4+18,revDesc->getConstPointer()));
1984   DataArrayInt *conn=mesh2->getNodalConnectivity();
1985   DataArrayInt *connIndex=mesh2->getNodalConnectivityIndex();
1986   const int expected5[14]={0,3,6,9,12,15,18,21,24,27,30,33,36,39};
1987   CPPUNIT_ASSERT(std::equal(expected5,expected5+14,connIndex->getConstPointer()));
1988   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};
1989   CPPUNIT_ASSERT(std::equal(expected6,expected6+39,conn->getConstPointer()));
1990   //
1991   desc->decrRef();
1992   descIndx->decrRef();
1993   revDesc->decrRef();
1994   revDescIndx->decrRef();
1995   mesh2->decrRef();
1996   mesh->decrRef();
1997 }
1998
1999 void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp1()
2000 {
2001   MEDCouplingCMesh *m1c=MEDCouplingCMesh::New();
2002   DataArrayDouble *coordX=DataArrayDouble::New();
2003   const double arrX[4]={-1., 1., 2., 4.};
2004   coordX->alloc(4,1);
2005   std::copy(arrX,arrX+4,coordX->getPointer());
2006   m1c->setCoordsAt(0,coordX);
2007   DataArrayDouble *coordY=DataArrayDouble::New();
2008   const double arrY[4]={-2., 2., 4., 8.};
2009   coordY->alloc(4,1);
2010   std::copy(arrY,arrY+4,coordY->getPointer());
2011   m1c->setCoordsAt(1,coordY);
2012   MEDCouplingUMesh *m1=m1c->buildUnstructured();
2013   const int subPart1[3]={3,4,5};
2014   MEDCouplingUMesh *m1bis=static_cast<MEDCouplingUMesh *>(m1->buildPartOfMySelf(subPart1,subPart1+3,false));
2015   MEDCouplingUMesh *m2tmp=static_cast<MEDCouplingUMesh *>(m1->deepCpy());
2016   const int subPart2[3]={0,1,2};
2017   MEDCouplingUMesh *m2=static_cast<MEDCouplingUMesh *>(m2tmp->buildPartOfMySelf(subPart2,subPart2+3,false));
2018   const double vec[2]={0.5,0.5};
2019   m2->translate(vec);
2020   // End of construction of input meshes m1bis and m2 -> start of specific part of the test
2021   DataArrayInt *d1=0,*d2=0;
2022   MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1bis,m2,1e-10,d1,d2);
2023   const int expected1[5]={0,1,1,2,2};
2024   const int expected2[5]={0,0,1,1,2};
2025   CPPUNIT_ASSERT_EQUAL(5,d1->getNumberOfTuples());
2026   CPPUNIT_ASSERT_EQUAL(5,d2->getNumberOfTuples());
2027   CPPUNIT_ASSERT_EQUAL(5,m3->getNumberOfCells());
2028   CPPUNIT_ASSERT_EQUAL(22,m3->getNumberOfNodes());
2029   CPPUNIT_ASSERT_EQUAL(2,m3->getSpaceDimension());
2030   CPPUNIT_ASSERT(std::equal(expected1,expected1+5,d1->getConstPointer()));
2031   CPPUNIT_ASSERT(std::equal(expected2,expected2+5,d2->getConstPointer()));
2032   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};
2033   const int expected4[6]={0,5,10,15,20,25};
2034   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};
2035   CPPUNIT_ASSERT_EQUAL(25,m3->getNodalConnectivity()->getNumberOfTuples());
2036   CPPUNIT_ASSERT_EQUAL(6,m3->getNodalConnectivityIndex()->getNumberOfTuples());
2037   CPPUNIT_ASSERT(std::equal(expected3,expected3+25,m3->getNodalConnectivity()->getConstPointer()));
2038   CPPUNIT_ASSERT(std::equal(expected4,expected4+6,m3->getNodalConnectivityIndex()->getConstPointer()));
2039   for(int i=0;i<44;i++)
2040     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m3->getCoords()->getIJ(0,i),1e-12);
2041   d1->decrRef();
2042   d2->decrRef();
2043   m3->decrRef();
2044   //
2045   m2->decrRef();
2046   m2tmp->decrRef();
2047   m1bis->decrRef();
2048   m1->decrRef();
2049   coordX->decrRef();
2050   coordY->decrRef();
2051   m1c->decrRef();
2052 }
2053
2054 void MEDCouplingBasicsTest4::testFindNodesOnLine1()
2055 {
2056   MEDCouplingUMesh *mesh=build2DTargetMesh_1();
2057   const double pt[2]={-0.3,-0.3};
2058   const double pt2[3]={0.,0.,0.};
2059   const double pt3[3]={-0.3,0.,0.};
2060   const double vec[2]={0.,1.};
2061   const double vec2[3]={1.,0.,0.};
2062   const double vec3[3]={0.,1.,1.};
2063   const int expected1[3]={0,3,6};
2064   std::vector<int> res;
2065   mesh->findNodesOnLine(pt,vec,1e-12,res);
2066   CPPUNIT_ASSERT_EQUAL(3,(int)res.size());
2067   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,res.begin()));
2068   res.clear();
2069   //
2070   mesh->changeSpaceDimension(3);
2071   mesh->rotate(pt2,vec2,M_PI/4.);
2072   mesh->findNodesOnLine(pt3,vec3,1e-12,res);
2073   CPPUNIT_ASSERT_EQUAL(3,(int)res.size());
2074   CPPUNIT_ASSERT(std::equal(expected1,expected1+3,res.begin()));
2075   //
2076   mesh->decrRef();
2077 }
2078
2079 void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp2()
2080 {
2081   MEDCouplingCMesh *m1c=MEDCouplingCMesh::New();
2082   DataArrayDouble *coordsX1=DataArrayDouble::New();
2083   const double arrX1[4]={ 0., 1., 1.5, 2. };
2084   coordsX1->alloc(4,1);
2085   std::copy(arrX1,arrX1+4,coordsX1->getPointer());
2086   m1c->setCoordsAt(0,coordsX1);
2087   DataArrayDouble *coordsY1=DataArrayDouble::New();
2088   const double arrY1[3]={ 0., 1.5, 3.};
2089   coordsY1->alloc(3,1);
2090   std::copy(arrY1,arrY1+3,coordsY1->getPointer());
2091   m1c->setCoordsAt(1,coordsY1);
2092   MEDCouplingUMesh *m1=m1c->buildUnstructured();
2093   //
2094   MEDCouplingCMesh *m2c=MEDCouplingCMesh::New();
2095   DataArrayDouble *coordsX2=DataArrayDouble::New();
2096   const double arrX2[3]={ 0., 1., 2. };
2097   coordsX2->alloc(3,1);
2098   std::copy(arrX2,arrX2+3,coordsX2->getPointer());
2099   m2c->setCoordsAt(0,coordsX2);
2100   DataArrayDouble *coordsY2=DataArrayDouble::New();
2101   coordsY2->alloc(3,1);
2102   const double arrY2[3]={ 0., 1., 3.};
2103   std::copy(arrY2,arrY2+3,coordsY2->getPointer());
2104   m2c->setCoordsAt(1,coordsY2);
2105   MEDCouplingUMesh *m2=m2c->buildUnstructured();
2106   //
2107   DataArrayInt *d1=0,*d2=0;
2108   MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2);
2109   const int expected1[9]={0,0,1,1,2,2,3,4,5};
2110   const int expected2[9]={0,2,1,3,1,3,2,3,3};
2111   CPPUNIT_ASSERT_EQUAL(9,d1->getNumberOfTuples());
2112   CPPUNIT_ASSERT_EQUAL(9,d2->getNumberOfTuples());
2113   CPPUNIT_ASSERT_EQUAL(9,m3->getNumberOfCells());
2114   CPPUNIT_ASSERT_EQUAL(22,m3->getNumberOfNodes());
2115   CPPUNIT_ASSERT_EQUAL(2,m3->getSpaceDimension());
2116   CPPUNIT_ASSERT(std::equal(expected1,expected1+9,d1->getConstPointer()));
2117   CPPUNIT_ASSERT(std::equal(expected2,expected2+9,d2->getConstPointer()));
2118   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};
2119   const int expected4[10]={0,5,10,15,20,25,30,35,40,45};
2120   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};
2121   CPPUNIT_ASSERT_EQUAL(45,m3->getNodalConnectivity()->getNumberOfTuples());
2122   CPPUNIT_ASSERT_EQUAL(10,m3->getNodalConnectivityIndex()->getNumberOfTuples());
2123   CPPUNIT_ASSERT(std::equal(expected3,expected3+45,m3->getNodalConnectivity()->getConstPointer()));
2124   CPPUNIT_ASSERT(std::equal(expected4,expected4+10,m3->getNodalConnectivityIndex()->getConstPointer()));
2125   for(int i=0;i<44;i++)
2126     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m3->getCoords()->getIJ(0,i),1e-12);
2127   d1->decrRef();
2128   d2->decrRef();
2129   m3->decrRef();
2130   //
2131   m1c->decrRef();
2132   coordsX1->decrRef();
2133   coordsY1->decrRef();
2134   m1->decrRef();
2135   m2c->decrRef();
2136   coordsX2->decrRef();
2137   coordsY2->decrRef();
2138   m2->decrRef();
2139 }
2140
2141 void MEDCouplingBasicsTest4::testBuildPartOfMySelfSafe1()
2142 {
2143   MEDCouplingUMesh *mesh=build2DTargetMesh_1();
2144   const int input1[4]={0,-1,4,2};
2145   const int input2[4]={0,4,5,4};
2146   CPPUNIT_ASSERT_THROW(mesh->buildPartOfMySelf(input1,input1+4,true),INTERP_KERNEL::Exception);
2147   CPPUNIT_ASSERT_THROW(mesh->buildPartOfMySelf(input2,input2+4,true),INTERP_KERNEL::Exception);
2148   mesh->decrRef();
2149 }
2150
2151 void MEDCouplingBasicsTest4::testIntersect2DMeshesTmp3()
2152 {
2153   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};
2154   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};
2155   MEDCouplingUMesh *m1=MEDCouplingUMesh::New();
2156   m1->setMeshDimension(2);
2157   m1->allocateCells(8);
2158   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn);
2159   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+6);
2160   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+14);
2161   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+20);
2162   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+28);
2163   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+34);
2164   m1->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,m1Conn+42);
2165   m1->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,m1Conn+48);
2166   m1->finishInsertingCells();
2167   DataArrayDouble *myCoords1=DataArrayDouble::New();
2168   myCoords1->alloc(25,2);
2169   std::copy(m1Coords,m1Coords+50,myCoords1->getPointer());
2170   m1->setCoords(myCoords1);
2171   myCoords1->decrRef();
2172   //
2173   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.};
2174   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};
2175   MEDCouplingUMesh *m2=MEDCouplingUMesh::New();
2176   m2->setMeshDimension(2);
2177   m2->allocateCells(8);
2178   for(int i=0;i<8;i++)
2179     m2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,m2Conn+4*i);
2180   m2->finishInsertingCells();
2181   DataArrayDouble *myCoords2=DataArrayDouble::New();
2182   myCoords2->alloc(15,2);
2183   std::copy(m2Coords,m2Coords+30,myCoords2->getPointer());
2184   m2->setCoords(myCoords2);
2185   myCoords2->decrRef();
2186   //
2187   DataArrayInt *d1=0,*d2=0;
2188   MEDCouplingUMesh *m3=MEDCouplingUMesh::Intersect2DMeshes(m1,m2,1e-10,d1,d2);
2189   m3->unPolyze();
2190   const int expected1[12]={0,1,1,2,3,3,4,5,5,6,7,7};
2191   const int expected2[12]={0,0,1,2,2,3,4,4,5,6,6,7};
2192   CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples());
2193   CPPUNIT_ASSERT_EQUAL(12,d2->getNumberOfTuples());
2194   CPPUNIT_ASSERT_EQUAL(12,m3->getNumberOfCells());
2195   CPPUNIT_ASSERT_EQUAL(88,m3->getNumberOfNodes());
2196   CPPUNIT_ASSERT_EQUAL(2,m3->getSpaceDimension());
2197   CPPUNIT_ASSERT(std::equal(expected1,expected1+12,d1->getConstPointer()));
2198   CPPUNIT_ASSERT(std::equal(expected2,expected2+12,d2->getConstPointer()));
2199   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};
2200   const int expected4[13]={0,7,16,25,32,41,50,57,66,75,82,91,100};
2201   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};
2202   CPPUNIT_ASSERT_EQUAL(100,m3->getNodalConnectivity()->getNumberOfTuples());
2203   CPPUNIT_ASSERT_EQUAL(13,m3->getNodalConnectivityIndex()->getNumberOfTuples());
2204   CPPUNIT_ASSERT(std::equal(expected3,expected3+100,m3->getNodalConnectivity()->getConstPointer()));
2205   CPPUNIT_ASSERT(std::equal(expected4,expected4+13,m3->getNodalConnectivityIndex()->getConstPointer()));
2206   for(int i=0;i<176;i++)
2207     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected5[i],m3->getCoords()->getIJ(0,i),1e-12);
2208   d1->decrRef();
2209   d2->decrRef();
2210   m3->decrRef();
2211   //
2212   m1->decrRef();
2213   m2->decrRef();
2214 }