]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[tools/medcoupling.git] / src / MEDCoupling / Test / MEDCouplingBasicsTest.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "MEDCouplingBasicsTest.hxx"
20 #include "MEDCouplingUMesh.hxx"
21 #include "MEDCouplingFieldDouble.hxx"
22 #include "MemArray.hxx"
23 #include "Interpolation2D.txx"
24 #include "Interpolation3DSurf.txx"
25
26 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
27
28 #include <cmath>
29
30 using namespace std;
31 using namespace ParaMEDMEM;
32
33 void MEDCouplingBasicsTest::testMesh()
34 {
35   const int nbOfCells=6;
36   const int nbOfNodes=12;
37   
38   double coords[3*nbOfNodes]={ 
39     0.024155, 0.04183768725682622, -0.305, 0.04831000000000001, -1.015761910347357e-17, -0.305, 0.09662000000000001, -1.832979297858306e-18, 
40     -0.305, 0.120775, 0.04183768725682623, -0.305, 0.09662000000000001, 0.08367537451365245, -0.305, 0.04831000000000001, 
41     0.08367537451365246, -0.305, 0.024155, 0.04183768725682622, -0.2863, 0.04831000000000001, -1.015761910347357e-17, -0.2863, 
42     0.09662000000000001, -1.832979297858306e-18, -0.2863, 0.120775, 0.04183768725682623, -0.2863, 0.09662000000000001, 0.08367537451365245, 
43     -0.2863, 0.04831000000000001, 0.08367537451365246, -0.2863, };
44   
45   int tab4[4*nbOfCells]={ 
46     1, 2, 8, 7, 2, 3, 9, 8, 3, 4, 10, 9, 4, 5, 11, 10, 5, 0, 6, 11, 
47     0, 1, 7, 6, };
48   
49   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
50   mesh->setMeshDimension(2);
51   mesh->allocateCells(8);
52   const int *curConn=tab4;
53   for(int i=0;i<nbOfCells;i++,curConn+=4)
54     mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,curConn);
55   mesh->finishInsertingCells();
56   CPPUNIT_ASSERT_EQUAL(30,mesh->getNodalConnectivity()->getNbOfElems());
57   CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh->getNumberOfCells());
58   //test 0 - no copy no ownership
59   DataArrayDouble *myCoords=DataArrayDouble::New();
60   myCoords->useArray(coords,false,CPP_DEALLOC,nbOfNodes,3);
61   mesh->setCoords(myCoords);
62   mesh->setCoords(myCoords);
63   myCoords->decrRef();
64   CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh->getNumberOfCells());
65   mesh->checkCoherency();
66   //test 1 - no copy ownership C++
67   myCoords=DataArrayDouble::New();
68   double *tmp=new double[3*nbOfNodes];
69   copy(coords,coords+3*nbOfNodes,tmp);
70   myCoords->useArray(tmp,true,CPP_DEALLOC,nbOfNodes,3);
71   mesh->setCoords(myCoords);
72   myCoords->decrRef();
73   CPPUNIT_ASSERT_EQUAL(nbOfCells,mesh->getNumberOfCells());
74   mesh->checkCoherency();
75   //test 2 - no copy ownership C
76   myCoords=DataArrayDouble::New();
77   tmp=(double *)malloc(3*nbOfNodes*sizeof(double));
78   copy(coords,coords+3*nbOfNodes,tmp);
79   myCoords->useArray(tmp,true,C_DEALLOC,nbOfNodes,3);
80   mesh->setCoords(myCoords);
81   myCoords->decrRef();
82   CPPUNIT_ASSERT_EQUAL(nbOfNodes,mesh->getNumberOfNodes());
83   mesh->checkCoherency();
84   //test 3 - copy.
85   myCoords=DataArrayDouble::New();
86   myCoords->alloc(nbOfNodes,3);
87   tmp=myCoords->getPointer();
88   copy(coords,coords+3*nbOfNodes,tmp);
89   // test 3 bis deepcopy
90   DataArrayDouble *myCoords2=DataArrayDouble::New();
91   *myCoords2=*myCoords;
92   myCoords2->decrRef();
93   //
94   mesh->setCoords(myCoords);
95   myCoords->decrRef();
96   CPPUNIT_ASSERT_EQUAL(nbOfNodes,mesh->getNumberOfNodes());
97   mesh->checkCoherency();
98   //test 4 - Field on cells
99   MEDCouplingFieldDouble *fieldOnCells=MEDCouplingFieldDouble::New(ON_CELLS);
100   fieldOnCells->setMesh(mesh);
101   DataArrayDouble *array=DataArrayDouble::New();
102   array->alloc(nbOfCells,9);
103   fieldOnCells->setArray(array);
104   tmp=array->getPointer();
105   array->decrRef();
106   fill(tmp,tmp+9*nbOfCells,7.);
107   fieldOnCells->declareAsNew();
108   fieldOnCells->checkCoherency();
109   fieldOnCells->decrRef();
110   //clean-up
111   mesh->decrRef();
112 }
113
114 void MEDCouplingBasicsTest::test2DInterpP0P0_1()
115 {
116   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
117   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
118   //
119   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
120   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
121   INTERP_KERNEL::Interpolation2D myInterpolator;
122   vector<map<int,double> > res;
123   INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D};
124   for(int i=0;i<3;i++)
125     {
126       myInterpolator.setPrecision(1e-12);
127       myInterpolator.setIntersectionType(types[i]);
128       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
129       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
130       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][0],1e-12);
131       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
132       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
133       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
134       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][1],1e-12);
135       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][0],1e-12);
136       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][1],1e-12);
137       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
138       res.clear();
139     }
140   //clean up
141   sourceMesh->decrRef();
142   targetMesh->decrRef();
143 }
144
145 void MEDCouplingBasicsTest::test2DInterpP0P1_1()
146 {
147   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
148   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
149   //
150   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
151   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
152   INTERP_KERNEL::Interpolation2D myInterpolator;
153   vector<map<int,double> > res;
154   INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D};
155   for(int i=0;i<3;i++)
156     {
157       myInterpolator.setPrecision(1e-12);
158       myInterpolator.setIntersectionType(types[i]);
159       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
160       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
161       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][0],1e-12);
162       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][1],1e-12);
163       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
164       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[2][0],1e-12);
165       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[3][1],1e-12);
166       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][0],1e-12);
167       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][1],1e-12);
168       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[5][0],1e-12);
169       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[6][1],1e-12);
170       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[7][1],1e-12);
171       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][0],1e-12);
172       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][1],1e-12);
173       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,sumAll(res),1e-12);
174       res.clear();
175     }
176   //clean up
177   sourceMesh->decrRef();
178   targetMesh->decrRef();
179 }
180
181 void MEDCouplingBasicsTest::test2DInterpP1P0_1()
182 {
183   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
184   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
185   //
186   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
187   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
188   INTERP_KERNEL::Interpolation2D myInterpolator;
189   vector<map<int,double> > res;
190   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
191   for(int i=0;i<2;i++)
192     {
193       myInterpolator.setPrecision(1e-12);
194       myInterpolator.setIntersectionType(types[i]);
195       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
196       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
197       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
198       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12);
199       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][0],1e-12);
200       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[1][1],1e-12);
201       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[2][1],1e-12);
202       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667,res[3][2],1e-12);
203       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12);
204       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][3],1e-12);
205       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][3],1e-12);
206       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
207       res.clear();
208     }
209   //clean up
210   sourceMesh->decrRef();
211   targetMesh->decrRef();
212 }
213
214 void MEDCouplingBasicsTest::test3DSurfInterpP0P0_1()
215 {
216   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
217   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
218   //
219   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
220   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
221   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
222   vector<map<int,double> > res;
223   INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D};
224   for(int i=0;i<3;i++)
225     {
226       myInterpolator.setPrecision(1e-12);
227       myInterpolator.setIntersectionType(types[i]);
228       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
229       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
230       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[0][0],1e-12);
231       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[0][1],1e-12);
232       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[1][0],1e-12);
233       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[2][0],1e-12);
234       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2),res[3][1],1e-12);
235       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[4][0],1e-12);
236       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[4][1],1e-12);
237       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2),sumAll(res),1e-12);
238       res.clear();
239     }
240   //clean up
241   sourceMesh->decrRef();
242   targetMesh->decrRef();
243 }
244
245 void MEDCouplingBasicsTest::test3DSurfInterpP0P1_1()
246 {
247   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
248   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
249   //
250   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
251   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
252   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
253   vector<map<int,double> > res;
254   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
255   for(int i=0;i<2;i++)
256     {
257       myInterpolator.setPrecision(1e-12);
258       myInterpolator.setIntersectionType(types[i]);
259       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
260       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
261       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[0][0],1e-12);
262       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[0][1],1e-12);
263       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[1][0],1e-12);
264       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2),res[2][0],1e-12);
265       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2),res[3][1],1e-12);
266       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2),res[4][0],1e-12);
267       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2),res[4][1],1e-12);
268       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2),res[5][0],1e-12);
269       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2),res[6][1],1e-12);
270       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2),res[7][1],1e-12);
271       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[8][0],1e-12);
272       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[8][1],1e-12);
273       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25*sqrt(2),sumAll(res),1e-12);
274       res.clear();
275     }
276   //clean up
277   sourceMesh->decrRef();
278   targetMesh->decrRef();
279 }
280
281 void MEDCouplingBasicsTest::test3DSurfInterpP1P0_1()
282 {
283   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
284   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
285   //
286   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
287   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
288   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
289   vector<map<int,double> > res;
290   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
291   for(int i=0;i<2;i++)
292     {
293       myInterpolator.setPrecision(1e-12);
294       myInterpolator.setIntersectionType(types[i]);
295       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
296       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
297       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2),res[0][0],1e-12);
298       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[1][0],1e-12);
299       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[3][0],1e-12);
300       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2),res[1][1],1e-12);
301       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2),res[2][1],1e-12);
302       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667*sqrt(2),res[3][2],1e-12);
303       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[2][3],1e-12);
304       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2),res[3][3],1e-12);
305       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2),res[4][3],1e-12);
306       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2),sumAll(res),1e-12);
307       res.clear();
308     }
309   //clean up
310   sourceMesh->decrRef();
311   targetMesh->decrRef();
312 }
313
314 void MEDCouplingBasicsTest::test3DInterpP0P0_1()
315 {
316   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
317   //clean up
318   sourceMesh->decrRef();
319 }
320
321 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DSourceMesh_1()
322 {
323   double sourceCoords[8]={-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7};
324   int sourceConn[6]={0,3,1,0,2,3};
325   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
326   sourceMesh->setMeshDimension(2);
327   sourceMesh->allocateCells(2);
328   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
329   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
330   sourceMesh->finishInsertingCells();
331   DataArrayDouble *myCoords=DataArrayDouble::New();
332   myCoords->alloc(4,2);
333   std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer());
334   sourceMesh->setCoords(myCoords);
335   myCoords->decrRef();
336   return sourceMesh;
337 }
338
339 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_1()
340 {
341   double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
342   int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
343   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
344   targetMesh->setMeshDimension(2);
345   targetMesh->allocateCells(5);
346   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
347   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
348   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
349   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
350   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
351   targetMesh->finishInsertingCells();
352   DataArrayDouble *myCoords=DataArrayDouble::New();
353   myCoords->alloc(9,2);
354   std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
355   targetMesh->setCoords(myCoords);
356   myCoords->decrRef();
357   return targetMesh;
358 }
359
360 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_1()
361 {
362   double sourceCoords[12]={-0.3,-0.3,0.5, 0.7,-0.3,1.5, -0.3,0.7,0.5, 0.7,0.7,1.5};
363   int sourceConn[6]={0,3,1,0,2,3};
364   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
365   sourceMesh->setMeshDimension(2);
366   sourceMesh->allocateCells(2);
367   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
368   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
369   sourceMesh->finishInsertingCells();
370   DataArrayDouble *myCoords=DataArrayDouble::New();
371   myCoords->alloc(4,3);
372   std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
373   sourceMesh->setCoords(myCoords);
374   myCoords->decrRef();
375   return sourceMesh;
376 }
377
378 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_1()
379 {
380   double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
381   int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
382   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
383   targetMesh->setMeshDimension(2);
384   targetMesh->allocateCells(5);
385   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
386   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
387   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
388   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
389   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
390   targetMesh->finishInsertingCells();
391   DataArrayDouble *myCoords=DataArrayDouble::New();
392   myCoords->alloc(9,3);
393   std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
394   targetMesh->setCoords(myCoords);
395   myCoords->decrRef();
396   return targetMesh;
397 }
398
399 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_1()
400 {
401   double sourceCoords[27]={ 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0,
402                             200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0 };
403   int sourceConn[48]={8,1,7,3, 6,0,8,2, 7,4,5,8, 6,8,4,7, 6,8,0,4, 6,8,7,3, 8,1,3,0, 4,1,5,8, 1,7,5,8, 0,3,8,2, 8,1,0,4, 3,6,8,2};
404   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
405   sourceMesh->setMeshDimension(3);
406   sourceMesh->allocateCells(12);
407   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn);
408   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4);
409   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+8);
410   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+12);
411   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+16);
412   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+20);
413   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+24);
414   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+28);
415   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+32);
416   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+36);
417   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+40);
418   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+44);
419   sourceMesh->finishInsertingCells();
420   DataArrayDouble *myCoords=DataArrayDouble::New();
421   myCoords->alloc(9,3);
422   std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
423   sourceMesh->setCoords(myCoords);
424   myCoords->decrRef();
425   return sourceMesh;
426 }
427
428 double MEDCouplingBasicsTest::sumAll(const std::vector< std::map<int,double> >& matrix)
429 {
430   double ret=0.;
431   for(std::vector< std::map<int,double> >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++)
432     for(std::map<int,double>::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++)
433       ret+=(*iter2).second;
434   return ret;
435 }