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