Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / MEDCoupling / Test / MEDCouplingBasicsTestInterp.cxx
1 // Copyright (C) 2007-2020  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 "MEDCouplingBasicsTestInterp.hxx"
22 #include "MEDCouplingUMesh.hxx"
23 #include "MEDCouplingMappedExtrudedMesh.hxx"
24 #include "MEDCouplingFieldDouble.hxx"
25 #include "MEDCouplingMemArray.hxx"
26 #include "Interpolation2D.txx"
27 #include "Interpolation3DSurf.hxx"
28 #include "Interpolation3D.txx"
29 #include "Interpolation2D1D.txx"
30 #include "Interpolation2D3D.txx"
31 #include "InterpolationCC.txx"
32 #include "InterpolationCU.txx"
33 #include "Interpolation2DCurve.hxx"
34 #include "Interpolation1D.txx"
35
36 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
37 #include "MEDCouplingNormalizedCartesianMesh.txx"
38
39 #include <cmath>
40 #include <functional>
41
42 using namespace MEDCoupling;
43
44 typedef std::vector<std::map<mcIdType,double> > IntersectionMatrix;
45
46 void MEDCouplingBasicsTestInterp::test2DInterpP0P0_1()
47 {
48   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
49   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
50   //
51   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
52   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
53   INTERP_KERNEL::Interpolation2D myInterpolator;
54   std::vector<std::map<mcIdType,double> > res;
55   INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D};
56   for(int i=0;i<3;i++)
57     {
58       myInterpolator.setPrecision(1e-12);
59       myInterpolator.setIntersectionType(types[i]);
60       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
61       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
62       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][0],1e-12);
63       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
64       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
65       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
66       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][1],1e-12);
67       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][0],1e-12);
68       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][1],1e-12);
69       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
70       res.clear();
71     }
72   //clean up
73   sourceMesh->decrRef();
74   targetMesh->decrRef();
75 }
76
77 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_1()
78 {
79   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
80   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
81   //
82   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
83   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
84   INTERP_KERNEL::Interpolation2D myInterpolator;
85   std::vector<std::map<mcIdType,double> > res;
86   //
87   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
88   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
89   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
90   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
91   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
92   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
93   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
94   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
95   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
96   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
97   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
98   //
99   sourceMesh->decrRef();
100   targetMesh->decrRef();
101 }
102
103 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_2()
104 {
105   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
106   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
107   //
108   std::vector<mcIdType> cellsIds(targetMesh->getNumberOfCells());
109   for(mcIdType i=0;i<targetMesh->getNumberOfCells();i++)
110     cellsIds[i]=i;
111   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
112   //
113   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
114   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
115   INTERP_KERNEL::Interpolation2D myInterpolator;
116   std::vector<std::map<mcIdType,double> > res;
117   //
118   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
119   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
120   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
121   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
122   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
123   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
124   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
125   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
126   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
127   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
128   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
129   //
130   sourceMesh->decrRef();
131   targetMesh->decrRef();
132 }
133
134 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_3()
135 {
136   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
137   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
138   //
139   std::vector<mcIdType> cellsIds(sourceMesh->getNumberOfCells());
140   for(mcIdType i=0;i<sourceMesh->getNumberOfCells();i++)
141     cellsIds[i]=i;
142   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
143   //
144   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
145   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
146   INTERP_KERNEL::Interpolation2D myInterpolator;
147   std::vector<std::map<mcIdType,double> > res;
148   //
149   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
150   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
151   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
152   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
153   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
154   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
155   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
156   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
157   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
158   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
159   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
160   //
161   sourceMesh->decrRef();
162   targetMesh->decrRef();
163 }
164
165 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_4()
166 {
167   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
168   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
169   //
170   std::vector<mcIdType> cellsIds(sourceMesh->getNumberOfCells());
171   for(mcIdType i=0;i<sourceMesh->getNumberOfCells();i++)
172     cellsIds[i]=i;
173   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
174   cellsIds.resize(targetMesh->getNumberOfCells());
175   for(mcIdType i=0;i<targetMesh->getNumberOfCells();i++)
176     cellsIds[i]=i;
177   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
178   //
179   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
180   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
181   INTERP_KERNEL::Interpolation2D myInterpolator;
182   std::vector<std::map<mcIdType,double> > res;
183   //
184   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
185   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
186   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
187   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
188   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
189   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
190   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
191   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
192   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
193   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
194   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
195   //
196   sourceMesh->decrRef();
197   targetMesh->decrRef();
198 }
199
200 void MEDCouplingBasicsTestInterp::test2DInterpP0P1_1()
201 {
202   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
203   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
204   //
205   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
206   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
207   INTERP_KERNEL::Interpolation2D myInterpolator;
208   std::vector<std::map<mcIdType,double> > res;
209   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
210   for(int i=0;i<2;i++)
211     {
212       myInterpolator.setPrecision(1e-12);
213       myInterpolator.setIntersectionType(types[i]);
214       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
215       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
216       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][0],1e-12);
217       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][1],1e-12);
218       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
219       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[2][0],1e-12);
220       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[3][1],1e-12);
221       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][0],1e-12);
222       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][1],1e-12);
223       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[5][0],1e-12);
224       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[6][1],1e-12);
225       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[7][1],1e-12);
226       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][0],1e-12);
227       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][1],1e-12);
228       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,sumAll(res),1e-12);
229       res.clear();
230     }
231   //clean up
232   sourceMesh->decrRef();
233   targetMesh->decrRef();
234 }
235
236 void MEDCouplingBasicsTestInterp::test2DInterpP0P1PL_1()
237 {
238   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
239   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
240   //
241   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
242   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
243   INTERP_KERNEL::Interpolation2D myInterpolator;
244   std::vector<std::map<mcIdType,double> > res;
245   myInterpolator.setPrecision(1e-12);
246   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
247   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
248   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
249   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
250   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
251   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
252   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
253   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
254   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
255   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
256   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
257   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
258   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
259   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
260   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
261   CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
262   res.clear();
263   //clean up
264   sourceMesh->decrRef();
265   targetMesh->decrRef();
266 }
267
268 void MEDCouplingBasicsTestInterp::test2DInterpP0P1PL_2()
269 {
270   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
271   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
272   //
273   std::vector<mcIdType> cellsIds(sourceMesh->getNumberOfCells());
274   for(mcIdType i=0;i<sourceMesh->getNumberOfCells();i++)
275     cellsIds[i]=i;
276   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
277   //
278   cellsIds.resize(targetMesh->getNumberOfCells());
279   for(mcIdType i=0;i<targetMesh->getNumberOfCells();i++)
280     cellsIds[i]=i;
281   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
282   //
283   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
284   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
285   INTERP_KERNEL::Interpolation2D myInterpolator;
286   std::vector<std::map<mcIdType,double> > res;
287   myInterpolator.setPrecision(1e-12);
288   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
289   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
290   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
291   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
292   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
293   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
294   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
295   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
296   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
297   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
298   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
299   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
300   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
301   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
302   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
303   CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
304   res.clear();
305   //clean up
306   sourceMesh->decrRef();
307   targetMesh->decrRef();
308 }
309
310 void MEDCouplingBasicsTestInterp::test2DInterpP1P0_1()
311 {
312   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
313   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
314   //
315   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
316   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
317   INTERP_KERNEL::Interpolation2D myInterpolator;
318   std::vector<std::map<mcIdType,double> > res;
319   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
320   for(mcIdType i=0;i<2;i++)
321     {
322       myInterpolator.setPrecision(1e-12);
323       myInterpolator.setIntersectionType(types[i]);
324       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
325       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
326       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
327       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12);
328       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][0],1e-12);
329       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[1][1],1e-12);
330       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[2][1],1e-12);
331       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667,res[3][2],1e-12);
332       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12);
333       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][3],1e-12);
334       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][3],1e-12);
335       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
336       res.clear();
337     }
338   //clean up
339   sourceMesh->decrRef();
340   targetMesh->decrRef();
341 }
342
343 void MEDCouplingBasicsTestInterp::test2DInterpP1P0PL_1()
344 {
345   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
346   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
347   //
348   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
349   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
350   INTERP_KERNEL::Interpolation2D myInterpolator;
351   std::vector<std::map<mcIdType,double> > res;
352   myInterpolator.setPrecision(1e-12);
353   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
354   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
355   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
356   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
357   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
358   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
359   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
360   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
361   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
362   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
363   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
364   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
365   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
366   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
367   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
368   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
369   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
370   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
371   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
372   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
373   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
374   res.clear();
375   //clean up
376   sourceMesh->decrRef();
377   targetMesh->decrRef();
378 }
379
380 void MEDCouplingBasicsTestInterp::test2DInterpP1P0PL_2()
381 {
382   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
383   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
384   //
385   std::vector<mcIdType >cellsIds(targetMesh->getNumberOfCells());
386   for(mcIdType i=0;i<targetMesh->getNumberOfCells();i++)
387     cellsIds[i]=i;
388   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
389   //
390   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
391   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
392   INTERP_KERNEL::Interpolation2D myInterpolator;
393   std::vector<std::map<mcIdType,double> > res;
394   myInterpolator.setPrecision(1e-12);
395   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
396   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
397   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
398   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
399   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
400   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
401   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
402   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
403   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
404   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
405   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
406   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
407   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
408   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
409   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
410   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
411   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
412   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
413   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
414   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
415   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
416   res.clear();
417   //clean up
418   sourceMesh->decrRef();
419   targetMesh->decrRef();
420 }
421
422 void MEDCouplingBasicsTestInterp::test2DInterpP1P1_1()
423 {
424   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
425   MEDCouplingUMesh *targetMesh=build2DTargetMesh_2();
426   //
427   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
428   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
429   INTERP_KERNEL::Interpolation2D myInterpolator;
430   std::vector<std::map<mcIdType,double> > res;
431   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
432   for(int i=0;i<2;i++)
433     {
434       myInterpolator.setPrecision(1e-12);
435       myInterpolator.setIntersectionType(types[i]);
436       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
437       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
438       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[0][0],1.e-12);
439       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[1][0],1.e-12);
440       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[1][1],1.e-12);
441       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[2][1],1.e-12);
442       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[3][0],1.e-12);
443       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668,res[3][2],1.e-12);
444       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666,res[4][0],1.e-12);
445       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][1],1.e-12);
446       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][2],1.e-12);
447       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999,res[4][3],1.e-12);
448       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[5][1],1.e-12);
449       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333,res[5][3],1.e-12);
450       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333,res[6][2],1.e-12);
451       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667,res[7][2],1.e-12);
452       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331,res[7][3],1.e-12);
453       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668,res[8][3],1.e-12);
454       res.clear();
455     }
456   //clean up
457   sourceMesh->decrRef();
458   targetMesh->decrRef();
459 }
460
461 void MEDCouplingBasicsTestInterp::test2DInterpP1P1PL_1()
462 {
463   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
464   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
465   //
466   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
467   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
468   INTERP_KERNEL::Interpolation2D myInterpolator;
469   std::vector<std::map<mcIdType,double> > res;
470   myInterpolator.setPrecision(1e-12);
471   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
472   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
473   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
474   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12);
475   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12);
476   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12);
477   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12);
478   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12);
479   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12);
480   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12);
481   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12);
482   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12);
483   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12);
484   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12);
485   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12);
486   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12);
487   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12);
488   CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12);
489   res.clear();
490   //clean up
491   sourceMesh->decrRef();
492   targetMesh->decrRef();
493 }
494
495 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_1()
496 {
497   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
498   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
499   //
500   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
501   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
502   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
503   std::vector<std::map<mcIdType,double> > res;
504   INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
505   for(int i=0;i<2;i++)
506     {
507       myInterpolator.setPrecision(1e-12);
508       myInterpolator.setIntersectionType(types[i]);
509       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
510       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
511       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
512       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
513       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
514       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
515       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
516       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
517       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
518       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
519       res.clear();
520     }
521   //clean up
522   sourceMesh->decrRef();
523   targetMesh->decrRef();
524 }
525
526 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0PL_1()
527 {
528   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
529   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
530   //
531   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
532   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
533   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
534   std::vector<std::map<mcIdType,double> > res;
535   myInterpolator.setPrecision(1e-12);
536   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
537   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
538   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
539   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
540   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
541   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
542   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
543   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
544   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
545   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
546   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
547   res.clear();
548   //clean up
549   sourceMesh->decrRef();
550   targetMesh->decrRef();
551 }
552
553 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P1_1()
554 {
555   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
556   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
557   //
558   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
559   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
560   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
561   std::vector<std::map<mcIdType,double> > res;
562   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
563   for(int i=0;i<2;i++)
564     {
565       myInterpolator.setPrecision(1e-12);
566       myInterpolator.setIntersectionType(types[i]);
567       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
568       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
569       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][0],1e-12);
570       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][1],1e-12);
571       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
572       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[2][0],1e-12);
573       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[3][1],1e-12);
574       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][0],1e-12);
575       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][1],1e-12);
576       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[5][0],1e-12);
577       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[6][1],1e-12);
578       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[7][1],1e-12);
579       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][0],1e-12);
580       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][1],1e-12);
581       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25*sqrt(2.),sumAll(res),1e-12);
582       res.clear();
583     }
584   //clean up
585   sourceMesh->decrRef();
586   targetMesh->decrRef();
587 }
588
589 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P1PL_1()
590 {
591   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
592   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
593   //
594   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
595   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
596   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
597   std::vector<std::map<mcIdType,double> > res;
598   myInterpolator.setPrecision(1e-12);
599   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
600   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
601   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
602   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
603   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
604   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
605   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
606   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
607   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
608   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
609   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
610   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
611   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
612   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
613   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
614   CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
615   res.clear();
616   //clean up
617   sourceMesh->decrRef();
618   targetMesh->decrRef();
619 }
620
621 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0_1()
622 {
623   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
624   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
625   //
626   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
627   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
628   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
629   std::vector<std::map<mcIdType,double> > res;
630   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
631   for(int i=0;i<2;i++)
632     {
633       myInterpolator.setPrecision(1e-12);
634       myInterpolator.setIntersectionType(types[i]);
635       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
636       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
637       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
638       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12);
639       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][0],1e-12);
640       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[1][1],1e-12);
641       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[2][1],1e-12);
642       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667*sqrt(2.),res[3][2],1e-12);
643       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12);
644       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][3],1e-12);
645       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][3],1e-12);
646       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
647       res.clear();
648     }
649   //clean up
650   sourceMesh->decrRef();
651   targetMesh->decrRef();
652 }
653
654 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0PL_1()
655 {
656   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
657   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
658   //
659   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
660   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
661   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
662   std::vector<std::map<mcIdType,double> > res;
663   myInterpolator.setPrecision(1e-12);
664   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
665   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
666   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
667   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
668   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
669   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
670   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
671   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
672   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
673   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
674   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
675   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
676   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
677   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
678   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
679   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
680   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
681   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
682   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
683   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
684   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
685   res.clear();
686   //clean up
687   sourceMesh->decrRef();
688   targetMesh->decrRef();
689 }
690
691 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P1_1()
692 {
693   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
694   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_2();
695   //
696   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
697   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
698   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
699   std::vector<std::map<mcIdType,double> > res;
700   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
701   for(int i=0;i<2;i++)
702     {
703       myInterpolator.setPrecision(1e-12);
704       myInterpolator.setIntersectionType(types[i]);
705       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
706       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
707       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[0][0],1.e-12);
708       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[1][0],1.e-12);
709       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[1][1],1.e-12);
710       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[2][1],1.e-12);
711       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[3][0],1.e-12);
712       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668*sqrt(2.),res[3][2],1.e-12);
713       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666*sqrt(2.),res[4][0],1.e-12);
714       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][1],1.e-12);
715       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][2],1.e-12);
716       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999*sqrt(2.),res[4][3],1.e-12);
717       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[5][1],1.e-12);
718       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333*sqrt(2.),res[5][3],1.e-12);
719       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333*sqrt(2.),res[6][2],1.e-12);
720       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667*sqrt(2.),res[7][2],1.e-12);
721       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331*sqrt(2.),res[7][3],1.e-12);
722       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668*sqrt(2.),res[8][3],1.e-12);
723       res.clear();
724     }
725   //
726   sourceMesh->decrRef();
727   targetMesh->decrRef();
728 }
729
730 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P1PL_1()
731 {
732   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
733   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
734   //
735   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
736   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
737   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
738   std::vector<std::map<mcIdType,double> > res;
739   myInterpolator.setPrecision(1e-12);
740   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
741   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
742   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
743   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12);
744   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12);
745   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12);
746   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12);
747   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12);
748   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12);
749   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12);
750   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12);
751   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12);
752   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12);
753   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12);
754   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12);
755   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12);
756   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12);
757   CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12);
758   res.clear();
759   //clean up
760   sourceMesh->decrRef();
761   targetMesh->decrRef();
762 }
763
764 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_2()
765 {
766   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
767   MEDCouplingUMesh *targetMesh=build3DSurfTargetMeshPerm_1();
768   //
769   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
770   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
771   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
772   std::vector<std::map<mcIdType,double> > res;
773   myInterpolator.setPrecision(1e-12);
774   myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation);
775   {
776     myInterpolator.setOrientation(2);
777     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
778     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
779     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
780     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
781     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
782     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
783     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
784     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
785     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
786     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
787     res.clear();
788   }
789   {
790     myInterpolator.setOrientation(0);
791     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
792     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
793     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
794     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
795     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
796     CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125*sqrt(2.),res[2][0],1e-12);
797     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
798     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
799     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
800     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75*sqrt(2.),sumAll(res),1e-12);
801     res.clear();
802   }
803   {
804     myInterpolator.setOrientation(1);
805     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
806     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
807     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
808     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
809     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
810     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
811     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
812     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
813     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.875*sqrt(2.),sumAll(res),1e-12);
814     res.clear();
815   }
816   {
817     myInterpolator.setOrientation(-1);
818     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
819     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
820     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
821     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),sumAll(res),1e-12);
822     res.clear();
823   }
824   //clean up
825   sourceMesh->decrRef();
826   targetMesh->decrRef();
827 }
828
829 /*!
830  * Test of precision option implemented by Fabien that represents distance of "barycenter" to the other cell.
831  */
832 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_3()
833 {
834   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
835   std::vector<std::map<mcIdType,double> > res;
836   double vecTrans[3]={0.,0.,1.e-10};
837   double vec[3]={0.,-1.,0.};
838   double pt[3]={-0.3,-0.3,5.e-11};
839   const int N=32;
840   const double deltaA=M_PI/N;
841   myInterpolator.setPrecision(1e-12);
842   myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation);
843   myInterpolator.setMaxDistance3DSurfIntersect(1e-9);
844   for(int i=0;i<N;i++)
845     {
846       res.clear();
847       MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
848       sourceMesh->rotate(pt,vec,i*deltaA);
849       MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
850       targetMesh->translate(vecTrans);
851       targetMesh->rotate(pt,vec,i*deltaA);
852       MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
853       MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
854       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
855       CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
856       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
857       sourceMesh->decrRef();
858       targetMesh->decrRef();
859     }
860   //
861   myInterpolator.setMaxDistance3DSurfIntersect(1e-11);
862   for(int i=0;i<N;i++)
863     {
864       res.clear();
865       MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
866       sourceMesh->rotate(pt,vec,i*deltaA);
867       MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
868       targetMesh->translate(vecTrans);
869       targetMesh->rotate(pt,vec,i*deltaA);
870       MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
871       MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
872       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
873       CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
874       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12);
875       sourceMesh->decrRef();
876       targetMesh->decrRef();
877     }
878   //
879   res.clear();
880   myInterpolator.setMaxDistance3DSurfIntersect(-1.);//unactivate fabien lookup
881   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
882   MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
883   targetMesh->translate(vecTrans);
884   myInterpolator.setBoundingBoxAdjustment(1e-11);
885   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper0(sourceMesh);
886   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper0(targetMesh);
887   myInterpolator.interpolateMeshes(sourceWrapper0,targetWrapper0,res,"P0P0");
888   CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
889   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12);
890   sourceMesh->decrRef();
891   targetMesh->decrRef();
892   //
893   res.clear();
894   sourceMesh=build3DSurfSourceMesh_2();
895   targetMesh=build3DSurfSourceMesh_2();
896   targetMesh->translate(vecTrans);
897   myInterpolator.setBoundingBoxAdjustment(1e-9);
898   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper1(sourceMesh);
899   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper1(targetMesh);
900   myInterpolator.interpolateMeshes(sourceWrapper1,targetWrapper1,res,"P0P0");
901   CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
902   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
903   sourceMesh->decrRef();
904   targetMesh->decrRef();
905   //keeping the same bbox adj == 1.e-11 but trying rotation
906   res.clear();
907   sourceMesh=build3DSurfSourceMesh_2();
908   sourceMesh->rotate(pt,vec,M_PI/4.);
909   targetMesh=build3DSurfSourceMesh_2();
910   targetMesh->translate(vecTrans);
911   targetMesh->rotate(pt,vec,M_PI/4.);
912   myInterpolator.setBoundingBoxAdjustment(1e-11);
913   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper2(sourceMesh);
914   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper2(targetMesh);
915   myInterpolator.interpolateMeshes(sourceWrapper2,targetWrapper2,res,"P0P0");
916   CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
917   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
918   sourceMesh->decrRef();
919   targetMesh->decrRef();
920 }
921
922 void MEDCouplingBasicsTestInterp::test3DInterpP0P0_1()
923 {
924   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
925   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
926   //
927   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
928   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
929   INTERP_KERNEL::Interpolation3D myInterpolator;
930   std::vector<std::map<mcIdType,double> > res;
931   myInterpolator.setPrecision(1e-12);
932   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
933   for ( int i = 0; i < 4; ++i )
934   {
935     myInterpolator.setSplittingPolicy( sp[i] );
936     res.clear();
937     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
938     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
939     CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7);
940     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7);
941     CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7);
942     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7);
943     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7);
944     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7);
945     CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7);
946     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7);
947     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7);
948     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7);
949     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7);
950     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7);
951     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7);
952     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7);
953     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7);
954     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7);
955     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7);
956     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7);
957     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7);
958     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7);
959     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7);
960     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7);
961     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7);
962     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7);
963     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7);
964     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7);
965     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7);
966     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7);
967     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7);
968     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7);
969     CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7);
970     CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7);
971     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7);
972     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7);
973     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7);
974     CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7);
975     CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7);
976     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7);
977     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7);
978     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7);
979     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7);
980     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7);
981     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7);
982     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7);
983     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7);
984   }
985   //clean up
986   sourceMesh->decrRef();
987   targetMesh->decrRef();
988 }
989
990 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_1()
991 {
992   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
993   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
994   //
995   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
996   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
997   INTERP_KERNEL::Interpolation3D myInterpolator;
998   std::vector<std::map<mcIdType,double> > res;
999   myInterpolator.setPrecision(1e-12);
1000   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1001   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1002   for ( int i = 0; i < 4; ++i )
1003   {
1004     myInterpolator.setSplittingPolicy( sp[i] );
1005     res.clear();
1006     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1007     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1008     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1009     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1010     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1011     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1012     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1013     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1014     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1015     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1016     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1017     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1018     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1019     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1020     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1021     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1022     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1023     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1024     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1025     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1026     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1027     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1028     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1029     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1030   }
1031   //clean up
1032   sourceMesh->decrRef();
1033   targetMesh->decrRef();
1034 }
1035
1036 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_2()
1037 {
1038   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1039   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1040   std::vector<mcIdType> cellsIds(targetMesh->getNumberOfCells());
1041   for(int i=0;i<targetMesh->getNumberOfCells();i++)
1042     cellsIds[i]=i;
1043   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1044   //
1045   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1046   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1047   INTERP_KERNEL::Interpolation3D myInterpolator;
1048   std::vector<std::map<mcIdType,double> > res;
1049   myInterpolator.setPrecision(1e-12);
1050   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1051   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1052   for ( int i = 0; i < 4; ++i )
1053   {
1054     myInterpolator.setSplittingPolicy( sp[i] );
1055     res.clear();
1056     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1057     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1058     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1059     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1060     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1061     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1062     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1063     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1064     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1065     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1066     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1067     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1068     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1069     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1070     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1071     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1072     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1073     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1074     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1075     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1076     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1077     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1078     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1079     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1080   }
1081   //clean up
1082   sourceMesh->decrRef();
1083   targetMesh->decrRef();
1084 }
1085
1086 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_3()
1087 {
1088   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1089   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1090   std::vector<mcIdType> cellsIds(sourceMesh->getNumberOfCells());
1091   for(int i=0;i<sourceMesh->getNumberOfCells();i++)
1092     cellsIds[i]=i;
1093   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1094   //
1095   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1096   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1097   INTERP_KERNEL::Interpolation3D myInterpolator;
1098   std::vector<std::map<mcIdType,double> > res;
1099   myInterpolator.setPrecision(1e-12);
1100   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1101   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1102   for ( int i = 0; i < 4; ++i )
1103   {
1104     myInterpolator.setSplittingPolicy( sp[i] );
1105     res.clear();
1106     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1107     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1108     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1109     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1110     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1111     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1112     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1113     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1114     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1115     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1116     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1117     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1118     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1119     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1120     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1121     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1122     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1123     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1124     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1125     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1126     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1127     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1128     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1129     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1130   }
1131   //clean up
1132   sourceMesh->decrRef();
1133   targetMesh->decrRef();
1134 }
1135
1136 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_4()
1137 {
1138   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1139   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1140   std::vector<mcIdType> cellsIds(sourceMesh->getNumberOfCells());
1141   for(int i=0;i<sourceMesh->getNumberOfCells();i++)
1142     cellsIds[i]=i;
1143   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1144   cellsIds.resize(targetMesh->getNumberOfCells());
1145   for(int j=0;j<targetMesh->getNumberOfCells();j++)
1146     cellsIds[j]=j;
1147   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
1148   //
1149   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1150   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1151   INTERP_KERNEL::Interpolation3D myInterpolator;
1152   std::vector<std::map<mcIdType,double> > res;
1153   myInterpolator.setPrecision(1e-12);
1154   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1155   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1156   for ( int i = 0; i < 4; ++i )
1157   {
1158     myInterpolator.setSplittingPolicy( sp[i] );
1159     res.clear();
1160     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1161     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1162     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
1163     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
1164     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
1165     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
1166     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
1167     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
1168     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
1169     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
1170     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1171     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
1172     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
1173     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
1174     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
1175     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
1176     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
1177     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
1178     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
1179     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1180     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
1181     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
1182     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1183     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1184   }
1185   //clean up
1186   sourceMesh->decrRef();
1187   targetMesh->decrRef();
1188 }
1189
1190 void MEDCouplingBasicsTestInterp::test3DInterpP0P1_1()
1191 {
1192   MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
1193   MEDCouplingUMesh *targetMesh=build3DSourceMesh_1();
1194   //
1195   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1196   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1197   INTERP_KERNEL::Interpolation3D myInterpolator;
1198   std::vector<std::map<mcIdType,double> > res;
1199   myInterpolator.setPrecision(1e-12);
1200   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1201   for ( int i = 0; i < 4; ++i )
1202   {
1203     myInterpolator.setSplittingPolicy( sp[i] );
1204     res.clear();
1205     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
1206     CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
1207     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7);
1208     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7);
1209     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7);
1210     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7);
1211     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7);
1212     CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
1213     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7);
1214     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7);
1215     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7);
1216     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7);
1217     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7);
1218     CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7);
1219     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7);
1220     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7);
1221     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7);
1222     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7);
1223     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7);
1224     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7);
1225     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7);
1226     CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7);
1227     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7);
1228     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
1229     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7);
1230     CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7);
1231     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7);
1232     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7);
1233     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7);
1234     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7);
1235     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7);
1236     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7);
1237     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7);
1238     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7);
1239     CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7);
1240   }
1241   //clean up
1242   sourceMesh->decrRef();
1243   targetMesh->decrRef();
1244 }
1245
1246 void MEDCouplingBasicsTestInterp::test3DInterpP0P1PL_1()
1247 {
1248   MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
1249   MEDCouplingUMesh *targetMesh=build3DSourceMesh_1();
1250   //
1251   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1252   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1253   INTERP_KERNEL::Interpolation3D myInterpolator;
1254   std::vector<std::map<mcIdType,double> > res;
1255   myInterpolator.setPrecision(1e-12);
1256   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1257   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1258   for ( int i = 0; i < 4; ++i )
1259   {
1260     myInterpolator.setSplittingPolicy( sp[i] );
1261     res.clear();
1262     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
1263     CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
1264     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12);
1265     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
1266     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
1267     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12);
1268     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12);
1269     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12);
1270     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12);
1271     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
1272     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12);
1273     CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12);
1274   }
1275   //clean up
1276   sourceMesh->decrRef();
1277   targetMesh->decrRef();
1278 }
1279
1280 void MEDCouplingBasicsTestInterp::test3DInterpP1P0_1()
1281 {
1282   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1283   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1284   //
1285   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1286   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1287   INTERP_KERNEL::Interpolation3D myInterpolator;
1288   std::vector<std::map<mcIdType,double> > res;
1289   myInterpolator.setPrecision(1e-12);
1290   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1291   for ( int i = 0; i < 4; ++i )
1292   {
1293     myInterpolator.setSplittingPolicy( sp[i] );
1294     res.clear();
1295     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1296     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1297     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7);
1298     CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
1299     CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7);
1300     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7);
1301     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7);
1302     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7);
1303     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7);
1304     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7);
1305     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7);
1306     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7);
1307     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7);
1308     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7);
1309     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7);
1310     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7);
1311     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7);
1312     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7);
1313     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7);
1314     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7);
1315     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
1316     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7);
1317     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7);
1318     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7);
1319     CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7);
1320     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7);
1321     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7);
1322     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7);
1323     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7);
1324     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7);
1325     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7);
1326     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7);
1327     CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7);
1328     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7);
1329     CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7);
1330   }
1331   //clean up
1332   sourceMesh->decrRef();
1333   targetMesh->decrRef();
1334 }
1335
1336 void MEDCouplingBasicsTestInterp::test3DInterpP1P0PL_1()
1337 {
1338   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1339   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1340   //
1341   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1342   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1343   INTERP_KERNEL::Interpolation3D myInterpolator;
1344   std::vector<std::map<mcIdType,double> > res;
1345   myInterpolator.setPrecision(1e-12);
1346   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1347   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
1348   for ( int i = 0; i < 4; ++i )
1349   {
1350     myInterpolator.setSplittingPolicy( sp[i] );
1351     res.clear();
1352     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1353     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1354     CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12);
1355     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12);
1356     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
1357     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12);
1358     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12);
1359     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
1360     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12);
1361     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12);
1362     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12);
1363     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12);
1364     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12);
1365     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
1366     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12);
1367     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12);
1368     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12);
1369     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12);
1370     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12);
1371     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12);
1372     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12);
1373     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12);
1374     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12);
1375     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12);
1376     CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12);
1377     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
1378   }
1379   //clean up
1380   sourceMesh->decrRef();
1381   targetMesh->decrRef();
1382 }
1383
1384 void MEDCouplingBasicsTestInterp::test3DInterpP1P1_1()
1385 {
1386   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
1387   MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
1388   //
1389   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1390   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1391   INTERP_KERNEL::Interpolation3D myInterpolator;
1392   std::vector<std::map<mcIdType,double> > res;
1393   myInterpolator.setPrecision(1e-12);
1394   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
1395   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1396   double res3D[8][28]= {{124999.999883775978, 245370.370390364464, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203703.703634892299, 187500.000094145857, 0.0, 0.0, 4629.6296266718, 0.0, 215277.777751402784, 209722.222322299582, 0.0, 0.0, 0.0, 0.0, 104166.666590829205, 121296.296368812196, 0.0, 250000.000003472145},
1397                         {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, 120370.370368827047, 0.0, 0.0, 38888.888897777797, 0.0, 0.0, 45370.3703701697596, 0.0, 0.0, 45370.3703701697596, 83333.3333263888926, 0.0},
1398                         {0.0, 0.0, 0.0, 97222.2222222221753, 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, 97222.2222222221608, 0.0, 97222.2222222222044, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
1399                         {0.0, 277777.777787084982, 199074.074074073927, 0.0, 0.0, 0.0, 4629.62962962962774, 0.0, 321759.259254934732, 83333.3333333333139, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4629.62962667180363, 0.0, 0.0, 251388.88888319055, 194444.444454861077, 0.0, 79629.6296194135939, 250000.000003472145, 0.0, 0.0, 0.0, 0.0},
1400                         {0.0, 0.0, 0.0, 0.0, 85185.1851851851534, 4629.62962962962774, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518511, 0.0, 41666.6666666666642, 83333.3333333333285, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
1401                         {0.0, 324074.07407629228, 0.0, 0.0, 0.0, 247685.185185184964, 6481.48148148147993, 0.0, 173611.11111196311, 0.0, 164814.814814814832, 0.0, 4629.62962962962865, 208333.33333418527, 0.0, 83333.3333333333285, 203703.703697273799, 249999.999999999767, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
1402                         {125000.000000000015, 423611.111111110775, 134259.259259259241, 194444.444444444351, 164814.814814814745, 164351.851851851825, 203703.703703703592, 249999.999999999825, 0.0, 0.0, 0.0, 0.0, 6481.48148148147902, 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},
1403                         {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518453, 0.0, 4629.62962962962956, 83333.3333333333139, 85185.1851851851825, 41666.6666666666642, 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}};
1404   int i=0;
1405   double sum = 0;
1406   //cout.precision(18);
1407   for(std::vector<std::map<mcIdType,double> >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++)
1408     {
1409       //cout<< "res3D[" <<i<< "][]={";
1410       for(int j=0;j<28;j++)
1411         {
1412           std::map<mcIdType,double>::const_iterator iter2=(*iter1).find(j);
1413           if(iter2!=(*iter1).end())
1414             {
1415               //cout<< iter2->second<< ", ";
1416               sum += iter2->second;
1417               CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5);
1418             }
1419           else
1420             {
1421               //cout << "0.0, ";
1422               CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14);
1423             }
1424         }
1425       //cout << "}" << endl;
1426     }
1427   //cout << "Sum = " << sum << endl;
1428   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5);
1429   //clean-up
1430   sourceMesh->decrRef();
1431   targetMesh->decrRef();
1432 }
1433
1434 void MEDCouplingBasicsTestInterp::test3DInterpP1P1PL_1()
1435 {
1436   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
1437   MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
1438   //
1439   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
1440   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1441   INTERP_KERNEL::Interpolation3D myInterpolator;
1442   std::vector<std::map<mcIdType,double> > res;
1443   myInterpolator.setPrecision(1e-12);
1444   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
1445   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
1446   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1447   CPPUNIT_ASSERT_DOUBLES_EQUAL(20.,res[0][24],1e-12);
1448   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[1][26],1e-12);
1449   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][21],1e-12);
1450   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[3][23],1e-12);
1451   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][14],1e-12);
1452   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[5][17],1e-12);
1453   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[6][7],1e-12);
1454   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
1455   CPPUNIT_ASSERT_DOUBLES_EQUAL(97.,sumAll(res),1e-12);
1456   //clean-up
1457   sourceMesh->decrRef();
1458   targetMesh->decrRef();
1459 }
1460
1461 void MEDCouplingBasicsTestInterp::test3DInterpP0P0Empty()
1462 {
1463   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
1464   sourceMesh->setMeshDimension(2);
1465   sourceMesh->allocateCells(0);
1466   sourceMesh->finishInsertingCells();
1467   DataArrayDouble *myCoords=DataArrayDouble::New();
1468   myCoords->alloc(0,2);
1469   sourceMesh->setCoords(myCoords);
1470   myCoords->decrRef();
1471   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
1472   targetMesh->setMeshDimension(2);
1473   targetMesh->allocateCells(0);
1474   targetMesh->finishInsertingCells();
1475   myCoords=DataArrayDouble::New();
1476   myCoords->alloc(0,2);
1477   targetMesh->setCoords(myCoords);
1478   myCoords->decrRef();
1479   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
1480   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1481   INTERP_KERNEL::Interpolation2D myInterpolator;
1482   std::vector<std::map<mcIdType,double> > res;
1483   myInterpolator.setPrecision(1e-12);
1484   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1485   //clean up
1486   sourceMesh->decrRef();
1487   targetMesh->decrRef();
1488 }
1489
1490 void MEDCouplingBasicsTestInterp::testInterpolationCC()
1491 {
1492   double arr1[3] = { 0/2., 1/2., 2/2. };
1493   double arr2[4] = { 0/3, 1/3., 2/3., 3/3. };
1494   MEDCouplingCMesh* mesh[2];
1495   for ( int i = 0; i < 2; ++i )
1496     {
1497       const double* arr = i ? arr1 : arr2;
1498       const int nb_coord = i ? 3 : 4;
1499       DataArrayDouble* coords = DataArrayDouble::New();
1500       coords->useArray( arr, /*ownership=*/false, DeallocType::CPP_DEALLOC, nb_coord, 1 );
1501
1502       mesh[i] = MEDCouplingCMesh::New();
1503       mesh[i]->setCoords( coords, coords, coords );
1504       coords->decrRef();
1505     }
1506   MEDCouplingNormalizedCartesianMesh<3> targetWrapper(mesh[1]);
1507   MEDCouplingNormalizedCartesianMesh<3> sourceWrapper(mesh[0]);
1508   CPPUNIT_ASSERT_EQUAL( 27,int( sourceWrapper.getNumberOfElements()));
1509   CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(0)));
1510   CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(1)));
1511   CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(2)));
1512   CPPUNIT_ASSERT_THROW( sourceWrapper.nbCellsAlongAxis(3), INTERP_KERNEL::Exception);
1513
1514   INTERP_KERNEL::InterpolationCC myInterpolator;
1515   std::vector<std::map<mcIdType,double> > res;
1516   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1517
1518   CPPUNIT_ASSERT_EQUAL(8,int( res.size()));
1519   CPPUNIT_ASSERT_EQUAL(8,int( res[0].size()));
1520   const double precis = 1e-7;
1521   std::set<double> vals;
1522   double sum = 0;
1523   for ( int i = 0; i < (int)res.size(); ++i )
1524     for ( std::map<mcIdType,double>::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v)
1525       {
1526         sum += s_v->second;
1527         double vvv;
1528 #ifdef WIN32
1529         double vv = s_v->second / precis;
1530         if(vv>=0.0)
1531           {
1532             vvv = floor(vv+0.5);
1533           }
1534         else
1535           {
1536             vvv = ceil(vv-0.5);
1537           }
1538 #else
1539         vvv = round( s_v->second / precis );
1540 #endif
1541         vals.insert( precis * vvv );
1542       }
1543   //cout << "tgt: " << i << " src: " << s_v->first << " - w: " << s_v->second << endl;
1544   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, sum, precis );
1545
1546   std::set<double>::iterator v = vals.begin();
1547   CPPUNIT_ASSERT_EQUAL( 4, int( vals.size()) );
1548   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00462963, *v++, precis );
1549   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00925926, *v++, precis );
1550   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.01851850, *v++, precis );
1551   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703700, *v++, precis );
1552
1553   mesh[0]->decrRef();
1554   mesh[1]->decrRef();
1555 }
1556
1557 void MEDCouplingBasicsTestInterp::testInterpolationCU1D()
1558 {
1559   MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
1560   DataArrayDouble* coords = DataArrayDouble::New();
1561   double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
1562   coords->useArray( arr, /*ownership=*/false, DeallocType::CPP_DEALLOC, 4, 1 );
1563   meshC->setCoords( coords );
1564   coords->decrRef();
1565
1566   MEDCouplingUMesh * meshU = buildCU1DMesh_U();
1567
1568   MEDCouplingNormalizedCartesianMesh<1>      sourceWrapper(meshC);
1569   MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(meshU);
1570   INTERP_KERNEL::InterpolationCU myInterpolator;
1571   std::vector<std::map<mcIdType,double> > res;
1572   const double precis = 1e-13;
1573   myInterpolator.setPrecision(precis);
1574   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1575
1576 //   std::cout.precision(18);
1577 //   for ( int i = 0; i < (int)res.size(); ++i )
1578 //     for ( std::map<int,double>::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v)
1579 //     {
1580 //       std::cout << "CPPUNIT_ASSERT_DOUBLES_EQUAL( "<<s_v->second<<" ,res["<<i<<"]["<<s_v->first<<"],precis);"<<std::endl;
1581 //     }
1582
1583   double sum = sumAll(res);
1584   CPPUNIT_ASSERT_EQUAL(3,int( res.size()));
1585   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
1586   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[1][0],precis);
1587   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.33333333333333 ,res[1][1],precis);
1588   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.08333333333333 ,res[1][2],precis);
1589   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25000000000000 ,res[2][2],precis);
1590
1591   meshC->decrRef();
1592   meshU->decrRef();
1593 }
1594
1595 void MEDCouplingBasicsTestInterp::testInterpolationCU2D()
1596 {
1597   MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
1598   DataArrayDouble* coords = DataArrayDouble::New();
1599   double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
1600   coords->useArray( arr, /*ownership=*/false, DeallocType::CPP_DEALLOC, 4, 1 );
1601   meshC->setCoords( coords, coords );
1602   coords->decrRef();
1603
1604   MEDCouplingUMesh * meshU = buildCU2DMesh_U();
1605
1606   MEDCouplingNormalizedCartesianMesh<2>      sourceWrapper(meshC);
1607   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(meshU);
1608   INTERP_KERNEL::InterpolationCU myInterpolator;
1609   std::vector<std::map<mcIdType,double> > res;
1610   myInterpolator.setPrecision(1e-12);
1611   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1612
1613   const double precis = 1e-7;
1614   double sum = sumAll(res);
1615   CPPUNIT_ASSERT_EQUAL(5,int( res.size()));
1616   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
1617   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[0][0],precis);
1618   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][1],precis);
1619   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][3],precis);
1620   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[0][4],precis);
1621   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][3],precis);
1622   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[1][4],precis);
1623   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[1][6],precis);
1624   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][7],precis);
1625   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[2][4],precis);
1626   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][5],precis);
1627   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][7],precis);
1628   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[2][8],precis);
1629   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][1],precis);
1630   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[3][2],precis);
1631   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[3][4],precis);
1632   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][5],precis);
1633   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][1],precis);
1634   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0972222 ,res[4][2],precis);
1635   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][5],precis);
1636
1637   std::vector<std::map<int,double> > resRev;
1638   myInterpolator.interpolateMeshesRev(targetWrapper,sourceWrapper,resRev,"P0P0");
1639
1640   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][0] ,resRev[0][0],precis);
1641   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][1] ,resRev[1][0],precis);
1642   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][1] ,resRev[1][3],precis);
1643   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][1] ,resRev[1][4],precis);
1644   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][2] ,resRev[2][3],precis);
1645   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][2] ,resRev[2][4],precis);
1646   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][3] ,resRev[3][0],precis);
1647   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][3] ,resRev[3][1],precis);
1648   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][4] ,resRev[4][0],precis);
1649   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][4] ,resRev[4][1],precis);
1650   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][4] ,resRev[4][2],precis);
1651   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][4] ,resRev[4][3],precis);
1652   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][5] ,resRev[5][2],precis);
1653   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][5] ,resRev[5][3],precis);
1654   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][5] ,resRev[5][4],precis);
1655   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][6] ,resRev[6][1],precis);
1656   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][7] ,resRev[7][1],precis);
1657   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][7] ,resRev[7][2],precis);
1658   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][8] ,resRev[8][2],precis);
1659
1660   meshC->decrRef();
1661   meshU->decrRef();
1662 }
1663
1664 void MEDCouplingBasicsTestInterp::testInterpolationCU3D()
1665 {
1666   MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
1667   DataArrayDouble* coords = DataArrayDouble::New();
1668   double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
1669   coords->useArray( arr, /*ownership=*/false, DeallocType::CPP_DEALLOC, 4, 1 );
1670   meshC->setCoords( coords, coords, coords );
1671   coords->decrRef();
1672
1673   MEDCouplingUMesh * meshU = buildCU3DMesh_U();
1674
1675   MEDCouplingNormalizedCartesianMesh<3>      sourceWrapper(meshC);
1676   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(meshU);
1677   INTERP_KERNEL::InterpolationCU myInterpolator;
1678   std::vector<std::map<mcIdType,double> > res;
1679   const double precis = 1e-13;
1680   myInterpolator.setPrecision(precis);
1681   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
1682
1683   double sum = sumAll(res);
1684   CPPUNIT_ASSERT_EQUAL(8,int( res.size()));
1685   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
1686   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02700000000000 ,res[0][0],precis);
1687   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[1][0],precis);
1688   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[1][1],precis);
1689   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[1][2],precis);
1690   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00300000000000 ,res[2][0],precis);
1691   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][3],precis);
1692   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][6],precis);
1693   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[3][0],precis);
1694   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][1],precis);
1695   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][2],precis);
1696   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][3],precis);
1697   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][4],precis);
1698   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][5],precis);
1699   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][6],precis);
1700   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][7],precis);
1701   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][8],precis);
1702   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[4][0],precis);
1703   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[4][9],precis);
1704   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[4][18],precis);
1705   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[5][0],precis);
1706   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][1],precis);
1707   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][2],precis);
1708   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][9],precis);
1709   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][10],precis);
1710   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][11],precis);
1711   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][18],precis);
1712   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][19],precis);
1713   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][20],precis);
1714   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[6][0],precis);
1715   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][3],precis);
1716   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][6],precis);
1717   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][9],precis);
1718   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][12],precis);
1719   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][15],precis);
1720   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][18],precis);
1721   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][21],precis);
1722   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][24],precis);
1723   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.7037037037e-05 ,res[7][0],precis);
1724   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][1],precis);
1725   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][2],precis);
1726   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][3],precis);
1727   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][4],precis);
1728   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][5],precis);
1729   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][6],precis);
1730   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][7],precis);
1731   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][8],precis);
1732   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][9],precis);
1733   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][10],precis);
1734   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][11],precis);
1735   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][12],precis);
1736   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][13],precis);
1737   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][14],precis);
1738   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][15],precis);
1739   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][16],precis);
1740   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][17],precis);
1741   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][18],precis);
1742   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][19],precis);
1743   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][20],precis);
1744   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][21],precis);
1745   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][22],precis);
1746   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][23],precis);
1747   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][24],precis);
1748   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][25],precis);
1749   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][26],precis);
1750
1751
1752   meshC->decrRef();
1753   meshU->decrRef();
1754 }
1755
1756 void MEDCouplingBasicsTestInterp::test2DInterpP0IntegralUniform()
1757 {
1758   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
1759   //
1760   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1761   INTERP_KERNEL::Interpolation2D myInterpolator;
1762   std::vector<std::map<mcIdType,double> > res;
1763   CPPUNIT_ASSERT_EQUAL(5,(int)myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
1764   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1765   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1766   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
1767   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
1768   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
1769   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
1770   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1771   res.clear();
1772   CPPUNIT_ASSERT_EQUAL(1,(int)myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
1773   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1774   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1775   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
1776   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
1777   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
1778   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][0],1e-12);
1779   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1780   res.clear();
1781   targetMesh->decrRef();
1782   //
1783   targetMesh=build2DTargetMeshPerm_1();
1784   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper2(targetMesh);
1785   INTERP_KERNEL::Interpolation2D myInterpolator2;
1786   CPPUNIT_ASSERT(myInterpolator2.getMeasureAbsStatus());
1787   CPPUNIT_ASSERT_EQUAL(5,(int)myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0"));
1788   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1789   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1790   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
1791   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
1792   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
1793   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
1794   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1795   res.clear();
1796   myInterpolator2.setMeasureAbsStatus(false);
1797   CPPUNIT_ASSERT(!myInterpolator2.getMeasureAbsStatus());
1798   CPPUNIT_ASSERT_EQUAL(5,(int)myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0"));
1799   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1800   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
1801   CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125,res[0][1],1e-12);
1802   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
1803   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
1804   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
1805   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,sumAll(res),1e-12);
1806   targetMesh->decrRef();
1807 }
1808
1809 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0IntegralUniform()
1810 {
1811   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
1812   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
1813   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
1814   std::vector<std::map<mcIdType,double> > res;
1815   CPPUNIT_ASSERT_EQUAL(5,(int)myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
1816   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1817   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
1818   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
1819   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][2],1e-12);
1820   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][3],1e-12);
1821   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][4],1e-12);
1822   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
1823   res.clear();
1824   CPPUNIT_ASSERT_EQUAL(1,(int)myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
1825   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1826   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
1827   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
1828   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
1829   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][0],1e-12);
1830   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][0],1e-12);
1831   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
1832   targetMesh->decrRef();
1833 }
1834
1835 void MEDCouplingBasicsTestInterp::test3DInterpP0IntegralUniform()
1836 {
1837   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
1838   INTERP_KERNEL::Interpolation3D myInterpolator;
1839   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
1840   std::vector<std::map<mcIdType,double> > res;
1841   CPPUNIT_ASSERT_EQUAL(8,(int)myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
1842   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1843   CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
1844   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][1],1e-6);
1845   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][2],1e-6);
1846   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][3],1e-6);
1847   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][4],1e-6);
1848   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][5],1e-6);
1849   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][6],1e-6);
1850   CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[0][7],1e-6);
1851   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1852   res.clear();
1853   CPPUNIT_ASSERT_EQUAL(1,(int)myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
1854   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
1855   CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
1856   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[1][0],1e-6);
1857   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[2][0],1e-6);
1858   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[3][0],1e-6);
1859   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[4][0],1e-6);
1860   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[5][0],1e-6);
1861   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[6][0],1e-6);
1862   CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[7][0],1e-6);
1863   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1864   res.clear();
1865   targetMesh->decrRef();
1866 }
1867
1868 void MEDCouplingBasicsTestInterp::test2DInterpP1IntegralUniform()
1869 {
1870   MEDCouplingUMesh *targetMesh=build2DSourceMesh_1();
1871   //
1872   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1873   INTERP_KERNEL::Interpolation2D myInterpolator;
1874   std::vector<std::map<mcIdType,double> > res;
1875   CPPUNIT_ASSERT_EQUAL(4,(int)myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
1876   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1877   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
1878   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][1],1e-12);
1879   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][2],1e-12);
1880   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][3],1e-12);
1881   res.clear();
1882   CPPUNIT_ASSERT_EQUAL(1,(int)myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
1883   CPPUNIT_ASSERT_EQUAL(4,(int)res.size());
1884   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
1885   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[1][0],1e-12);
1886   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[2][0],1e-12);
1887   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[3][0],1e-12);
1888   res.clear();
1889   targetMesh->decrRef();
1890 }
1891
1892 void MEDCouplingBasicsTestInterp::test3DInterpP1IntegralUniform()
1893 {
1894   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
1895   //
1896   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(sourceMesh);
1897   INTERP_KERNEL::Interpolation3D myInterpolator;
1898   std::vector<std::map<mcIdType,double> > res;
1899   CPPUNIT_ASSERT_EQUAL(9,(int)myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
1900   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
1901   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
1902   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][1],1e-6);
1903   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][2],1e-6);
1904   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][3],1e-6);
1905   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][4],1e-6);
1906   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][5],1e-6);
1907   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][6],1e-6);
1908   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][7],1e-6);
1909   CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[0][8],1e-6);
1910   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1911   res.clear();
1912   CPPUNIT_ASSERT_EQUAL(1,(int)myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
1913   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
1914   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
1915   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[1][0],1e-6);
1916   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[2][0],1e-6);
1917   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[3][0],1e-6);
1918   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[4][0],1e-6);
1919   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[5][0],1e-6);
1920   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][0],1e-6);
1921   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][0],1e-6);
1922   CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[8][0],1e-6);
1923   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
1924   sourceMesh->decrRef();
1925 }
1926
1927 void MEDCouplingBasicsTestInterp::test2DInterpP1P0Bary_1()
1928 {
1929   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
1930   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
1931   //
1932   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
1933   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
1934   INTERP_KERNEL::Interpolation2D myInterpolator;
1935   std::vector<std::map<mcIdType,double> > res;
1936   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Barycentric,INTERP_KERNEL::BarycentricGeo2D};
1937   for(int i=0;i<2;i++)
1938     {
1939       myInterpolator.setPrecision(1e-12);
1940       myInterpolator.setIntersectionType(types[i]);
1941       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1942       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1943       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669,res[0][0],1e-12);
1944       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][1],1e-12);
1945       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][2],1e-12);
1946       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][3],1e-12);
1947       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12);
1948       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[1][1],1e-12);
1949       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[1][3],1e-12);
1950       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[2][0],1e-12);
1951       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[2][1],1e-12);
1952       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12);
1953       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][0],1e-12);
1954       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[3][2],1e-12);
1955       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][3],1e-12);
1956       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[4][0],1e-12);
1957       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][1],1e-12);
1958       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][2],1e-12);
1959       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][3],1e-12);
1960       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
1961       res.clear();
1962     }
1963   //clean up
1964   sourceMesh->decrRef();
1965   targetMesh->decrRef();
1966 }
1967
1968 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0Bary_1()
1969 {
1970   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
1971   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
1972   //
1973   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
1974   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
1975   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
1976   std::vector<std::map<mcIdType,double> > res;
1977   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Barycentric,INTERP_KERNEL::BarycentricGeo2D};
1978   for(int i=0;i<2;i++)
1979     {
1980       myInterpolator.setPrecision(1e-12);
1981       myInterpolator.setIntersectionType(types[i]);
1982       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
1983       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
1984       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669*sqrt(2.),res[0][0],1e-12);
1985       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][1],1e-12);
1986       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][2],1e-12);
1987       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][3],1e-12);
1988       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12);
1989       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[1][1],1e-12);
1990       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[1][3],1e-12);
1991       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[2][0],1e-12);
1992       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[2][1],1e-12);
1993       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12);
1994       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][0],1e-12);
1995       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[3][2],1e-12);
1996       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][3],1e-12);
1997       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[4][0],1e-12);
1998       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][1],1e-12);
1999       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][2],1e-12);
2000       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][3],1e-12);
2001       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
2002       res.clear();
2003     }
2004   //clean up
2005   sourceMesh->decrRef();
2006   targetMesh->decrRef();
2007 }
2008
2009 #include <iomanip>
2010 void MEDCouplingBasicsTestInterp::test3DInterpP1P0Bary_1()
2011 {
2012   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
2013   MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
2014   //
2015   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
2016   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
2017   INTERP_KERNEL::Interpolation3D myInterpolator;
2018   std::vector<std::map<mcIdType,double> > res;
2019   myInterpolator.setPrecision(1e-12);
2020   myInterpolator.setIntersectionType(INTERP_KERNEL::Barycentric);
2021   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
2022   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
2023
2024   double res3D[5][28]={{104166.66658918398, 885416.666685817763, 135416.666666666541, 36458.3333333335031, 31249.9999999999018, 145833.333333333256, 41666.6666666667516, 124999.999999999971, 177083.333326388849, 0.0, 31249.9999999999636, 0.0, 41666.666620792399, 159722.22229009436, 0.0, 0.0, 41666.6666631944681, 125000, 43499.2283723790752, 164351.851924000395, 36458.3333372396883, 0.0, 0.0, 125000.000001736029, 34722.2221800900952, 13599.5370788455439, 0.0, 167438.27159690368},
2025                        {0.0, 41666.6664479170649, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 125000.000161457952, 0.0, 0.0, 0.0, 0.0, 111111.11112005508, 0.0, 0.0, 291666.666656249959, 41666.6666666666933, 6944.4444415638809, 270833.333520485845, 0.0, 0.0, 124999.999989583303, 41666.6665798612958, 20833.3333186342825, 145833.333354303701, 83333.3333263888198, 27777.7777501651799},
2026                        {0.0, 93750.0000000000728, 125000.000000000058, 0.0, 0.0, 72916.666666666526, 291666.666666666628, 41666.6666666667152, 197916.66666666657, 166666.666666666802, 218750.000000000116, 41666.6666666665697, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666861, 0.0, 0.0, 0.0, 0.0, 0.0, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0},
2027                        {72916.6666484848247, 82465.2777799315081, 0.0, 0.0, 217447.916666666686, 197916.666666666802, 0.0, 41666.6666666666715, 0.0, 0.0, 0.0, 0.0, 290364.583310396119, 125000.000018181803, 41666.6666666666351, 166666.666666666599, 0.0, 41666.6666666665551, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 27777.7777734705051, 0.0, 0.0, 27777.7778028684952},
2028                        {72916.6666461071727, 172309.027782170655, 70312.5000000000437, 253906.250000000029, 0.0, 0.0, 0.0, 41666.666666666657, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 258246.527775988478, 71180.5555571812583, 253906.250006944378, 41666.6666666666861, 0.0, 41666.6666649305407, 20833.3333186342534, 6944.44445267237552, 0.0, 27777.7777953707919}};
2029
2030   double sum = 0;
2031   int i=0;
2032   for(std::vector<std::map<mcIdType,double> >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++)
2033     {
2034       for(int j=0;j<28;j++)
2035         {
2036           std::map<mcIdType,double>::const_iterator iter2=(*iter1).find(j);
2037           if(iter2!=(*iter1).end())
2038             {
2039               sum += iter2->second;
2040               CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5);
2041             }
2042           else
2043             {
2044               CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14);
2045             }
2046         }
2047     }
2048   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5);
2049   //clean up
2050   sourceMesh->decrRef();
2051   targetMesh->decrRef();
2052 }
2053
2054 void MEDCouplingBasicsTestInterp::test3DTo1DInterpP0P0PL_1()
2055 {
2056   MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
2057   MEDCouplingUMesh *targetMesh=build1DTargetMesh_1();
2058   //
2059   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
2060   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
2061   INTERP_KERNEL::Interpolation3D myInterpolator;
2062   std::vector<std::map<mcIdType,double> > res;
2063   myInterpolator.setPrecision(1e-12);
2064   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
2065   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2066   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
2067   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
2068   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][4],1e-12);
2069   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][1],1e-12);
2070   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][5],1e-12);
2071   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][2],1e-12);
2072   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][6],1e-12);
2073   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][3],1e-12);
2074   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][7],1e-12);
2075   CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,sumAll(res),1e-12);
2076   //
2077   sourceMesh->decrRef();
2078   targetMesh->decrRef();
2079 }
2080
2081 void MEDCouplingBasicsTestInterp::test1DInterp_1()
2082 {
2083   //      c1   c0    c2    - pay attention to cell order!
2084   // S: o---o------o---o
2085   // T:   o---o------o---o
2086   //      n0  n1     n2  n3
2087   //
2088   // ---+---+------+---+---> X
2089   //    0.  1.     3.  4.   
2090   MEDCouplingUMesh *sourceMesh=build1DMesh(0);
2091   MEDCouplingUMesh *targetMesh=build1DMesh(0.5);
2092   //
2093   MEDCouplingNormalizedUnstructuredMesh<1,1> sourceWrapper(sourceMesh);
2094   MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(targetMesh);
2095   INTERP_KERNEL::Interpolation1D myInterpolator;
2096   const double precis = 1e-13;
2097   myInterpolator.setPrecision(precis);
2098
2099   // P0P0
2100   std::vector<std::map<mcIdType,double> > res;
2101   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2102   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2103   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][0], precis);
2104   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][2], precis);
2105   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][0], precis);
2106   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis);
2107   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][2], precis);
2108   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2109
2110   // P1P0
2111   res.clear();
2112   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
2113   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2114   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
2115   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][2], precis);
2116   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis);
2117   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis);
2118   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2119
2120   // P0P1
2121   res.clear();
2122   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
2123
2124   CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) );
2125   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
2126   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[1][0], precis);
2127   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][0], precis);
2128   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis);
2129   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2130
2131   // P1P1
2132   res.clear();
2133   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
2134   CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) );
2135   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
2136   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis);
2137   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][2], precis);
2138   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis);
2139   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis);
2140   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
2141
2142   sourceMesh->decrRef();
2143   targetMesh->decrRef();
2144 }
2145
2146 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P0_1()
2147 {
2148   // coincident meshes
2149   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2150   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2151   //
2152   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2153   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2154   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2155   const double precis = 1e-13;
2156   myInterpolator.setPrecision(precis);
2157   std::vector<std::map<mcIdType,double> > res;
2158   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2159
2160   CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
2161   CPPUNIT_ASSERT_DOUBLES_EQUAL( sqrt(2.),res[0][0], precis);
2162   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., res[1][1], precis);
2163   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.+sqrt(2.), sumAll(res), precis);
2164
2165   sourceMesh->decrRef();
2166   targetMesh->decrRef();
2167 }
2168
2169 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P0_2()
2170 {
2171   // equal meshes shifted one from another along X by 0.5
2172   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0.5,0);
2173   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2174   //
2175   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2176   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2177   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2178   const double precis = 1e-13;
2179   myInterpolator.setPrecision(precis);
2180   myInterpolator.setMedianPlane(1.);// median line on target
2181   std::vector<std::map<mcIdType,double> > res;
2182   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
2183
2184   double tolInters = myInterpolator.getBoundingBoxAdjustmentAbs() * sqrt(2.);
2185   CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
2186   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0,res[0][0], precis);
2187   CPPUNIT_ASSERT_DOUBLES_EQUAL( tolInters,res[0][1], precis);
2188   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis);
2189   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5+tolInters, sumAll(res), precis);
2190
2191   sourceMesh->decrRef();
2192   targetMesh->decrRef();
2193 }
2194
2195 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P1_1()
2196 {
2197   // coincident meshes
2198   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2199   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2200   //
2201   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2202   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2203   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2204   const double precis = 1e-13;
2205   myInterpolator.setPrecision(precis);
2206   std::vector<std::map<mcIdType,double> > res;
2207   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
2208
2209   const double len1 = 1., len0 = sqrt(2.);
2210   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2211   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][1], precis);
2212   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[1][0], precis);
2213   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis);
2214   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][0], precis);
2215   CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
2216
2217   sourceMesh->decrRef();
2218   targetMesh->decrRef();
2219 }
2220
2221 void MEDCouplingBasicsTestInterp::test2DCurveInterpP1P0_1()
2222 {
2223   // coincident meshes
2224   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2225   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2226   //
2227   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2228   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2229   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2230   const double precis = 1e-13;
2231   myInterpolator.setPrecision(precis);
2232   std::vector<std::map<mcIdType,double> > res;
2233   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
2234
2235   const double len1 = 1., len0 = sqrt(2.);
2236   CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
2237   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][0], precis);
2238   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][1], precis);
2239   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis);
2240   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][2], precis);
2241   CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
2242
2243   sourceMesh->decrRef();
2244   targetMesh->decrRef();
2245 }
2246
2247 void MEDCouplingBasicsTestInterp::test2DCurveInterpP1P1_1()
2248 {
2249   // coincident meshes
2250   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
2251   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
2252   //
2253   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
2254   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
2255   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
2256   const double precis = 1e-13;
2257   myInterpolator.setPrecision(precis);
2258   std::vector<std::map<mcIdType,double> > res;
2259   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
2260
2261   const double len1 = 1., len0 = sqrt(2.);
2262   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
2263   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][0], precis);
2264   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*(len0+len1), res[1][1], precis);
2265   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][2], precis);
2266   CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
2267
2268   sourceMesh->decrRef();
2269   targetMesh->decrRef();
2270 }
2271
2272 void MEDCouplingBasicsTestInterp::test2D1DBasicInterpP0P0()
2273 {
2274   MEDCouplingUMesh *sourceMesh=build2D1DSourceMesh();
2275   MEDCouplingUMesh *targetMesh=build2D1DTargetMesh();
2276
2277   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
2278   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
2279   INTERP_KERNEL::Interpolation2D1D myInterpolator;
2280   myInterpolator.setPrecision(1e-12);
2281   myInterpolator.setIntersectionType(INTERP_KERNEL::Geometric2D);
2282   std::vector<std::map<int,double> > matrix;
2283   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
2284
2285   CPPUNIT_ASSERT_EQUAL(2,(int)matrix.size());
2286
2287   CPPUNIT_ASSERT_DOUBLES_EQUAL(3., matrix[0][0],1e-12);
2288   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][1],1e-12);
2289   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][2],1e-12);
2290   CPPUNIT_ASSERT_DOUBLES_EQUAL(8., matrix[0][3],1e-12);
2291   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][4],1e-12);
2292   CPPUNIT_ASSERT_DOUBLES_EQUAL(5., matrix[0][5],1e-12);
2293   CPPUNIT_ASSERT_DOUBLES_EQUAL(6., matrix[0][6],1e-12);
2294   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][7],1e-12);
2295
2296   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][0],1e-12);
2297   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][1],1e-12);
2298   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][2],1e-12);
2299   CPPUNIT_ASSERT_DOUBLES_EQUAL(4., matrix[1][3],1e-12);
2300   CPPUNIT_ASSERT_DOUBLES_EQUAL(5., matrix[1][4],1e-12);
2301   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][5],1e-12);
2302   CPPUNIT_ASSERT_DOUBLES_EQUAL(6., matrix[1][6],1e-12);
2303   CPPUNIT_ASSERT_DOUBLES_EQUAL(3., matrix[1][7],1e-12);
2304
2305   INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
2306   CPPUNIT_ASSERT_EQUAL(1,(int)duplicateFaces.size());
2307
2308   INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType correctDuplicateFaces;
2309   std::set<mcIdType> face6;
2310   face6.insert(0);
2311   face6.insert(1);
2312   correctDuplicateFaces[6] = face6;
2313
2314   CPPUNIT_ASSERT(correctDuplicateFaces == duplicateFaces);
2315
2316   //clean up
2317   sourceMesh->decrRef();
2318   targetMesh->decrRef();
2319 }
2320
2321 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_1()
2322 {
2323   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh();
2324   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
2325   test2D1DMeshesIntersection(sourceMesh, targetMesh, 16., 0, 4);
2326 }
2327
2328 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_2()
2329 {
2330   const double shiftX = 3.;
2331   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2332   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
2333   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 16., 4, 2 * 4);
2334 }
2335
2336 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_3()
2337 {
2338   const double shiftX = 1.5;
2339   const double inclinationX = 3.;
2340   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2341   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
2342   test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 0, 4);
2343 }
2344
2345 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_4()
2346 {
2347   const double shiftX = 3.;
2348   const double inclinationX = 3.;
2349   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2350   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
2351   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 20., 4, 2 * 4);
2352 }
2353
2354 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_5()
2355 {
2356   const double shiftX = 9.;
2357   const double inclinationX = 3.;
2358   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2359   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
2360   test2D1DMeshesIntersection(sourceMesh, targetMesh, 12., 0, 3);
2361 }
2362
2363 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_6()
2364 {
2365   const double shiftX = 9.;
2366   const double inclinationX = 3.;
2367   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2368   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
2369   test2D1DMeshesIntersection(sourceMesh, targetMesh, 10., 0, 2);
2370 }
2371
2372 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_1()
2373 {
2374   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh();
2375   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
2376   test2D1DMeshesIntersection(sourceMesh, targetMesh, 16., 0, 4);
2377 }
2378
2379 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_2()
2380 {
2381   const double shiftX = 3.;
2382   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2383   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
2384   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 16., 4, 2 * 4);
2385 }
2386
2387 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_3()
2388 {
2389   const double shiftX = 1.5;
2390   const double inclinationX = 3.;
2391   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2392   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
2393   test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 0, 8);
2394 }
2395
2396 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_4()
2397 {
2398   const double shiftX = 3.;
2399   const double inclinationX = 3.;
2400   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2401   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
2402   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 20., 4, 8);
2403 }
2404
2405 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_5()
2406 {
2407   const double shiftX = 9.;
2408   const double inclinationX = 3.;
2409   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
2410   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
2411   test2D1DMeshesIntersection(sourceMesh, targetMesh, 12., 0, 6);
2412 }
2413
2414 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_6()
2415 {
2416   const double shiftX = 9.;
2417   const double inclinationX = 3.;
2418   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
2419   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
2420   test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 2, 4);
2421 }
2422
2423 void MEDCouplingBasicsTestInterp::test3D2DBasicInterpP0P0()
2424 {
2425   MEDCouplingUMesh *sourceMesh=build3D2DSourceMesh();
2426   MEDCouplingUMesh *targetMesh=build3D2DTargetMesh();
2427
2428   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
2429   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
2430   INTERP_KERNEL::Interpolation2D3D myInterpolator;
2431   myInterpolator.setPrecision(1e-12);
2432   std::vector<std::map<int,double> > matrix;
2433   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
2434   for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i )
2435   {
2436     myInterpolator.setSplittingPolicy( sp[i] );
2437     matrix.clear();
2438     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
2439
2440     CPPUNIT_ASSERT_EQUAL(3,(int)matrix.size());
2441
2442     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[0][0],1e-12);
2443     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[0][1],1e-12);
2444     CPPUNIT_ASSERT_DOUBLES_EQUAL(40.        ,matrix[0][2],1e-12);
2445     CPPUNIT_ASSERT_DOUBLES_EQUAL(8.         ,matrix[0][3],1e-12);
2446     CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5        ,matrix[0][4],1e-12);
2447     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[0][5],1e-12);
2448     CPPUNIT_ASSERT_DOUBLES_EQUAL(32.        ,matrix[0][6],1e-12);
2449
2450     CPPUNIT_ASSERT_DOUBLES_EQUAL(8.*sqrt(3.),matrix[1][0],1e-12);
2451     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[1][1],1e-12);
2452     CPPUNIT_ASSERT_DOUBLES_EQUAL(40.        ,matrix[1][2],1e-12);
2453     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[1][3],1e-12);
2454     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[1][4],1e-12);
2455     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[1][5],1e-12);
2456     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[1][6],1e-12);
2457
2458     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][0],1e-12);
2459     CPPUNIT_ASSERT_DOUBLES_EQUAL(32.        ,matrix[2][1],1e-12);
2460     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][2],1e-12);
2461     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][3],1e-12);
2462     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][4],1e-12);
2463     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[2][5],1e-12);
2464     CPPUNIT_ASSERT_DOUBLES_EQUAL(112.       ,matrix[2][6],1e-12);
2465
2466     INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
2467     CPPUNIT_ASSERT_EQUAL(3,(int)duplicateFaces.size());
2468
2469     INTERP_KERNEL::Interpolation2D3D::DuplicateFacesType correctDuplicateFaces;
2470     std::set<mcIdType> face2;
2471     face2.insert(0);
2472     face2.insert(1);
2473     correctDuplicateFaces[2] = face2;
2474     std::set<mcIdType> face5;
2475     face5.insert(1);
2476     face5.insert(2);
2477     correctDuplicateFaces[5] = face5;
2478     std::set<mcIdType> face6;
2479     face6.insert(0);
2480     face6.insert(1);
2481     face6.insert(2);
2482     correctDuplicateFaces[6] = face6;
2483
2484     CPPUNIT_ASSERT(correctDuplicateFaces == duplicateFaces);
2485   }
2486   //clean up
2487   sourceMesh->decrRef();
2488   targetMesh->decrRef();
2489 }
2490
2491 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_1()
2492 {
2493   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh();
2494   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2495   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 20);
2496 }
2497
2498 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_2()
2499 {
2500   const double shiftX = 3.;
2501   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2502   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2503   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 20, 2 * 20);
2504 }
2505
2506 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_3()
2507 {
2508   const double shiftX = 1.5;
2509   const double inclinationX = 3.;
2510   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2511   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2512   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 20);
2513 }
2514
2515 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_4()
2516 {
2517   const double shiftX = 3.;
2518   const double inclinationX = 3.;
2519   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2520   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2521   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 20, 2 * 20);
2522 }
2523
2524 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_5()
2525 {
2526   const double shiftX = 9.;
2527   const double inclinationX = 3.;
2528   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2529   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2530   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 15);
2531 }
2532
2533 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_6()
2534 {
2535   const double shiftX = 9.;
2536   const double inclinationX = 3.;
2537   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2538   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2539   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 10);
2540 }
2541
2542 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_1()
2543 {
2544   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh();
2545   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2546   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 40);
2547 }
2548
2549 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_2()
2550 {
2551   const double shiftX = 3.;
2552   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2553   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2554   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 40, 2 * 40);
2555 }
2556
2557 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_3()
2558 {
2559   const double shiftX = 1.5;
2560   const double inclinationX = 3.;
2561   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2562   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2563   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 40);
2564 }
2565
2566 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_4()
2567 {
2568   const double shiftX = 3.;
2569   const double inclinationX = 3.;
2570   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2571   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2572   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 40, 2 * 40);
2573 }
2574
2575 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_5()
2576 {
2577   const double shiftX = 9.;
2578   const double inclinationX = 3.;
2579   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2580   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
2581   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 30);
2582 }
2583
2584 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_6()
2585 {
2586   const double shiftX = 9.;
2587   const double inclinationX = 3.;
2588   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2589   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
2590   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 20);
2591 }
2592
2593 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_1()
2594 {
2595   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh();
2596   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2597   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 20, 40);
2598 }
2599
2600 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_2()
2601 {
2602   const double shiftX = 3.;
2603   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2604   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2605   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 20, 2 * 40);
2606 }
2607
2608 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_3()
2609 {
2610   const double shiftX = 1.5;
2611   const double inclinationX = 3.;
2612   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2613   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2614   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 100);
2615 }
2616
2617 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_4()
2618 {
2619   const double shiftX = 3.;
2620   const double inclinationX = 3.;
2621   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2622   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2623   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 20, 2 * 40);
2624 }
2625
2626 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_5()
2627 {
2628   const double shiftX = 9.;
2629   const double inclinationX = 3.;
2630   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
2631   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2632   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 45);
2633 }
2634
2635 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_6()
2636 {
2637   const double shiftX = 9.;
2638   const double inclinationX = 3.;
2639   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
2640   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2641   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 30);
2642 }
2643
2644 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_1()
2645 {
2646   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh();
2647   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2648   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 40);
2649 }
2650
2651 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_2()
2652 {
2653   const double shiftX = 3.;
2654   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2655   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2656   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 40, 40 + 80);
2657 }
2658
2659 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_3()
2660 {
2661   const double shiftX = 1.5;
2662   const double inclinationX = 3.;
2663   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2664   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2665   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0);
2666 }
2667
2668 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_4()
2669 {
2670   const double shiftX = 3.;
2671   const double inclinationX = 3.;
2672   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2673   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2674   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 40, 40 + 80);
2675 }
2676
2677 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_5()
2678 {
2679   const double shiftX = 9.;
2680   const double inclinationX = 3.;
2681   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
2682   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
2683   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0);
2684 }
2685
2686 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_6()
2687 {
2688   const double shiftX = 9.;
2689   const double inclinationX = 3.;
2690   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
2691   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
2692   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0);
2693 }
2694