Back to index

salome-med  6.5.0
MEDCouplingBasicsTestInterp.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDCouplingBasicsTestInterp.hxx"
00021 #include "MEDCouplingUMesh.hxx"
00022 #include "MEDCouplingExtrudedMesh.hxx"
00023 #include "MEDCouplingFieldDouble.hxx"
00024 #include "MEDCouplingMemArray.hxx"
00025 #include "Interpolation2D.txx"
00026 #include "Interpolation3DSurf.hxx"
00027 #include "Interpolation3D.txx"
00028 #include "Interpolation2D1D.txx"
00029 #include "Interpolation3D2D.txx"
00030 #include "InterpolationCC.txx"
00031 #include "InterpolationCU.txx"
00032 #include "Interpolation2DCurve.hxx"
00033 #include "Interpolation1D.txx"
00034 
00035 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
00036 #include "MEDCouplingNormalizedCartesianMesh.txx"
00037 
00038 #include <cmath>
00039 #include <functional>
00040 
00041 using namespace ParaMEDMEM;
00042 
00043 typedef std::vector<std::map<int,double> > IntersectionMatrix;
00044 
00045 void MEDCouplingBasicsTestInterp::test2DInterpP0P0_1()
00046 {
00047   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00048   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00049   //
00050   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00051   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00052   INTERP_KERNEL::Interpolation2D myInterpolator;
00053   std::vector<std::map<int,double> > res;
00054   INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Convex, INTERP_KERNEL::Geometric2D};
00055   for(int i=0;i<3;i++)
00056     {
00057       myInterpolator.setPrecision(1e-12);
00058       myInterpolator.setIntersectionType(types[i]);
00059       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00060       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00061       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][0],1e-12);
00062       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
00063       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
00064       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
00065       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][1],1e-12);
00066       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][0],1e-12);
00067       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[4][1],1e-12);
00068       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
00069       res.clear();
00070     }
00071   //clean up
00072   sourceMesh->decrRef();
00073   targetMesh->decrRef();
00074 }
00075 
00076 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_1()
00077 {
00078   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00079   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00080   //
00081   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00082   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00083   INTERP_KERNEL::Interpolation2D myInterpolator;
00084   std::vector<std::map<int,double> > res;
00085   //
00086   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00087   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00088   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00089   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00090   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00091   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00092   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00093   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00094   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00095   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00096   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00097   //
00098   sourceMesh->decrRef();
00099   targetMesh->decrRef();
00100 }
00101 
00102 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_2()
00103 {
00104   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00105   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00106   //
00107   std::vector<int> cellsIds(targetMesh->getNumberOfCells());
00108   for(int i=0;i<targetMesh->getNumberOfCells();i++)
00109     cellsIds[i]=i;
00110   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
00111   //
00112   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00113   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00114   INTERP_KERNEL::Interpolation2D myInterpolator;
00115   std::vector<std::map<int,double> > res;
00116   //
00117   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00118   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00119   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00120   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00121   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00122   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00123   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00124   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00125   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00126   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00127   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00128   //
00129   sourceMesh->decrRef();
00130   targetMesh->decrRef();
00131 }
00132 
00133 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_3()
00134 {
00135   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00136   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00137   //
00138   std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
00139   for(int i=0;i<sourceMesh->getNumberOfCells();i++)
00140     cellsIds[i]=i;
00141   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
00142   //
00143   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00144   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00145   INTERP_KERNEL::Interpolation2D myInterpolator;
00146   std::vector<std::map<int,double> > res;
00147   //
00148   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00149   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00150   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00151   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00152   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00153   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00154   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00155   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00156   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00157   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00158   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00159   //
00160   sourceMesh->decrRef();
00161   targetMesh->decrRef();
00162 }
00163 
00164 void MEDCouplingBasicsTestInterp::test2DInterpP0P0PL_4()
00165 {
00166   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00167   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00168   //
00169   std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
00170   for(int i=0;i<sourceMesh->getNumberOfCells();i++)
00171     cellsIds[i]=i;
00172   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
00173   cellsIds.resize(targetMesh->getNumberOfCells());
00174   for(int i=0;i<targetMesh->getNumberOfCells();i++)
00175     cellsIds[i]=i;
00176   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
00177   //
00178   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00179   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00180   INTERP_KERNEL::Interpolation2D myInterpolator;
00181   std::vector<std::map<int,double> > res;
00182   //
00183   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00184   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00185   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00186   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00187   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00188   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00189   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00190   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00191   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00192   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00193   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00194   //
00195   sourceMesh->decrRef();
00196   targetMesh->decrRef();
00197 }
00198 
00199 void MEDCouplingBasicsTestInterp::test2DInterpP0P1_1()
00200 {
00201   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00202   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00203   //
00204   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00205   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00206   INTERP_KERNEL::Interpolation2D myInterpolator;
00207   std::vector<std::map<int,double> > res;
00208   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
00209   for(int i=0;i<2;i++)
00210     {
00211       myInterpolator.setPrecision(1e-12);
00212       myInterpolator.setIntersectionType(types[i]);
00213       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
00214       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00215       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][0],1e-12);
00216       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][1],1e-12);
00217       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
00218       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[2][0],1e-12);
00219       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[3][1],1e-12);
00220       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][0],1e-12);
00221       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][1],1e-12);
00222       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[5][0],1e-12);
00223       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329,res[6][1],1e-12);
00224       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[7][1],1e-12);
00225       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][0],1e-12);
00226       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[8][1],1e-12);
00227       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,sumAll(res),1e-12);
00228       res.clear();
00229     }
00230   //clean up
00231   sourceMesh->decrRef();
00232   targetMesh->decrRef();
00233 }
00234 
00235 void MEDCouplingBasicsTestInterp::test2DInterpP0P1PL_1()
00236 {
00237   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00238   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00239   //
00240   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00241   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00242   INTERP_KERNEL::Interpolation2D myInterpolator;
00243   std::vector<std::map<int,double> > res;
00244   myInterpolator.setPrecision(1e-12);
00245   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00246   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
00247   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00248   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00249   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00250   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00251   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00252   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00253   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00254   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00255   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
00256   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
00257   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
00258   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
00259   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
00260   CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
00261   res.clear();
00262   //clean up
00263   sourceMesh->decrRef();
00264   targetMesh->decrRef();
00265 }
00266 
00267 void MEDCouplingBasicsTestInterp::test2DInterpP0P1PL_2()
00268 {
00269   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00270   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00271   //
00272   std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
00273   for(int i=0;i<sourceMesh->getNumberOfCells();i++)
00274     cellsIds[i]=i;
00275   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
00276   //
00277   cellsIds.resize(targetMesh->getNumberOfCells());
00278   for(int i=0;i<targetMesh->getNumberOfCells();i++)
00279     cellsIds[i]=i;
00280   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
00281   //
00282   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00283   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00284   INTERP_KERNEL::Interpolation2D myInterpolator;
00285   std::vector<std::map<int,double> > res;
00286   myInterpolator.setPrecision(1e-12);
00287   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00288   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
00289   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00290   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00291   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00292   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00293   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00294   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00295   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00296   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00297   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
00298   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
00299   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
00300   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
00301   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
00302   CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
00303   res.clear();
00304   //clean up
00305   sourceMesh->decrRef();
00306   targetMesh->decrRef();
00307 }
00308 
00309 void MEDCouplingBasicsTestInterp::test2DInterpP1P0_1()
00310 {
00311   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00312   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00313   //
00314   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00315   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00316   INTERP_KERNEL::Interpolation2D myInterpolator;
00317   std::vector<std::map<int,double> > res;
00318   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
00319   for(int i=0;i<2;i++)
00320     {
00321       myInterpolator.setPrecision(1e-12);
00322       myInterpolator.setIntersectionType(types[i]);
00323       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
00324       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00325       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
00326       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12);
00327       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][0],1e-12);
00328       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[1][1],1e-12);
00329       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333,res[2][1],1e-12);
00330       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667,res[3][2],1e-12);
00331       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12);
00332       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[3][3],1e-12);
00333       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][3],1e-12);
00334       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
00335       res.clear();
00336     }
00337   //clean up
00338   sourceMesh->decrRef();
00339   targetMesh->decrRef();
00340 }
00341 
00342 void MEDCouplingBasicsTestInterp::test2DInterpP1P0PL_1()
00343 {
00344   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00345   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00346   //
00347   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00348   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00349   INTERP_KERNEL::Interpolation2D myInterpolator;
00350   std::vector<std::map<int,double> > res;
00351   myInterpolator.setPrecision(1e-12);
00352   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00353   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
00354   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00355   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
00356   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
00357   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
00358   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
00359   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
00360   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
00361   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
00362   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
00363   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
00364   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
00365   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
00366   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
00367   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
00368   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
00369   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
00370   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
00371   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
00372   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00373   res.clear();
00374   //clean up
00375   sourceMesh->decrRef();
00376   targetMesh->decrRef();
00377 }
00378 
00379 void MEDCouplingBasicsTestInterp::test2DInterpP1P0PL_2()
00380 {
00381   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00382   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00383   //
00384   std::vector<int >cellsIds(targetMesh->getNumberOfCells());
00385   for(int i=0;i<targetMesh->getNumberOfCells();i++)
00386     cellsIds[i]=i;
00387   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
00388   //
00389   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00390   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00391   INTERP_KERNEL::Interpolation2D myInterpolator;
00392   std::vector<std::map<int,double> > res;
00393   myInterpolator.setPrecision(1e-12);
00394   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00395   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
00396   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00397   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
00398   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
00399   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
00400   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
00401   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
00402   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
00403   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
00404   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
00405   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
00406   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
00407   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
00408   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
00409   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
00410   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
00411   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
00412   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
00413   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
00414   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00415   res.clear();
00416   //clean up
00417   sourceMesh->decrRef();
00418   targetMesh->decrRef();
00419 }
00420 
00421 void MEDCouplingBasicsTestInterp::test2DInterpP1P1_1()
00422 {
00423   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00424   MEDCouplingUMesh *targetMesh=build2DTargetMesh_2();
00425   //
00426   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00427   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00428   INTERP_KERNEL::Interpolation2D myInterpolator;
00429   std::vector<std::map<int,double> > res;
00430   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
00431   for(int i=0;i<2;i++)
00432     {
00433       myInterpolator.setPrecision(1e-12);
00434       myInterpolator.setIntersectionType(types[i]);
00435       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
00436       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00437       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[0][0],1.e-12);
00438       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[1][0],1.e-12);
00439       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[1][1],1.e-12);
00440       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334,res[2][1],1.e-12);
00441       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665,res[3][0],1.e-12);
00442       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668,res[3][2],1.e-12);
00443       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666,res[4][0],1.e-12);
00444       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][1],1.e-12);
00445       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999,res[4][2],1.e-12);
00446       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999,res[4][3],1.e-12);
00447       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666,res[5][1],1.e-12);
00448       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333,res[5][3],1.e-12);
00449       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333,res[6][2],1.e-12);
00450       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667,res[7][2],1.e-12);
00451       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331,res[7][3],1.e-12);
00452       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668,res[8][3],1.e-12);
00453       res.clear();
00454     }
00455   //clean up
00456   sourceMesh->decrRef();
00457   targetMesh->decrRef();
00458 }
00459 
00460 void MEDCouplingBasicsTestInterp::test2DInterpP1P1PL_1()
00461 {
00462   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
00463   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
00464   //
00465   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
00466   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
00467   INTERP_KERNEL::Interpolation2D myInterpolator;
00468   std::vector<std::map<int,double> > res;
00469   myInterpolator.setPrecision(1e-12);
00470   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00471   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
00472   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00473   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12);
00474   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12);
00475   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12);
00476   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12);
00477   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12);
00478   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12);
00479   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12);
00480   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12);
00481   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12);
00482   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12);
00483   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12);
00484   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12);
00485   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12);
00486   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12);
00487   CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12);
00488   res.clear();
00489   //clean up
00490   sourceMesh->decrRef();
00491   targetMesh->decrRef();
00492 }
00493 
00494 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_1()
00495 {
00496   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00497   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
00498   //
00499   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00500   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00501   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00502   std::vector<std::map<int,double> > res;
00503   INTERP_KERNEL::IntersectionType types[3]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
00504   for(int i=0;i<2;i++)
00505     {
00506       myInterpolator.setPrecision(1e-12);
00507       myInterpolator.setIntersectionType(types[i]);
00508       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00509       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00510       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
00511       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
00512       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
00513       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
00514       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
00515       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
00516       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
00517       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
00518       res.clear();
00519     }
00520   //clean up
00521   sourceMesh->decrRef();
00522   targetMesh->decrRef();
00523 }
00524 
00525 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0PL_1()
00526 {
00527   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00528   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
00529   //
00530   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00531   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00532   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00533   std::vector<std::map<int,double> > res;
00534   myInterpolator.setPrecision(1e-12);
00535   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00536   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00537   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00538   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00539   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00540   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00541   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00542   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00543   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00544   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00545   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00546   res.clear();
00547   //clean up
00548   sourceMesh->decrRef();
00549   targetMesh->decrRef();
00550 }
00551 
00552 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P1_1()
00553 {
00554   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00555   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
00556   //
00557   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00558   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00559   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00560   std::vector<std::map<int,double> > res;
00561   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
00562   for(int i=0;i<2;i++)
00563     {
00564       myInterpolator.setPrecision(1e-12);
00565       myInterpolator.setIntersectionType(types[i]);
00566       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
00567       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00568       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][0],1e-12);
00569       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][1],1e-12);
00570       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
00571       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[2][0],1e-12);
00572       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[3][1],1e-12);
00573       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][0],1e-12);
00574       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][1],1e-12);
00575       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[5][0],1e-12);
00576       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333329*sqrt(2.),res[6][1],1e-12);
00577       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[7][1],1e-12);
00578       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][0],1e-12);
00579       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[8][1],1e-12);
00580       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25*sqrt(2.),sumAll(res),1e-12);
00581       res.clear();
00582     }
00583   //clean up
00584   sourceMesh->decrRef();
00585   targetMesh->decrRef();
00586 }
00587 
00588 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P1PL_1()
00589 {
00590   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00591   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
00592   //
00593   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00594   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00595   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00596   std::vector<std::map<int,double> > res;
00597   myInterpolator.setPrecision(1e-12);
00598   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00599   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
00600   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00601   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
00602   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12);
00603   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
00604   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
00605   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12);
00606   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
00607   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12);
00608   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][0],1e-12);
00609   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][1],1e-12);
00610   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
00611   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][0],1e-12);
00612   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][1],1e-12);
00613   CPPUNIT_ASSERT_DOUBLES_EQUAL(12.,sumAll(res),1e-12);
00614   res.clear();
00615   //clean up
00616   sourceMesh->decrRef();
00617   targetMesh->decrRef();
00618 }
00619 
00620 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0_1()
00621 {
00622   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00623   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
00624   //
00625   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00626   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00627   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00628   std::vector<std::map<int,double> > res;
00629   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
00630   for(int i=0;i<2;i++)
00631     {
00632       myInterpolator.setPrecision(1e-12);
00633       myInterpolator.setIntersectionType(types[i]);
00634       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
00635       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00636       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
00637       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12);
00638       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][0],1e-12);
00639       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[1][1],1e-12);
00640       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.083333333333333333*sqrt(2.),res[2][1],1e-12);
00641       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666667*sqrt(2.),res[3][2],1e-12);
00642       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12);
00643       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[3][3],1e-12);
00644       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][3],1e-12);
00645       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
00646       res.clear();
00647     }
00648   //clean up
00649   sourceMesh->decrRef();
00650   targetMesh->decrRef();
00651 }
00652 
00653 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0PL_1()
00654 {
00655   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00656   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
00657   //
00658   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00659   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00660   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00661   std::vector<std::map<int,double> > res;
00662   myInterpolator.setPrecision(1e-12);
00663   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00664   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
00665   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00666   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[0][0],1e-12);
00667   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][1],1e-12);
00668   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[0][2],1e-12);
00669   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[0][3],1e-12);
00670   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[1][0],1e-12);
00671   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
00672   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[1][3],1e-12);
00673   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.166666666666666666,res[2][0],1e-12);
00674   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
00675   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333333333333333,res[2][3],1e-12);
00676   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
00677   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12);
00678   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][3],1e-12);
00679   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][0],1e-12);
00680   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][1],1e-12);
00681   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res[4][2],1e-12);
00682   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.5,res[4][3],1e-12);
00683   CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,sumAll(res),1e-12);
00684   res.clear();
00685   //clean up
00686   sourceMesh->decrRef();
00687   targetMesh->decrRef();
00688 }
00689 
00690 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P1_1()
00691 {
00692   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00693   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_2();
00694   //
00695   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00696   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00697   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00698   std::vector<std::map<int,double> > res;
00699   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
00700   for(int i=0;i<2;i++)
00701     {
00702       myInterpolator.setPrecision(1e-12);
00703       myInterpolator.setIntersectionType(types[i]);
00704       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
00705       CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00706       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[0][0],1.e-12);
00707       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[1][0],1.e-12);
00708       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[1][1],1.e-12);
00709       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333334*sqrt(2.),res[2][1],1.e-12);
00710       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.05416666666666665*sqrt(2.),res[3][0],1.e-12);
00711       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666668*sqrt(2.),res[3][2],1.e-12);
00712       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1416666666666666*sqrt(2.),res[4][0],1.e-12);
00713       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][1],1.e-12);
00714       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02499999999999999*sqrt(2.),res[4][2],1.e-12);
00715       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09999999999999999*sqrt(2.),res[4][3],1.e-12);
00716       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666666*sqrt(2.),res[5][1],1.e-12);
00717       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333333*sqrt(2.),res[5][3],1.e-12);
00718       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.08333333333333333*sqrt(2.),res[6][2],1.e-12);
00719       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.02916666666666667*sqrt(2.),res[7][2],1.e-12);
00720       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.09583333333333331*sqrt(2.),res[7][3],1.e-12);
00721       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04166666666666668*sqrt(2.),res[8][3],1.e-12);
00722       res.clear();
00723     }
00724   //
00725   sourceMesh->decrRef();
00726   targetMesh->decrRef();
00727 }
00728 
00729 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P1PL_1()
00730 {
00731   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00732   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
00733   //
00734   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00735   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00736   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00737   std::vector<std::map<int,double> > res;
00738   myInterpolator.setPrecision(1e-12);
00739   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
00740   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
00741   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
00742   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[0][0],1.e-12);
00743   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1.e-12);
00744   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1.e-12);
00745   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[2][1],1.e-12);
00746   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1.e-12);
00747   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1.e-12);
00748   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][0],1.e-12);
00749   CPPUNIT_ASSERT_DOUBLES_EQUAL(5.,res[4][3],1.e-12);
00750   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1.e-12);
00751   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][3],1.e-12);
00752   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][2],1.e-12);
00753   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1.e-12);
00754   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1.e-12);
00755   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[8][3],1.e-12);
00756   CPPUNIT_ASSERT_DOUBLES_EQUAL(25.,sumAll(res),1e-12);
00757   res.clear();
00758   //clean up
00759   sourceMesh->decrRef();
00760   targetMesh->decrRef();
00761 }
00762 
00763 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_2()
00764 {
00765   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
00766   MEDCouplingUMesh *targetMesh=build3DSurfTargetMeshPerm_1();
00767   //
00768   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00769   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00770   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00771   std::vector<std::map<int,double> > res;
00772   myInterpolator.setPrecision(1e-12);
00773   myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation);
00774   {
00775     myInterpolator.setOrientation(2);
00776     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00777     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00778     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
00779     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
00780     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
00781     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
00782     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
00783     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
00784     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
00785     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
00786     res.clear();
00787   }
00788   {
00789     myInterpolator.setOrientation(0);
00790     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00791     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00792     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
00793     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
00794     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
00795     CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125*sqrt(2.),res[2][0],1e-12);
00796     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
00797     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
00798     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
00799     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75*sqrt(2.),sumAll(res),1e-12);
00800     res.clear();
00801   }
00802   {
00803     myInterpolator.setOrientation(1);
00804     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00805     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00806     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][0],1e-12);
00807     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
00808     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
00809     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][1],1e-12);
00810     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][0],1e-12);
00811     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[4][1],1e-12);
00812     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.875*sqrt(2.),sumAll(res),1e-12);
00813     res.clear();
00814   }
00815   {
00816     myInterpolator.setOrientation(-1);
00817     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00818     CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
00819     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
00820     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),sumAll(res),1e-12);
00821     res.clear();
00822   }
00823   //clean up
00824   sourceMesh->decrRef();
00825   targetMesh->decrRef();
00826 }
00827 
00831 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0P0_3()
00832 {
00833   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
00834   std::vector<std::map<int,double> > res;
00835   double vecTrans[3]={0.,0.,1.e-10};
00836   double vec[3]={0.,-1.,0.};
00837   double pt[3]={-0.3,-0.3,5.e-11};
00838   const int N=32;
00839   const double deltaA=M_PI/N;
00840   myInterpolator.setPrecision(1e-12);
00841   myInterpolator.setIntersectionType(INTERP_KERNEL::Triangulation);
00842   myInterpolator.setMaxDistance3DSurfIntersect(1e-9);
00843   for(int i=0;i<N;i++)
00844     {
00845       res.clear();
00846       MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
00847       sourceMesh->rotate(pt,vec,i*deltaA);
00848       MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
00849       targetMesh->translate(vecTrans);
00850       targetMesh->rotate(pt,vec,i*deltaA);
00851       MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00852       MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00853       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00854       CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
00855       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
00856       sourceMesh->decrRef();
00857       targetMesh->decrRef();
00858     }
00859   //
00860   myInterpolator.setMaxDistance3DSurfIntersect(1e-11);
00861   for(int i=0;i<N;i++)
00862     {
00863       res.clear();
00864       MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
00865       sourceMesh->rotate(pt,vec,i*deltaA);
00866       MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
00867       targetMesh->translate(vecTrans);
00868       targetMesh->rotate(pt,vec,i*deltaA);
00869       MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
00870       MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
00871       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00872       CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
00873       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12);
00874       sourceMesh->decrRef();
00875       targetMesh->decrRef();
00876     }
00877   //
00878   res.clear();
00879   myInterpolator.setMaxDistance3DSurfIntersect(-1.);//unactivate fabien lookup
00880   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_2();
00881   MEDCouplingUMesh *targetMesh=build3DSurfSourceMesh_2();
00882   targetMesh->translate(vecTrans);
00883   myInterpolator.setBoundingBoxAdjustment(1e-11);
00884   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper0(sourceMesh);
00885   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper0(targetMesh);
00886   myInterpolator.interpolateMeshes(sourceWrapper0,targetWrapper0,res,"P0P0");
00887   CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
00888   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,sumAll(res),1e-12);
00889   sourceMesh->decrRef();
00890   targetMesh->decrRef();
00891   //
00892   res.clear();
00893   sourceMesh=build3DSurfSourceMesh_2();
00894   targetMesh=build3DSurfSourceMesh_2();
00895   targetMesh->translate(vecTrans);
00896   myInterpolator.setBoundingBoxAdjustment(1e-9);
00897   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper1(sourceMesh);
00898   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper1(targetMesh);
00899   myInterpolator.interpolateMeshes(sourceWrapper1,targetWrapper1,res,"P0P0");
00900   CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
00901   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
00902   sourceMesh->decrRef();
00903   targetMesh->decrRef();
00904   //keeping the same bbox adj == 1.e-11 but trying rotation
00905   res.clear();
00906   sourceMesh=build3DSurfSourceMesh_2();
00907   sourceMesh->rotate(pt,vec,M_PI/4.);
00908   targetMesh=build3DSurfSourceMesh_2();
00909   targetMesh->translate(vecTrans);
00910   targetMesh->rotate(pt,vec,M_PI/4.);
00911   myInterpolator.setBoundingBoxAdjustment(1e-11);
00912   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper2(sourceMesh);
00913   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper2(targetMesh);
00914   myInterpolator.interpolateMeshes(sourceWrapper2,targetWrapper2,res,"P0P0");
00915   CPPUNIT_ASSERT_EQUAL(2,(int)res.size());
00916   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
00917   sourceMesh->decrRef();
00918   targetMesh->decrRef();
00919 }
00920 
00921 void MEDCouplingBasicsTestInterp::test3DInterpP0P0_1()
00922 {
00923   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
00924   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
00925   //
00926   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
00927   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
00928   INTERP_KERNEL::Interpolation3D myInterpolator;
00929   std::vector<std::map<int,double> > res;
00930   myInterpolator.setPrecision(1e-12);
00931   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
00932   for ( int i = 0; i < 4; ++i )
00933   {
00934     myInterpolator.setSplittingPolicy( sp[i] );
00935     res.clear();
00936     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
00937     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
00938     CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7);
00939     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7);
00940     CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7);
00941     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7);
00942     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7);
00943     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7);
00944     CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7);
00945     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7);
00946     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7);
00947     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7);
00948     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7);
00949     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7);
00950     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7);
00951     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7);
00952     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7);
00953     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7);
00954     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7);
00955     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7);
00956     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7);
00957     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7);
00958     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7);
00959     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7);
00960     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7);
00961     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7);
00962     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7);
00963     CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7);
00964     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7);
00965     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7);
00966     CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7);
00967     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7);
00968     CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7);
00969     CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7);
00970     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7);
00971     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7);
00972     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7);
00973     CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7);
00974     CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7);
00975     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7);
00976     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7);
00977     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7);
00978     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7);
00979     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7);
00980     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7);
00981     CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7);
00982     CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7);
00983   }
00984   //clean up
00985   sourceMesh->decrRef();
00986   targetMesh->decrRef();
00987 }
00988 
00989 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_1()
00990 {
00991   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
00992   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
00993   //
00994   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
00995   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
00996   INTERP_KERNEL::Interpolation3D myInterpolator;
00997   std::vector<std::map<int,double> > res;
00998   myInterpolator.setPrecision(1e-12);
00999   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
01000   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01001   for ( int i = 0; i < 4; ++i )
01002   {
01003     myInterpolator.setSplittingPolicy( sp[i] );
01004     res.clear();
01005     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01006     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01007     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
01008     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
01009     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
01010     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
01011     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
01012     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
01013     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
01014     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
01015     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
01016     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
01017     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
01018     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
01019     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
01020     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
01021     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
01022     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
01023     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
01024     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
01025     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
01026     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
01027     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
01028     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
01029   }
01030   //clean up
01031   sourceMesh->decrRef();
01032   targetMesh->decrRef();
01033 }
01034 
01035 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_2()
01036 {
01037   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
01038   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
01039   std::vector<int> cellsIds(targetMesh->getNumberOfCells());
01040   for(int i=0;i<targetMesh->getNumberOfCells();i++)
01041     cellsIds[i]=i;
01042   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
01043   //
01044   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01045   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01046   INTERP_KERNEL::Interpolation3D myInterpolator;
01047   std::vector<std::map<int,double> > res;
01048   myInterpolator.setPrecision(1e-12);
01049   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
01050   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01051   for ( int i = 0; i < 4; ++i )
01052   {
01053     myInterpolator.setSplittingPolicy( sp[i] );
01054     res.clear();
01055     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01056     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01057     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
01058     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
01059     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
01060     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
01061     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
01062     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
01063     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
01064     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
01065     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
01066     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
01067     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
01068     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
01069     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
01070     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
01071     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
01072     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
01073     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
01074     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
01075     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
01076     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
01077     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
01078     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
01079   }
01080   //clean up
01081   sourceMesh->decrRef();
01082   targetMesh->decrRef();
01083 }
01084 
01085 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_3()
01086 {
01087   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
01088   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
01089   std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
01090   for(int i=0;i<sourceMesh->getNumberOfCells();i++)
01091     cellsIds[i]=i;
01092   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
01093   //
01094   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01095   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01096   INTERP_KERNEL::Interpolation3D myInterpolator;
01097   std::vector<std::map<int,double> > res;
01098   myInterpolator.setPrecision(1e-12);
01099   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
01100   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01101   for ( int i = 0; i < 4; ++i )
01102   {
01103     myInterpolator.setSplittingPolicy( sp[i] );
01104     res.clear();
01105     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01106     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01107     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
01108     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
01109     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
01110     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
01111     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
01112     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
01113     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
01114     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
01115     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
01116     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
01117     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
01118     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
01119     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
01120     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
01121     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
01122     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
01123     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
01124     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
01125     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
01126     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
01127     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
01128     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
01129   }
01130   //clean up
01131   sourceMesh->decrRef();
01132   targetMesh->decrRef();
01133 }
01134 
01135 void MEDCouplingBasicsTestInterp::test3DInterpP0P0PL_4()
01136 {
01137   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
01138   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
01139   std::vector<int> cellsIds(sourceMesh->getNumberOfCells());
01140   for(int i=0;i<sourceMesh->getNumberOfCells();i++)
01141     cellsIds[i]=i;
01142   sourceMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
01143   cellsIds.resize(targetMesh->getNumberOfCells());
01144   for(int j=0;j<targetMesh->getNumberOfCells();j++)
01145     cellsIds[j]=j;
01146   targetMesh->convertToPolyTypes(&cellsIds[0],&cellsIds[0]+cellsIds.size());
01147   //
01148   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01149   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01150   INTERP_KERNEL::Interpolation3D myInterpolator;
01151   std::vector<std::map<int,double> > res;
01152   myInterpolator.setPrecision(1e-12);
01153   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
01154   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01155   for ( int i = 0; i < 4; ++i )
01156   {
01157     myInterpolator.setSplittingPolicy( sp[i] );
01158     res.clear();
01159     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01160     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01161     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
01162     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
01163     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
01164     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
01165     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
01166     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
01167     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
01168     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
01169     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
01170     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
01171     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
01172     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
01173     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
01174     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
01175     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
01176     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
01177     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
01178     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
01179     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
01180     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
01181     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
01182     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
01183   }
01184   //clean up
01185   sourceMesh->decrRef();
01186   targetMesh->decrRef();
01187 }
01188 
01189 void MEDCouplingBasicsTestInterp::test3DInterpP0P1_1()
01190 {
01191   MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
01192   MEDCouplingUMesh *targetMesh=build3DSourceMesh_1();
01193   //
01194   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01195   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01196   INTERP_KERNEL::Interpolation3D myInterpolator;
01197   std::vector<std::map<int,double> > res;
01198   myInterpolator.setPrecision(1e-12);
01199   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01200   for ( int i = 0; i < 4; ++i )
01201   {
01202     myInterpolator.setSplittingPolicy( sp[i] );
01203     res.clear();
01204     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
01205     CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
01206     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7);
01207     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7);
01208     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7);
01209     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7);
01210     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7);
01211     CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
01212     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7);
01213     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7);
01214     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7);
01215     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7);
01216     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7);
01217     CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7);
01218     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7);
01219     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7);
01220     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7);
01221     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7);
01222     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7);
01223     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7);
01224     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7);
01225     CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7);
01226     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7);
01227     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
01228     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7);
01229     CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7);
01230     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7);
01231     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7);
01232     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7);
01233     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7);
01234     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7);
01235     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7);
01236     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7);
01237     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7);
01238     CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7);
01239   }
01240   //clean up
01241   sourceMesh->decrRef();
01242   targetMesh->decrRef();
01243 }
01244 
01245 void MEDCouplingBasicsTestInterp::test3DInterpP0P1PL_1()
01246 {
01247   MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
01248   MEDCouplingUMesh *targetMesh=build3DSourceMesh_1();
01249   //
01250   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01251   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01252   INTERP_KERNEL::Interpolation3D myInterpolator;
01253   std::vector<std::map<int,double> > res;
01254   myInterpolator.setPrecision(1e-12);
01255   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
01256   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01257   for ( int i = 0; i < 4; ++i )
01258   {
01259     myInterpolator.setSplittingPolicy( sp[i] );
01260     res.clear();
01261     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
01262     CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
01263     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12);
01264     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
01265     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
01266     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12);
01267     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12);
01268     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12);
01269     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12);
01270     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
01271     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12);
01272     CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12);
01273   }
01274   //clean up
01275   sourceMesh->decrRef();
01276   targetMesh->decrRef();
01277 }
01278 
01279 void MEDCouplingBasicsTestInterp::test3DInterpP1P0_1()
01280 {
01281   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
01282   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
01283   //
01284   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01285   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01286   INTERP_KERNEL::Interpolation3D myInterpolator;
01287   std::vector<std::map<int,double> > res;
01288   myInterpolator.setPrecision(1e-12);
01289   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01290   for ( int i = 0; i < 4; ++i )
01291   {
01292     myInterpolator.setSplittingPolicy( sp[i] );
01293     res.clear();
01294     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
01295     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01296     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7);
01297     CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
01298     CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7);
01299     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7);
01300     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7);
01301     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7);
01302     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7);
01303     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7);
01304     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7);
01305     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7);
01306     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7);
01307     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7);
01308     CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7);
01309     CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7);
01310     CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7);
01311     CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7);
01312     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7);
01313     CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7);
01314     CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
01315     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7);
01316     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7);
01317     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7);
01318     CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7);
01319     CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7);
01320     CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7);
01321     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7);
01322     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7);
01323     CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7);
01324     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7);
01325     CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7);
01326     CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7);
01327     CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7);
01328     CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7);
01329   }
01330   //clean up
01331   sourceMesh->decrRef();
01332   targetMesh->decrRef();
01333 }
01334 
01335 void MEDCouplingBasicsTestInterp::test3DInterpP1P0PL_1()
01336 {
01337   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
01338   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
01339   //
01340   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01341   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01342   INTERP_KERNEL::Interpolation3D myInterpolator;
01343   std::vector<std::map<int,double> > res;
01344   myInterpolator.setPrecision(1e-12);
01345   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
01346   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01347   for ( int i = 0; i < 4; ++i )
01348   {
01349     myInterpolator.setSplittingPolicy( sp[i] );
01350     res.clear();
01351     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
01352     CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01353     CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12);
01354     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12);
01355     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
01356     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12);
01357     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12);
01358     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
01359     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12);
01360     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12);
01361     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12);
01362     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12);
01363     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12);
01364     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
01365     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12);
01366     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12);
01367     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12);
01368     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12);
01369     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12);
01370     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12);
01371     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12);
01372     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12);
01373     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12);
01374     CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12);
01375     CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12);
01376     CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
01377   }
01378   //clean up
01379   sourceMesh->decrRef();
01380   targetMesh->decrRef();
01381 }
01382 
01383 void MEDCouplingBasicsTestInterp::test3DInterpP1P1_1()
01384 {
01385   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
01386   MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
01387   //
01388   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01389   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01390   INTERP_KERNEL::Interpolation3D myInterpolator;
01391   std::vector<std::map<int,double> > res;
01392   myInterpolator.setPrecision(1e-12);
01393   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
01394   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01395   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},
01396                         {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},
01397                         {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},
01398                         {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},
01399                         {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},
01400                         {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},
01401                         {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},
01402                         {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}};
01403   int i=0;
01404   double sum = 0;
01405   //cout.precision(18);
01406   for(std::vector<std::map<int,double> >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++)
01407     {
01408       //cout<< "res3D[" <<i<< "][]={";
01409       for(int j=0;j<28;j++)
01410         {
01411           std::map<int,double>::const_iterator iter2=(*iter1).find(j);
01412           if(iter2!=(*iter1).end())
01413             {
01414               //cout<< iter2->second<< ", ";
01415               sum += iter2->second;
01416               CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5);
01417             }
01418           else
01419             {
01420               //cout << "0.0, ";
01421               CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14);
01422             }
01423         }
01424       //cout << "}" << endl;
01425     }
01426   //cout << "Sum = " << sum << endl;
01427   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5);
01428   //clean-up
01429   sourceMesh->decrRef();
01430   targetMesh->decrRef();
01431 }
01432 
01433 void MEDCouplingBasicsTestInterp::test3DInterpP1P1PL_1()
01434 {
01435   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
01436   MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
01437   //
01438   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01439   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01440   INTERP_KERNEL::Interpolation3D myInterpolator;
01441   std::vector<std::map<int,double> > res;
01442   myInterpolator.setPrecision(1e-12);
01443   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
01444   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
01445   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01446   CPPUNIT_ASSERT_DOUBLES_EQUAL(20.,res[0][24],1e-12);
01447   CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res[1][26],1e-12);
01448   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][21],1e-12);
01449   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[3][23],1e-12);
01450   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][14],1e-12);
01451   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[5][17],1e-12);
01452   CPPUNIT_ASSERT_DOUBLES_EQUAL(24.,res[6][7],1e-12);
01453   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
01454   CPPUNIT_ASSERT_DOUBLES_EQUAL(97.,sumAll(res),1e-12);
01455   //clean-up
01456   sourceMesh->decrRef();
01457   targetMesh->decrRef();
01458 }
01459 
01460 void MEDCouplingBasicsTestInterp::test3DInterpP0P0Empty()
01461 {
01462   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
01463   sourceMesh->setMeshDimension(2);
01464   sourceMesh->allocateCells(0);
01465   sourceMesh->finishInsertingCells();
01466   DataArrayDouble *myCoords=DataArrayDouble::New();
01467   myCoords->alloc(0,0);
01468   sourceMesh->setCoords(myCoords);
01469   myCoords->decrRef();
01470   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
01471   targetMesh->setMeshDimension(2);
01472   targetMesh->allocateCells(0);
01473   targetMesh->finishInsertingCells();
01474   myCoords=DataArrayDouble::New();
01475   myCoords->alloc(0,2);
01476   targetMesh->setCoords(myCoords);
01477   myCoords->decrRef();
01478   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
01479   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
01480   INTERP_KERNEL::Interpolation2D myInterpolator;
01481   std::vector<std::map<int,double> > res;
01482   myInterpolator.setPrecision(1e-12);
01483   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01484   //clean up
01485   sourceMesh->decrRef();
01486   targetMesh->decrRef();
01487 }
01488 
01489 void MEDCouplingBasicsTestInterp::testInterpolationCC()
01490 {
01491   double arr1[3] = { 0/2., 1/2., 2/2. };
01492   double arr2[4] = { 0/3, 1/3., 2/3., 3/3. };
01493   MEDCouplingCMesh* mesh[2];
01494   for ( int i = 0; i < 2; ++i )
01495     {
01496       const double* arr = i ? arr1 : arr2;
01497       const int nb_coord = i ? 3 : 4;
01498       DataArrayDouble* coords = DataArrayDouble::New();
01499       coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, nb_coord, 1 );
01500 
01501       mesh[i] = MEDCouplingCMesh::New();
01502       mesh[i]->setCoords( coords, coords, coords );
01503       coords->decrRef();
01504     }
01505   MEDCouplingNormalizedCartesianMesh<3> targetWrapper(mesh[1]);
01506   MEDCouplingNormalizedCartesianMesh<3> sourceWrapper(mesh[0]);
01507   CPPUNIT_ASSERT_EQUAL( 27,int( sourceWrapper.getNumberOfElements()));
01508   CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(0)));
01509   CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(1)));
01510   CPPUNIT_ASSERT_EQUAL( 3, int( sourceWrapper.nbCellsAlongAxis(2)));
01511   CPPUNIT_ASSERT_THROW( sourceWrapper.nbCellsAlongAxis(3), INTERP_KERNEL::Exception);
01512 
01513   INTERP_KERNEL::InterpolationCC myInterpolator;
01514   std::vector<std::map<int,double> > res;
01515   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01516 
01517   CPPUNIT_ASSERT_EQUAL(8,int( res.size()));
01518   CPPUNIT_ASSERT_EQUAL(8,int( res[0].size()));
01519   const double precis = 1e-7;
01520   std::set<double> vals;
01521   double sum = 0;
01522   for ( int i = 0; i < (int)res.size(); ++i )
01523     for ( std::map<int,double>::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v)
01524       {
01525         sum += s_v->second;
01526         double vvv;
01527 #ifdef WNT
01528         double vv = s_v->second / precis;
01529         if(vv>=0.0)
01530           {
01531             vvv = floor(vv+0.5);
01532           }
01533         else
01534           {
01535             vvv = ceil(vv-0.5);
01536           }
01537 #else
01538         vvv = round( s_v->second / precis );
01539 #endif
01540         vals.insert( precis * vvv );
01541       }
01542   //cout << "tgt: " << i << " src: " << s_v->first << " - w: " << s_v->second << endl;
01543   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, sum, precis );
01544 
01545   std::set<double>::iterator v = vals.begin();
01546   CPPUNIT_ASSERT_EQUAL( 4, int( vals.size()) );
01547   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00462963, *v++, precis );
01548   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00925926, *v++, precis );
01549   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.01851850, *v++, precis );
01550   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703700, *v++, precis );
01551 
01552   mesh[0]->decrRef();
01553   mesh[1]->decrRef();
01554 }
01555 
01556 void MEDCouplingBasicsTestInterp::testInterpolationCU1D()
01557 {
01558   MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
01559   DataArrayDouble* coords = DataArrayDouble::New();
01560   double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
01561   coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 );
01562   meshC->setCoords( coords );
01563   coords->decrRef();
01564 
01565   MEDCouplingUMesh * meshU = buildCU1DMesh_U();
01566 
01567   MEDCouplingNormalizedCartesianMesh<1>      sourceWrapper(meshC);
01568   MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(meshU);
01569   INTERP_KERNEL::InterpolationCU myInterpolator;
01570   std::vector<std::map<int,double> > res;
01571   const double precis = 1e-13;
01572   myInterpolator.setPrecision(precis);
01573   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01574 
01575 //   std::cout.precision(18);
01576 //   for ( int i = 0; i < (int)res.size(); ++i )
01577 //     for ( std::map<int,double>::iterator s_v = res[i].begin(); s_v != res[i].end(); ++s_v)
01578 //     {
01579 //       std::cout << "CPPUNIT_ASSERT_DOUBLES_EQUAL( "<<s_v->second<<" ,res["<<i<<"]["<<s_v->first<<"],precis);"<<std::endl;
01580 //     }
01581 
01582   double sum = sumAll(res);
01583   CPPUNIT_ASSERT_EQUAL(3,int( res.size()));
01584   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
01585   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[1][0],precis);
01586   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.33333333333333 ,res[1][1],precis);
01587   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.08333333333333 ,res[1][2],precis);
01588   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.25000000000000 ,res[2][2],precis);
01589 
01590   meshC->decrRef();
01591   meshU->decrRef();
01592 }
01593 
01594 void MEDCouplingBasicsTestInterp::testInterpolationCU2D()
01595 {
01596   MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
01597   DataArrayDouble* coords = DataArrayDouble::New();
01598   double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
01599   coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 );
01600   meshC->setCoords( coords, coords );
01601   coords->decrRef();
01602 
01603   MEDCouplingUMesh * meshU = buildCU2DMesh_U();
01604 
01605   MEDCouplingNormalizedCartesianMesh<2>      sourceWrapper(meshC);
01606   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(meshU);
01607   INTERP_KERNEL::InterpolationCU myInterpolator;
01608   std::vector<std::map<int,double> > res;
01609   myInterpolator.setPrecision(1e-12);
01610   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01611 
01612   const double precis = 1e-7;
01613   double sum = sumAll(res);
01614   CPPUNIT_ASSERT_EQUAL(5,int( res.size()));
01615   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
01616   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[0][0],precis);
01617   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][1],precis);
01618   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[0][3],precis);
01619   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[0][4],precis);
01620   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][3],precis);
01621   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[1][4],precis);
01622   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[1][6],precis);
01623   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[1][7],precis);
01624   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[2][4],precis);
01625   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][5],precis);
01626   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0555556 ,res[2][7],precis);
01627   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1111111 ,res[2][8],precis);
01628   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][1],precis);
01629   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[3][2],precis);
01630   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0277778 ,res[3][4],precis);
01631   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0416667 ,res[3][5],precis);
01632   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][1],precis);
01633   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0972222 ,res[4][2],precis);
01634   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0138889 ,res[4][5],precis);
01635 
01636   std::vector<std::map<int,double> > resRev;
01637   myInterpolator.interpolateMeshesRev(targetWrapper,sourceWrapper,resRev,"P0P0");
01638 
01639   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][0] ,resRev[0][0],precis);
01640   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][1] ,resRev[1][0],precis);
01641   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][1] ,resRev[1][3],precis);
01642   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][1] ,resRev[1][4],precis);
01643   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][2] ,resRev[2][3],precis);
01644   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][2] ,resRev[2][4],precis);
01645   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][3] ,resRev[3][0],precis);
01646   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][3] ,resRev[3][1],precis);
01647   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[0][4] ,resRev[4][0],precis);
01648   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][4] ,resRev[4][1],precis);
01649   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][4] ,resRev[4][2],precis);
01650   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][4] ,resRev[4][3],precis);
01651   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][5] ,resRev[5][2],precis);
01652   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[3][5] ,resRev[5][3],precis);
01653   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[4][5] ,resRev[5][4],precis);
01654   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][6] ,resRev[6][1],precis);
01655   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[1][7] ,resRev[7][1],precis);
01656   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][7] ,resRev[7][2],precis);
01657   CPPUNIT_ASSERT_DOUBLES_EQUAL( res[2][8] ,resRev[8][2],precis);
01658 
01659   meshC->decrRef();
01660   meshU->decrRef();
01661 }
01662 
01663 void MEDCouplingBasicsTestInterp::testInterpolationCU3D()
01664 {
01665   MEDCouplingCMesh* meshC = MEDCouplingCMesh::New();
01666   DataArrayDouble* coords = DataArrayDouble::New();
01667   double arr[4] = { -1/3., 1/3., 2/3., 4/3. };
01668   coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, 4, 1 );
01669   meshC->setCoords( coords, coords, coords );
01670   coords->decrRef();
01671 
01672   MEDCouplingUMesh * meshU = buildCU3DMesh_U();
01673 
01674   MEDCouplingNormalizedCartesianMesh<3>      sourceWrapper(meshC);
01675   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(meshU);
01676   INTERP_KERNEL::InterpolationCU myInterpolator;
01677   std::vector<std::map<int,double> > res;
01678   const double precis = 1e-13;
01679   myInterpolator.setPrecision(precis);
01680   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
01681 
01682   double sum = sumAll(res);
01683   CPPUNIT_ASSERT_EQUAL(8,int( res.size()));
01684   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, sum, precis );
01685   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02700000000000 ,res[0][0],precis);
01686   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[1][0],precis);
01687   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[1][1],precis);
01688   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[1][2],precis);
01689   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00300000000000 ,res[2][0],precis);
01690   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][3],precis);
01691   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[2][6],precis);
01692   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[3][0],precis);
01693   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][1],precis);
01694   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][2],precis);
01695   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][3],precis);
01696   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][4],precis);
01697   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][5],precis);
01698   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[3][6],precis);
01699   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][7],precis);
01700   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[3][8],precis);
01701   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00299999999999 ,res[4][0],precis);
01702   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.02999999999999 ,res[4][9],precis);
01703   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03000000000000 ,res[4][18],precis);
01704   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[5][0],precis);
01705   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][1],precis);
01706   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][2],precis);
01707   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][9],precis);
01708   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][10],precis);
01709   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][11],precis);
01710   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[5][18],precis);
01711   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][19],precis);
01712   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[5][20],precis);
01713   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00033333333333 ,res[6][0],precis);
01714   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][3],precis);
01715   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][6],precis);
01716   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][9],precis);
01717   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][12],precis);
01718   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][15],precis);
01719   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00333333333333 ,res[6][18],precis);
01720   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][21],precis);
01721   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03333333333333 ,res[6][24],precis);
01722   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.7037037037e-05 ,res[7][0],precis);
01723   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][1],precis);
01724   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][2],precis);
01725   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][3],precis);
01726   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][4],precis);
01727   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][5],precis);
01728   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][6],precis);
01729   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][7],precis);
01730   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][8],precis);
01731   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][9],precis);
01732   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][10],precis);
01733   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][11],precis);
01734   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][12],precis);
01735   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][13],precis);
01736   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][14],precis);
01737   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][15],precis);
01738   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][16],precis);
01739   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][17],precis);
01740   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00037037037037 ,res[7][18],precis);
01741   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][19],precis);
01742   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][20],precis);
01743   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][21],precis);
01744   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][22],precis);
01745   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][23],precis);
01746   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.00370370370370 ,res[7][24],precis);
01747   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][25],precis);
01748   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.03703703703703 ,res[7][26],precis);
01749 
01750 
01751   meshC->decrRef();
01752   meshU->decrRef();
01753 }
01754 
01755 void MEDCouplingBasicsTestInterp::test2DInterpP0IntegralUniform()
01756 {
01757   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
01758   //
01759   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
01760   INTERP_KERNEL::Interpolation2D myInterpolator;
01761   std::vector<std::map<int,double> > res;
01762   CPPUNIT_ASSERT_EQUAL(5,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
01763   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01764   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
01765   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
01766   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
01767   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
01768   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
01769   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
01770   res.clear();
01771   CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
01772   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
01773   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
01774   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
01775   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
01776   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
01777   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][0],1e-12);
01778   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
01779   res.clear();
01780   targetMesh->decrRef();
01781   //
01782   targetMesh=build2DTargetMeshPerm_1();
01783   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper2(targetMesh);
01784   INTERP_KERNEL::Interpolation2D myInterpolator2;
01785   CPPUNIT_ASSERT(myInterpolator2.getMeasureAbsStatus());
01786   CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0"));
01787   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01788   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
01789   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
01790   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
01791   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
01792   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
01793   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
01794   res.clear();
01795   myInterpolator2.setMeasureAbsStatus(false);
01796   CPPUNIT_ASSERT(!myInterpolator2.getMeasureAbsStatus());
01797   CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.toIntegralUniform(targetWrapper2,res,"P0"));
01798   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01799   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
01800   CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125,res[0][1],1e-12);
01801   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
01802   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
01803   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
01804   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,sumAll(res),1e-12);
01805   targetMesh->decrRef();
01806 }
01807 
01808 void MEDCouplingBasicsTestInterp::test3DSurfInterpP0IntegralUniform()
01809 {
01810   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
01811   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
01812   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
01813   std::vector<std::map<int,double> > res;
01814   CPPUNIT_ASSERT_EQUAL(5,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
01815   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01816   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
01817   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
01818   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][2],1e-12);
01819   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][3],1e-12);
01820   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][4],1e-12);
01821   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
01822   res.clear();
01823   CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
01824   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
01825   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
01826   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
01827   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
01828   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][0],1e-12);
01829   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][0],1e-12);
01830   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
01831   targetMesh->decrRef();
01832 }
01833 
01834 void MEDCouplingBasicsTestInterp::test3DInterpP0IntegralUniform()
01835 {
01836   MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
01837   INTERP_KERNEL::Interpolation3D myInterpolator;
01838   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01839   std::vector<std::map<int,double> > res;
01840   CPPUNIT_ASSERT_EQUAL(8,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
01841   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01842   CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
01843   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][1],1e-6);
01844   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][2],1e-6);
01845   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][3],1e-6);
01846   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][4],1e-6);
01847   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][5],1e-6);
01848   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][6],1e-6);
01849   CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[0][7],1e-6);
01850   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
01851   res.clear();
01852   CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
01853   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
01854   CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
01855   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[1][0],1e-6);
01856   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[2][0],1e-6);
01857   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[3][0],1e-6);
01858   CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[4][0],1e-6);
01859   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[5][0],1e-6);
01860   CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[6][0],1e-6);
01861   CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[7][0],1e-6);
01862   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
01863   res.clear();
01864   targetMesh->decrRef();
01865 }
01866 
01867 void MEDCouplingBasicsTestInterp::test2DInterpP1IntegralUniform()
01868 {
01869   MEDCouplingUMesh *targetMesh=build2DSourceMesh_1();
01870   //
01871   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
01872   INTERP_KERNEL::Interpolation2D myInterpolator;
01873   std::vector<std::map<int,double> > res;
01874   CPPUNIT_ASSERT_EQUAL(4,myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
01875   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01876   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
01877   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][1],1e-12);
01878   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][2],1e-12);
01879   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][3],1e-12);
01880   res.clear();
01881   CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
01882   CPPUNIT_ASSERT_EQUAL(4,(int)res.size());
01883   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
01884   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[1][0],1e-12);
01885   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[2][0],1e-12);
01886   CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[3][0],1e-12);
01887   res.clear();
01888   targetMesh->decrRef();
01889 }
01890 
01891 void MEDCouplingBasicsTestInterp::test3DInterpP1IntegralUniform()
01892 {
01893   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
01894   //
01895   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(sourceMesh);
01896   INTERP_KERNEL::Interpolation3D myInterpolator;
01897   std::vector<std::map<int,double> > res;
01898   CPPUNIT_ASSERT_EQUAL(9,myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
01899   CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
01900   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
01901   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][1],1e-6);
01902   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][2],1e-6);
01903   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][3],1e-6);
01904   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][4],1e-6);
01905   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][5],1e-6);
01906   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][6],1e-6);
01907   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][7],1e-6);
01908   CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[0][8],1e-6);
01909   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
01910   res.clear();
01911   CPPUNIT_ASSERT_EQUAL(1,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
01912   CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
01913   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
01914   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[1][0],1e-6);
01915   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[2][0],1e-6);
01916   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[3][0],1e-6);
01917   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[4][0],1e-6);
01918   CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[5][0],1e-6);
01919   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][0],1e-6);
01920   CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][0],1e-6);
01921   CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[8][0],1e-6);
01922   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
01923   sourceMesh->decrRef();
01924 }
01925 
01926 void MEDCouplingBasicsTestInterp::test2DInterpP1P0Bary_1()
01927 {
01928   MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1();
01929   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
01930   //
01931   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
01932   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
01933   INTERP_KERNEL::Interpolation2D myInterpolator;
01934   myInterpolator.setP1P0BaryMethod(true);
01935   std::vector<std::map<int,double> > res;
01936   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
01937   for(int i=0;i<2;i++)
01938     {
01939       myInterpolator.setPrecision(1e-12);
01940       myInterpolator.setIntersectionType(types[i]);
01941       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
01942       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
01943       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669,res[0][0],1e-12);
01944       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][1],1e-12);
01945       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[0][2],1e-12);
01946       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[0][3],1e-12);
01947       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[1][0],1e-12);
01948       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[1][1],1e-12);
01949       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[1][3],1e-12);
01950       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[2][0],1e-12);
01951       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[2][1],1e-12);
01952       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[2][3],1e-12);
01953       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][0],1e-12);
01954       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[3][2],1e-12);
01955       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625,res[3][3],1e-12);
01956       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664,res[4][0],1e-12);
01957       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][1],1e-12);
01958       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343,res[4][2],1e-12);
01959       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[4][3],1e-12);
01960       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
01961       res.clear();
01962     }
01963   //clean up
01964   sourceMesh->decrRef();
01965   targetMesh->decrRef();
01966 }
01967 
01968 void MEDCouplingBasicsTestInterp::test3DSurfInterpP1P0Bary_1()
01969 {
01970   MEDCouplingUMesh *sourceMesh=build3DSurfSourceMesh_1();
01971   MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
01972   //
01973   MEDCouplingNormalizedUnstructuredMesh<3,2> sourceWrapper(sourceMesh);
01974   MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
01975   INTERP_KERNEL::Interpolation3DSurf myInterpolator;
01976   myInterpolator.setP1P0BaryMethod(true);
01977   std::vector<std::map<int,double> > res;
01978   INTERP_KERNEL::IntersectionType types[2]={INTERP_KERNEL::Triangulation, INTERP_KERNEL::Geometric2D};
01979   for(int i=0;i<2;i++)
01980     {
01981       myInterpolator.setPrecision(1e-12);
01982       myInterpolator.setIntersectionType(types[i]);
01983       myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
01984       CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
01985       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666669*sqrt(2.),res[0][0],1e-12);
01986       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][1],1e-12);
01987       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[0][2],1e-12);
01988       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[0][3],1e-12);
01989       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[1][0],1e-12);
01990       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[1][1],1e-12);
01991       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[1][3],1e-12);
01992       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[2][0],1e-12);
01993       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[2][1],1e-12);
01994       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[2][3],1e-12);
01995       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][0],1e-12);
01996       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[3][2],1e-12);
01997       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0625*sqrt(2.),res[3][3],1e-12);
01998       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.041666666666666664*sqrt(2.),res[4][0],1e-12);
01999       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][1],1e-12);
02000       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.020833333333333343*sqrt(2.),res[4][2],1e-12);
02001       CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666*sqrt(2.),res[4][3],1e-12);
02002       CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
02003       res.clear();
02004     }
02005   //clean up
02006   sourceMesh->decrRef();
02007   targetMesh->decrRef();
02008 }
02009 
02010 #include <iomanip>
02011 void MEDCouplingBasicsTestInterp::test3DInterpP1P0Bary_1()
02012 {
02013   MEDCouplingUMesh *sourceMesh=build3DSourceMesh_2();
02014   MEDCouplingUMesh *targetMesh=build3DTargetMesh_2();
02015   //
02016   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
02017   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
02018   INTERP_KERNEL::Interpolation3D myInterpolator;
02019   myInterpolator.setP1P0BaryMethod(true);
02020   std::vector<std::map<int,double> > res;
02021   myInterpolator.setPrecision(1e-12);
02022   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
02023   CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
02024 
02025   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},
02026                        {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},
02027                        {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},
02028                        {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},
02029                        {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}};
02030 
02031   double sum = 0;
02032   int i=0;
02033   for(std::vector<std::map<int,double> >::const_iterator iter1=res.begin();iter1!=res.end();iter1++,i++)
02034     {
02035       for(int j=0;j<28;j++)
02036         {
02037           std::map<int,double>::const_iterator iter2=(*iter1).find(j);
02038           if(iter2!=(*iter1).end())
02039             {
02040               sum += iter2->second;
02041               CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5);
02042             }
02043           else
02044             {
02045               CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,res3D[i][j],1e-14);
02046             }
02047         }
02048     }
02049   CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000,sum,1.e-5);
02050   //clean up
02051   sourceMesh->decrRef();
02052   targetMesh->decrRef();
02053 }
02054 
02055 void MEDCouplingBasicsTestInterp::test3DTo1DInterpP0P0PL_1()
02056 {
02057   MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
02058   MEDCouplingUMesh *targetMesh=build1DTargetMesh_1();
02059   //
02060   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
02061   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
02062   INTERP_KERNEL::Interpolation3D myInterpolator;
02063   std::vector<std::map<int,double> > res;
02064   myInterpolator.setPrecision(1e-12);
02065   myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
02066   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
02067   CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
02068   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
02069   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][4],1e-12);
02070   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][1],1e-12);
02071   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][5],1e-12);
02072   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][2],1e-12);
02073   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][6],1e-12);
02074   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][3],1e-12);
02075   CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][7],1e-12);
02076   CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,sumAll(res),1e-12);
02077   //
02078   sourceMesh->decrRef();
02079   targetMesh->decrRef();
02080 }
02081 
02082 void MEDCouplingBasicsTestInterp::test1DInterp_1()
02083 {
02084   //      c1   c0    c2    - pay attention to cell order!
02085   // S: o---o------o---o
02086   // T:   o---o------o---o
02087   //      n0  n1     n2  n3
02088   //
02089   // ---+---+------+---+---> X
02090   //    0.  1.     3.  4.   
02091   MEDCouplingUMesh *sourceMesh=build1DMesh(0);
02092   MEDCouplingUMesh *targetMesh=build1DMesh(0.5);
02093   //
02094   MEDCouplingNormalizedUnstructuredMesh<1,1> sourceWrapper(sourceMesh);
02095   MEDCouplingNormalizedUnstructuredMesh<1,1> targetWrapper(targetMesh);
02096   INTERP_KERNEL::Interpolation1D myInterpolator;
02097   const double precis = 1e-13;
02098   myInterpolator.setPrecision(precis);
02099 
02100   // P0P0
02101   std::vector<std::map<int,double> > res;
02102   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
02103   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
02104   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][0], precis);
02105   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][2], precis);
02106   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][0], precis);
02107   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis);
02108   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][2], precis);
02109   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
02110 
02111   // P1P0
02112   res.clear();
02113   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
02114   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
02115   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
02116   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[0][2], precis);
02117   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis);
02118   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis);
02119   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
02120 
02121   // P0P1
02122   res.clear();
02123   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
02124 
02125   CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) );
02126   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
02127   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, res[1][0], precis);
02128   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][0], precis);
02129   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis);
02130   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
02131 
02132   // P1P1
02133   res.clear();
02134   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
02135   CPPUNIT_ASSERT_EQUAL( 4, int( res.size()) );
02136   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[0][1], precis);
02137   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[1][1], precis);
02138   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][2], precis);
02139   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, res[2][2], precis);
02140   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[2][3], precis);
02141   CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.5, sumAll(res), precis);
02142 
02143   sourceMesh->decrRef();
02144   targetMesh->decrRef();
02145 }
02146 
02147 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P0_1()
02148 {
02149   // coincident meshes
02150   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
02151   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
02152   //
02153   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
02154   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
02155   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
02156   const double precis = 1e-13;
02157   myInterpolator.setPrecision(precis);
02158   std::vector<std::map<int,double> > res;
02159   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
02160 
02161   CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
02162   CPPUNIT_ASSERT_DOUBLES_EQUAL( sqrt(2.),res[0][0], precis);
02163   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., res[1][1], precis);
02164   CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.+sqrt(2.), sumAll(res), precis);
02165 
02166   sourceMesh->decrRef();
02167   targetMesh->decrRef();
02168 }
02169 
02170 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P0_2()
02171 {
02172   // equal meshes shifted one from another along X by 0.5
02173   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0.5,0);
02174   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
02175   //
02176   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
02177   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
02178   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
02179   const double precis = 1e-13;
02180   myInterpolator.setPrecision(precis);
02181   myInterpolator.setMedianPlane(1.);// median line on target
02182   std::vector<std::map<int,double> > res;
02183   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
02184 
02185   double tolInters = myInterpolator.getBoundingBoxAdjustmentAbs() * sqrt(2.);
02186   CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
02187   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0,res[0][0], precis);
02188   CPPUNIT_ASSERT_DOUBLES_EQUAL( tolInters,res[0][1], precis);
02189   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, res[1][1], precis);
02190   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5+tolInters, sumAll(res), precis);
02191 
02192   sourceMesh->decrRef();
02193   targetMesh->decrRef();
02194 }
02195 
02196 void MEDCouplingBasicsTestInterp::test2DCurveInterpP0P1_1()
02197 {
02198   // coincident meshes
02199   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
02200   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
02201   //
02202   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
02203   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
02204   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
02205   const double precis = 1e-13;
02206   myInterpolator.setPrecision(precis);
02207   std::vector<std::map<int,double> > res;
02208   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
02209 
02210   const double len1 = 1., len0 = sqrt(2.);
02211   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
02212   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][1], precis);
02213   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[1][0], precis);
02214   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis);
02215   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][0], precis);
02216   CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
02217 
02218   sourceMesh->decrRef();
02219   targetMesh->decrRef();
02220 }
02221 
02222 void MEDCouplingBasicsTestInterp::test2DCurveInterpP1P0_1()
02223 {
02224   // coincident meshes
02225   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
02226   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
02227   //
02228   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
02229   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
02230   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
02231   const double precis = 1e-13;
02232   myInterpolator.setPrecision(precis);
02233   std::vector<std::map<int,double> > res;
02234   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
02235 
02236   const double len1 = 1., len0 = sqrt(2.);
02237   CPPUNIT_ASSERT_EQUAL( 2, int( res.size()) );
02238   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][0], precis);
02239   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][1], precis);
02240   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[1][1], precis);
02241   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[0][2], precis);
02242   CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
02243 
02244   sourceMesh->decrRef();
02245   targetMesh->decrRef();
02246 }
02247 
02248 void MEDCouplingBasicsTestInterp::test2DCurveInterpP1P1_1()
02249 {
02250   // coincident meshes
02251   MEDCouplingUMesh *sourceMesh=build2DCurveMesh(0,0);
02252   MEDCouplingUMesh *targetMesh=build2DCurveMesh(0,0);
02253   //
02254   MEDCouplingNormalizedUnstructuredMesh<2,1> sourceWrapper(sourceMesh);
02255   MEDCouplingNormalizedUnstructuredMesh<2,1> targetWrapper(targetMesh);
02256   INTERP_KERNEL::Interpolation2DCurve myInterpolator;
02257   const double precis = 1e-13;
02258   myInterpolator.setPrecision(precis);
02259   std::vector<std::map<int,double> > res;
02260   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1");
02261 
02262   const double len1 = 1., len0 = sqrt(2.);
02263   CPPUNIT_ASSERT_EQUAL( 3, int( res.size()) );
02264   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len1, res[0][0], precis);
02265   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*(len0+len1), res[1][1], precis);
02266   CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5*len0, res[2][2], precis);
02267   CPPUNIT_ASSERT_DOUBLES_EQUAL( len0+len1, sumAll(res), precis);
02268 
02269   sourceMesh->decrRef();
02270   targetMesh->decrRef();
02271 }
02272 
02273 void MEDCouplingBasicsTestInterp::test2D1DBasicInterpP0P0()
02274 {
02275   MEDCouplingUMesh *sourceMesh=build2D1DSourceMesh();
02276   MEDCouplingUMesh *targetMesh=build2D1DTargetMesh();
02277 
02278   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
02279   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
02280   INTERP_KERNEL::Interpolation2D1D myInterpolator;
02281   myInterpolator.setPrecision(1e-12);
02282   myInterpolator.setIntersectionType(INTERP_KERNEL::Geometric2D);
02283   std::vector<std::map<int,double> > matrix;
02284   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
02285 
02286   CPPUNIT_ASSERT_EQUAL(2,(int)matrix.size());
02287 
02288   CPPUNIT_ASSERT_DOUBLES_EQUAL(3., matrix[0][0],1e-12);
02289   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][1],1e-12);
02290   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][2],1e-12);
02291   CPPUNIT_ASSERT_DOUBLES_EQUAL(8., matrix[0][3],1e-12);
02292   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][4],1e-12);
02293   CPPUNIT_ASSERT_DOUBLES_EQUAL(5., matrix[0][5],1e-12);
02294   CPPUNIT_ASSERT_DOUBLES_EQUAL(6., matrix[0][6],1e-12);
02295   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[0][7],1e-12);
02296 
02297   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][0],1e-12);
02298   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][1],1e-12);
02299   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][2],1e-12);
02300   CPPUNIT_ASSERT_DOUBLES_EQUAL(4., matrix[1][3],1e-12);
02301   CPPUNIT_ASSERT_DOUBLES_EQUAL(5., matrix[1][4],1e-12);
02302   CPPUNIT_ASSERT_DOUBLES_EQUAL(0., matrix[1][5],1e-12);
02303   CPPUNIT_ASSERT_DOUBLES_EQUAL(6., matrix[1][6],1e-12);
02304   CPPUNIT_ASSERT_DOUBLES_EQUAL(3., matrix[1][7],1e-12);
02305 
02306   INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
02307   CPPUNIT_ASSERT_EQUAL(1,(int)duplicateFaces.size());
02308 
02309   INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType correctDuplicateFaces;
02310   std::set<int> face6;
02311   face6.insert(0);
02312   face6.insert(1);
02313   correctDuplicateFaces[6] = face6;
02314 
02315   CPPUNIT_ASSERT(correctDuplicateFaces == duplicateFaces);
02316 
02317   //clean up
02318   sourceMesh->decrRef();
02319   targetMesh->decrRef();
02320 }
02321 
02322 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_1()
02323 {
02324   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh();
02325   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
02326   test2D1DMeshesIntersection(sourceMesh, targetMesh, 16., 0, 4);
02327 }
02328 
02329 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_2()
02330 {
02331   const double shiftX = 3.;
02332   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
02333   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
02334   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 16., 4, 2 * 4);
02335 }
02336 
02337 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_3()
02338 {
02339   const double shiftX = 1.5;
02340   const double inclinationX = 3.;
02341   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
02342   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
02343   test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 0, 4);
02344 }
02345 
02346 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_4()
02347 {
02348   const double shiftX = 3.;
02349   const double inclinationX = 3.;
02350   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
02351   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
02352   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 20., 4, 2 * 4);
02353 }
02354 
02355 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_5()
02356 {
02357   const double shiftX = 9.;
02358   const double inclinationX = 3.;
02359   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
02360   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh(inclinationX);
02361   test2D1DMeshesIntersection(sourceMesh, targetMesh, 12., 0, 3);
02362 }
02363 
02364 void MEDCouplingBasicsTestInterp::test2D1DSegQuadInterpP0P0_6()
02365 {
02366   const double shiftX = 9.;
02367   const double inclinationX = 3.;
02368   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
02369   MEDCouplingUMesh *targetMesh=build2D1DQuadTargetMesh();
02370   test2D1DMeshesIntersection(sourceMesh, targetMesh, 10., 0, 2);
02371 }
02372 
02373 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_1()
02374 {
02375   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh();
02376   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
02377   test2D1DMeshesIntersection(sourceMesh, targetMesh, 16., 0, 4);
02378 }
02379 
02380 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_2()
02381 {
02382   const double shiftX = 3.;
02383   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
02384   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
02385   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 16., 4, 2 * 4);
02386 }
02387 
02388 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_3()
02389 {
02390   const double shiftX = 1.5;
02391   const double inclinationX = 3.;
02392   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
02393   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
02394   test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 0, 8);
02395 }
02396 
02397 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_4()
02398 {
02399   const double shiftX = 3.;
02400   const double inclinationX = 3.;
02401   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
02402   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
02403   test2D1DMeshesIntersection(sourceMesh, targetMesh, 2. * 20., 4, 8);
02404 }
02405 
02406 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_5()
02407 {
02408   const double shiftX = 9.;
02409   const double inclinationX = 3.;
02410   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX);
02411   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh(inclinationX);
02412   test2D1DMeshesIntersection(sourceMesh, targetMesh, 12., 0, 6);
02413 }
02414 
02415 void MEDCouplingBasicsTestInterp::test2D1DSegTriInterpP0P0_6()
02416 {
02417   const double shiftX = 9.;
02418   const double inclinationX = 3.;
02419   MEDCouplingUMesh *sourceMesh=build2D1DSegSourceMesh(shiftX, inclinationX);
02420   MEDCouplingUMesh *targetMesh=build2D1DTriTargetMesh();
02421   test2D1DMeshesIntersection(sourceMesh, targetMesh, 20., 2, 4);
02422 }
02423 
02424 void MEDCouplingBasicsTestInterp::test3D2DBasicInterpP0P0()
02425 {
02426   MEDCouplingUMesh *sourceMesh=build3D2DSourceMesh();
02427   MEDCouplingUMesh *targetMesh=build3D2DTargetMesh();
02428 
02429   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
02430   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
02431   INTERP_KERNEL::Interpolation3D2D myInterpolator;
02432   myInterpolator.setPrecision(1e-12);
02433   std::vector<std::map<int,double> > matrix;
02434   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
02435   for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i )
02436   {
02437     myInterpolator.setSplittingPolicy( sp[i] );
02438     matrix.clear();
02439     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
02440 
02441     CPPUNIT_ASSERT_EQUAL(3,(int)matrix.size());
02442 
02443     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[0][0],1e-12);
02444     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[0][1],1e-12);
02445     CPPUNIT_ASSERT_DOUBLES_EQUAL(40.        ,matrix[0][2],1e-12);
02446     CPPUNIT_ASSERT_DOUBLES_EQUAL(8.         ,matrix[0][3],1e-12);
02447     CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5        ,matrix[0][4],1e-12);
02448     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[0][5],1e-12);
02449     CPPUNIT_ASSERT_DOUBLES_EQUAL(32.        ,matrix[0][6],1e-12);
02450 
02451     CPPUNIT_ASSERT_DOUBLES_EQUAL(8.*sqrt(3.),matrix[1][0],1e-12);
02452     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[1][1],1e-12);
02453     CPPUNIT_ASSERT_DOUBLES_EQUAL(40.        ,matrix[1][2],1e-12);
02454     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[1][3],1e-12);
02455     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[1][4],1e-12);
02456     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[1][5],1e-12);
02457     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[1][6],1e-12);
02458 
02459     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][0],1e-12);
02460     CPPUNIT_ASSERT_DOUBLES_EQUAL(32.        ,matrix[2][1],1e-12);
02461     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][2],1e-12);
02462     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][3],1e-12);
02463     CPPUNIT_ASSERT_DOUBLES_EQUAL(0.         ,matrix[2][4],1e-12);
02464     CPPUNIT_ASSERT_DOUBLES_EQUAL(80.        ,matrix[2][5],1e-12);
02465     CPPUNIT_ASSERT_DOUBLES_EQUAL(112.       ,matrix[2][6],1e-12);
02466 
02467     INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
02468     CPPUNIT_ASSERT_EQUAL(3,(int)duplicateFaces.size());
02469 
02470     INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType correctDuplicateFaces;
02471     std::set<int> face2;
02472     face2.insert(0);
02473     face2.insert(1);
02474     correctDuplicateFaces[2] = face2;
02475     std::set<int> face5;
02476     face5.insert(1);
02477     face5.insert(2);
02478     correctDuplicateFaces[5] = face5;
02479     std::set<int> face6;
02480     face6.insert(0);
02481     face6.insert(1);
02482     face6.insert(2);
02483     correctDuplicateFaces[6] = face6;
02484 
02485     CPPUNIT_ASSERT(correctDuplicateFaces == duplicateFaces);
02486   }
02487   //clean up
02488   sourceMesh->decrRef();
02489   targetMesh->decrRef();
02490 }
02491 
02492 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_1()
02493 {
02494   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh();
02495   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
02496   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 20);
02497 }
02498 
02499 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_2()
02500 {
02501   const double shiftX = 3.;
02502   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
02503   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
02504   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 20, 2 * 20);
02505 }
02506 
02507 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_3()
02508 {
02509   const double shiftX = 1.5;
02510   const double inclinationX = 3.;
02511   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
02512   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
02513   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 20);
02514 }
02515 
02516 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_4()
02517 {
02518   const double shiftX = 3.;
02519   const double inclinationX = 3.;
02520   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
02521   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
02522   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 20, 2 * 20);
02523 }
02524 
02525 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_5()
02526 {
02527   const double shiftX = 9.;
02528   const double inclinationX = 3.;
02529   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
02530   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
02531   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 15);
02532 }
02533 
02534 void MEDCouplingBasicsTestInterp::test3D2DQuadHexaInterpP0P0_6()
02535 {
02536   const double shiftX = 9.;
02537   const double inclinationX = 3.;
02538   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
02539   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
02540   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 10);
02541 }
02542 
02543 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_1()
02544 {
02545   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh();
02546   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
02547   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 40);
02548 }
02549 
02550 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_2()
02551 {
02552   const double shiftX = 3.;
02553   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
02554   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
02555   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 40, 2 * 40);
02556 }
02557 
02558 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_3()
02559 {
02560   const double shiftX = 1.5;
02561   const double inclinationX = 3.;
02562   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
02563   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
02564   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 40);
02565 }
02566 
02567 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_4()
02568 {
02569   const double shiftX = 3.;
02570   const double inclinationX = 3.;
02571   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
02572   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
02573   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 40, 2 * 40);
02574 }
02575 
02576 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_5()
02577 {
02578   const double shiftX = 9.;
02579   const double inclinationX = 3.;
02580   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
02581   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh(inclinationX);
02582   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 30);
02583 }
02584 
02585 void MEDCouplingBasicsTestInterp::test3D2DTriHexaInterpP0P0_6()
02586 {
02587   const double shiftX = 9.;
02588   const double inclinationX = 3.;
02589   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
02590   MEDCouplingUMesh *targetMesh=build3D2DHexaTargetMesh();
02591   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 20);
02592 }
02593 
02594 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_1()
02595 {
02596   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh();
02597   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
02598   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 20, 40);
02599 }
02600 
02601 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_2()
02602 {
02603   const double shiftX = 3.;
02604   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
02605   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
02606   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 20, 2 * 40);
02607 }
02608 
02609 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_3()
02610 {
02611   const double shiftX = 1.5;
02612   const double inclinationX = 3.;
02613   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
02614   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
02615   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0, 100);
02616 }
02617 
02618 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_4()
02619 {
02620   const double shiftX = 3.;
02621   const double inclinationX = 3.;
02622   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
02623   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
02624   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 20, 2 * 40);
02625 }
02626 
02627 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_5()
02628 {
02629   const double shiftX = 9.;
02630   const double inclinationX = 3.;
02631   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX);
02632   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
02633   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0, 45);
02634 }
02635 
02636 void MEDCouplingBasicsTestInterp::test3D2DQuadTetraInterpP0P0_6()
02637 {
02638   const double shiftX = 9.;
02639   const double inclinationX = 3.;
02640   MEDCouplingUMesh *sourceMesh=build3D2DQuadSourceMesh(shiftX, inclinationX);
02641   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
02642   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0, 30);
02643 }
02644 
02645 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_1()
02646 {
02647   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh();
02648   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
02649   test3D2DMeshesIntersection(sourceMesh, targetMesh, 240., 0, 40);
02650 }
02651 
02652 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_2()
02653 {
02654   const double shiftX = 3.;
02655   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
02656   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
02657   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 240., 40, 40 + 80);
02658 }
02659 
02660 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_3()
02661 {
02662   const double shiftX = 1.5;
02663   const double inclinationX = 3.;
02664   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
02665   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
02666   test3D2DMeshesIntersection(sourceMesh, targetMesh, 300., 0);
02667 }
02668 
02669 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_4()
02670 {
02671   const double shiftX = 3.;
02672   const double inclinationX = 3.;
02673   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
02674   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
02675   test3D2DMeshesIntersection(sourceMesh, targetMesh, 2. * 300., 40, 40 + 80);
02676 }
02677 
02678 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_5()
02679 {
02680   const double shiftX = 9.;
02681   const double inclinationX = 3.;
02682   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX);
02683   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh(inclinationX);
02684   test3D2DMeshesIntersection(sourceMesh, targetMesh, 180., 0);
02685 }
02686 
02687 void MEDCouplingBasicsTestInterp::test3D2DTriTetraInterpP0P0_6()
02688 {
02689   const double shiftX = 9.;
02690   const double inclinationX = 3.;
02691   MEDCouplingUMesh *sourceMesh=build3D2DTriSourceMesh(shiftX, inclinationX);
02692   MEDCouplingUMesh *targetMesh=build3D2DTetraTargetMesh();
02693   test3D2DMeshesIntersection(sourceMesh, targetMesh, 150., 0);
02694 }
02695