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