Back to index

salome-med  6.5.0
MEDCouplingBasicsTest0.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 "MEDCouplingBasicsTest.hxx"
00021 #include "MEDCouplingUMesh.hxx"
00022 #include "MEDCouplingExtrudedMesh.hxx"
00023 #include "MEDCouplingFieldDouble.hxx"
00024 #include "MEDCouplingMemArray.hxx"
00025 #include "MEDCouplingMultiFields.hxx"
00026 
00027 #include "MEDCouplingBasicsTestData1.hxx"
00028 
00029 #include "Interpolation2D.txx"
00030 #include "Interpolation3D2D.txx"
00031 #include "Interpolation2D1D.txx"
00032 #include "MEDCouplingNormalizedUnstructuredMesh.txx"
00033 #include "MEDCouplingNormalizedCartesianMesh.txx"
00034 
00035 using namespace ParaMEDMEM;
00036 
00037 typedef std::vector<std::map<int,double> > IntersectionMatrix;
00038 
00039 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_2()
00040 {
00041   double sourceCoords[84]={100.0, 100.0, 0.0, 100.0, 100.0, 100.0, 100.0, 0.0, 100.0, 100.0, 0.0, 0.0, 0.0, 100.0, 0.0, 0.0, 100.0, 100.0, 0.0,
00042                            0.0, 100.0, 0.0, 0.0, 0.0, 100.0, 100.0, 200.0, 100.0, 0.0, 200.0, 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0,
00043                            0.0, 100.0, 200.0, 100.0, 0.0, 200.0, 0.0, 0.0, 200.0, 100.0, 100.0, 200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 100.0,
00044                            0.0, 200.0, 100.00000000833332, 100.00000000833332, 200.0, 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0, 200.0,
00045                            0.0, 200.0, 200.0, 200.0, 0.0, 200.0, 200.0, 100.0, 200.0, 200.0, 200.0, 149.999999970343, 149.9999999874621, 49.999999881628682};
00046   
00047   
00048   int sourceConn[212]={25, 27, 13, 19, 18, 3, 20, 21, 5, 10, 17, 1, 1, 3, 0, 7, 18, 1, 0, 27, 12, 27, 13, 24, 25, 19, 16, 26, 1, 2, 6, 8, 15, 13, 
00049                        12, 5, 24, 13, 25, 27, 10, 11, 9, 6, 19, 8, 23, 1, 22, 8, 23, 19, 16, 13, 17, 1, 6, 9, 10, 8, 13, 17, 5, 15, 5, 4, 1, 12, 18,
00050                        0, 24, 27, 19, 20, 18, 1, 7, 6, 5, 1, 4, 12, 15, 14, 25, 27, 19, 18, 1, 19, 16, 13, 20, 19, 23, 1, 27, 12, 1, 0, 6, 5, 1, 10,
00051                        4, 5, 1, 7, 12, 27, 1, 13, 5, 15, 4, 12, 19, 16, 26, 22, 13, 5, 17, 1, 1, 3, 7, 2, 13, 5, 1, 12, 18, 1, 3, 0, 8, 23, 2, 9, 3,
00052                        1, 18, 20, 1, 27, 19, 13, 24, 25, 18, 27, 25, 16, 19, 13, 7, 1, 2, 6, 3, 1, 20, 2, 8, 16, 17, 1, 7, 4, 0, 1, 18, 19, 1, 27,
00053                        27, 12, 0, 24, 9, 6, 2, 8, 1, 4, 0, 12, 19, 16, 22, 8, 8, 2, 23, 1, 1, 16, 19, 8, 20, 2, 1, 23, 10, 1, 6, 8, 10, 8, 17, 1};
00054   
00055   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
00056   sourceMesh->setMeshDimension(3);
00057   sourceMesh->allocateCells(53);
00058   for(int i=0;i<53;i++)
00059     sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4*i);
00060   sourceMesh->finishInsertingCells();
00061   DataArrayDouble *myCoords=DataArrayDouble::New();
00062   myCoords->alloc(28,3);
00063   std::copy(sourceCoords,sourceCoords+84,myCoords->getPointer());
00064   sourceMesh->setCoords(myCoords);
00065   myCoords->decrRef();
00066   return sourceMesh;
00067 }
00068 
00069 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_2()
00070 {
00071   double targetCoords[24]={200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 200.0, 0.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 0.0, 200.0, 200.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200.0};
00072   int targetConn[20]={5, 6, 3, 0, 1, 3, 0, 5, 3, 6, 5, 7, 6, 4, 0, 5, 6, 3, 0, 2};
00073   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00074   targetMesh->setMeshDimension(3);
00075   targetMesh->allocateCells(5);
00076   for(int i=0;i<5;i++)
00077     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn+4*i);
00078   targetMesh->finishInsertingCells();
00079   DataArrayDouble *myCoords=DataArrayDouble::New();
00080   myCoords->alloc(8,3);
00081   std::copy(targetCoords,targetCoords+24,myCoords->getPointer());
00082   targetMesh->setCoords(myCoords);
00083   myCoords->decrRef();
00084   return targetMesh;
00085 }
00086 
00087 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_1()
00088 {
00089   double targetCoords[36]={
00090     25.,25.,0., 25.,25.,50., 25.,25.,200., 75.,25.,0., 75.,25.,50., 75.,25.,200.,
00091     25.,125.,0., 25.,125.,50., 25.,125.,200., 125.,125.,0., 125.,125.,50., 125.,125.,200.
00092   };
00093   int targetConn[16]={0,1, 1,2, 3,4, 4,5, 6,7, 7,8, 9,10, 10,11};
00094 
00095   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("my name of mesh 1D",1);
00096   targetMesh->allocateCells(8);
00097   for(int i=0;i<8;i++)
00098     targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
00099   targetMesh->finishInsertingCells();
00100   DataArrayDouble *myCoords=DataArrayDouble::New();
00101   myCoords->alloc(12,3);
00102   std::copy(targetCoords,targetCoords+36,myCoords->getPointer());
00103   targetMesh->setCoords(myCoords);
00104   myCoords->decrRef();
00105   return targetMesh;
00106 }
00107 
00108 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DSourceMesh_1()
00109 {
00110   double sourceCoords[8]={-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7};
00111   int sourceConn[6]={0,3,1,0,2,3};
00112   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New("my name of mesh 2D",2);
00113   sourceMesh->allocateCells(2);
00114   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
00115   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
00116   sourceMesh->finishInsertingCells();
00117   DataArrayDouble *myCoords=DataArrayDouble::New();
00118   myCoords->alloc(4,2);
00119   std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer());
00120   sourceMesh->setCoords(myCoords);
00121   myCoords->decrRef();
00122   return sourceMesh;
00123 }
00124 
00125 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_1()
00126 {
00127   double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
00128   int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
00129   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00130   targetMesh->setMeshDimension(2);
00131   targetMesh->allocateCells(5);
00132   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00133   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00134   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00135   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00136   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00137   targetMesh->finishInsertingCells();
00138   DataArrayDouble *myCoords=DataArrayDouble::New();
00139   myCoords->alloc(9,2);
00140   std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
00141   targetMesh->setCoords(myCoords);
00142   myCoords->decrRef();
00143   return targetMesh;
00144 }
00145 
00146 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshPerm_1()
00147 {
00148   double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
00149   int targetConn[18]={0,3,4,1, 1,2,4, 4,5,2, 6,7,4,3, 7,8,5,4};
00150   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00151   targetMesh->setMeshDimension(2);
00152   targetMesh->allocateCells(5);
00153   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00154   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00155   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00156   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00157   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00158   targetMesh->finishInsertingCells();
00159   DataArrayDouble *myCoords=DataArrayDouble::New();
00160   myCoords->alloc(9,2);
00161   std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
00162   targetMesh->setCoords(myCoords);
00163   myCoords->decrRef();
00164   return targetMesh;
00165 }
00166 
00167 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_2()
00168 {
00169   double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
00170   int targetConn[24]={0,3,4, 0,4,1, 1,4,2, 4,5,2, 3,6,4, 6,7,4, 4,7,5, 7,8,5 };
00171   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00172   targetMesh->setMeshDimension(2);
00173   targetMesh->allocateCells(8);
00174   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
00175   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
00176   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6);
00177   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9);
00178   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12);
00179   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15);
00180   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
00181   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
00182   targetMesh->finishInsertingCells();
00183   DataArrayDouble *myCoords=DataArrayDouble::New();
00184   myCoords->alloc(9,2);
00185   std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
00186   targetMesh->setCoords(myCoords);
00187   myCoords->decrRef();
00188   return targetMesh;
00189 }
00190 
00191 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU1DMesh_U()
00192 {
00193   double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
00194   int conn[2*3]={ 0,1, 1,2, 2,3 };
00195   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
00196   mesh->setMeshDimension(1);
00197   mesh->allocateCells(3);
00198   mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
00199   mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
00200   mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
00201   mesh->finishInsertingCells();
00202   DataArrayDouble *myCoords=DataArrayDouble::New();
00203   myCoords->alloc(4,1);
00204   std::copy(coords,coords+4,myCoords->getPointer());
00205   mesh->setCoords(myCoords);
00206   myCoords->decrRef();
00207   return mesh;
00208 }
00209 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU2DMesh_U()
00210 {
00211   double coords[18]={0.0,0.0, 0.5,0.0, 1.0,0.0, 0.0,0.5, 0.5,0.5, 1.0,0.5, 0.0,1.0, 0.5,1.0, 1.0,1.0 };
00212   int conn[18]={0,1,4,3, 3,4,7,6, 4,5,8,7, 1,5,4, 1,2,5 };
00213   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
00214   mesh->setMeshDimension(2);
00215   mesh->allocateCells(5);
00216   mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);
00217   mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+4);
00218   mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+8);
00219   mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+12);
00220   mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+15);
00221   mesh->finishInsertingCells();
00222   DataArrayDouble *myCoords=DataArrayDouble::New();
00223   myCoords->alloc(9,2);
00224   std::copy(coords,coords+18,myCoords->getPointer());
00225   mesh->setCoords(myCoords);
00226   myCoords->decrRef();
00227   return mesh;
00228 }
00229 MEDCouplingUMesh *MEDCouplingBasicsTest::buildCU3DMesh_U()
00230 {
00231   double coords[27*3]=
00232     {
00233 //   0.0,1.0,0.0 ,0.0,0.3,0.0 ,0.0,0.3,0.3 ,0.3,0.0,0.0 ,0.3,0.3,1.0 ,1.0,0.0,1.0 ,1.0,0.0,0.3 ,0.3,0.0,0.3 ,0.3,1.0,0.3 ,0.0,0.3,1.0 ,0.3,0.0,1.0 ,0.3,0.3,0.3 ,1.0,0.3,1.0 ,1.0,0.0,0.0 ,0.0,0.0,0.0 ,1.0,0.3,0.3 ,0.3,1.0,0.0 ,1.0,1.0,0.3 ,1.0,1.0,1.0 ,0.0,1.0,1.0 ,0.3,0.3,0.0 ,0.0,1.0,0.3 ,0.0,0.0,1.0 ,0.3,1.0,1.0 ,1.0,0.3,0.0 ,0.0,0.0,0.3 ,1.0,1.0,0.0
00234       0.0,0.0,0.0, 0.3,0.0,0.0, 1.0,0.0,0.0, 0.0,0.3,0.0, 0.3,0.3,0.0, 1.0,0.3,0.0, 0.0,1.0,0.0, 0.3,1.0,0.0, 1.0,1.0,0.0, 0.0,0.0,0.3, 0.3,0.0,0.3, 1.0,0.0,0.3, 0.0,0.3,0.3, 0.3,0.3,0.3, 1.0,0.3,0.3, 0.0,1.0,0.3, 0.3,1.0,0.3, 1.0,1.0,0.3, 0.0,0.0,1.0, 0.3,0.0,1.0, 1.0,0.0,1.0, 0.0,0.3,1.0, 0.3,0.3,1.0, 1.0,0.3,1.0, 0.0,1.0,1.0, 0.3,1.0,1.0, 1.0,1.0,1.0,
00235     };
00236   int conn[8*8]=
00237     {
00238 //       11,15,12,4,8,17,18,23,3,13,6,7,20,24,15,11,14,3,7,25,1,20,11,2,1,20,11,2,0,16,8,21,20,24,15,11,16,26,17,8,25,7,10,22,2,11,4,9,2,11,4,9,21,8,23,19,7,6,5,10,11,15,12,4
00239       0,3,4,1,9,12,13,10, 1,4,5,2,10,13,14,11, 3,6,7,4,12,15,16,13, 4,7,8,5,13,16,17,14, 9,12,13,10,18,21,22,19, 10,13,14,11,19,22,23,20, 12,15,16,13,21,24,25,22, 13,16,17,14,22,25,26,23
00240     };
00241   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
00242   mesh->setMeshDimension(3);
00243   mesh->allocateCells(8);
00244   for(int i=0;i<8;i++)
00245     mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
00246   mesh->finishInsertingCells();
00247   DataArrayDouble *myCoords=DataArrayDouble::New();
00248   myCoords->alloc(27,3);
00249   std::copy(coords,coords+27*3,myCoords->getPointer());
00250   mesh->setCoords(myCoords);
00251   myCoords->decrRef();
00252   return mesh;
00253 }
00254 
00255 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_1()
00256 {
00257   double sourceCoords[12]={-0.3,-0.3,0.5, 0.7,-0.3,1.5, -0.3,0.7,0.5, 0.7,0.7,1.5};
00258   int sourceConn[6]={0,3,1,0,2,3};
00259   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
00260   sourceMesh->setMeshDimension(2);
00261   sourceMesh->allocateCells(2);
00262   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
00263   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
00264   sourceMesh->finishInsertingCells();
00265   DataArrayDouble *myCoords=DataArrayDouble::New();
00266   myCoords->alloc(4,3);
00267   std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
00268   sourceMesh->setCoords(myCoords);
00269   myCoords->decrRef();
00270   return sourceMesh;
00271 }
00272 
00273 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfSourceMesh_2()
00274 {
00275   double sourceCoords[12]={-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.};
00276   int sourceConn[6]={0,3,1,0,2,3};
00277   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
00278   sourceMesh->setMeshDimension(2);
00279   sourceMesh->allocateCells(2);
00280   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
00281   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn+3);
00282   sourceMesh->finishInsertingCells();
00283   DataArrayDouble *myCoords=DataArrayDouble::New();
00284   myCoords->alloc(4,3);
00285   std::copy(sourceCoords,sourceCoords+12,myCoords->getPointer());
00286   sourceMesh->setCoords(myCoords);
00287   myCoords->decrRef();
00288   return sourceMesh;
00289 }
00290 
00291 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_1()
00292 {
00293   double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
00294   int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
00295   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00296   targetMesh->setMeshDimension(2);
00297   targetMesh->allocateCells(5);
00298   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00299   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00300   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00301   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00302   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00303   targetMesh->finishInsertingCells();
00304   DataArrayDouble *myCoords=DataArrayDouble::New();
00305   myCoords->alloc(9,3);
00306   std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
00307   targetMesh->setCoords(myCoords);
00308   myCoords->decrRef();
00309   return targetMesh;
00310 }
00311 
00315 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMeshPerm_1()
00316 {
00317   double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
00318   int targetConn[18]={0,3,4,1, 1,4,2, 4,2,5, 6,7,4,3, 7,8,5,4};
00319   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00320   targetMesh->setMeshDimension(2);
00321   targetMesh->allocateCells(5);
00322   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00323   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00324   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00325   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00326   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00327   targetMesh->finishInsertingCells();
00328   DataArrayDouble *myCoords=DataArrayDouble::New();
00329   myCoords->alloc(9,3);
00330   std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
00331   targetMesh->setCoords(myCoords);
00332   myCoords->decrRef();
00333   return targetMesh;
00334 }
00335 
00336 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSurfTargetMesh_2()
00337 {
00338   double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
00339   int targetConn[24]={0,3,4, 0,4,1, 1,4,2, 4,5,2, 3,6,4, 6,7,4, 4,7,5, 7,8,5 };
00340   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00341   targetMesh->setMeshDimension(2);
00342   targetMesh->allocateCells(8);
00343   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
00344   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
00345   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+6);
00346   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+9);
00347   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+12);
00348   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+15);
00349   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
00350   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
00351   targetMesh->finishInsertingCells();
00352   DataArrayDouble *myCoords=DataArrayDouble::New();
00353   myCoords->alloc(9,3);
00354   std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
00355   targetMesh->setCoords(myCoords);
00356   myCoords->decrRef();
00357   return targetMesh;
00358 }
00359 
00360 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_1()
00361 {
00362   double sourceCoords[27]={ 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0,
00363                             200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0 };
00364   int sourceConn[48]={8,1,7,3, 6,0,8,2, 7,4,5,8, 6,8,4,7, 6,8,0,4, 6,8,7,3, 8,1,3,0, 4,1,5,8, 1,7,5,8, 0,3,8,2, 8,1,0,4, 3,6,8,2};
00365   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
00366   sourceMesh->setMeshDimension(3);
00367   sourceMesh->allocateCells(12);
00368   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn);
00369   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+4);
00370   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+8);
00371   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+12);
00372   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+16);
00373   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+20);
00374   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+24);
00375   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+28);
00376   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+32);
00377   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+36);
00378   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+40);
00379   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,sourceConn+44);
00380   sourceMesh->finishInsertingCells();
00381   DataArrayDouble *myCoords=DataArrayDouble::New();
00382   myCoords->alloc(9,3);
00383   std::copy(sourceCoords,sourceCoords+27,myCoords->getPointer());
00384   sourceMesh->setCoords(myCoords);
00385   myCoords->decrRef();
00386   return sourceMesh;
00387 }
00388 
00389 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_1()
00390 {
00391   double targetCoords[81]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0.  , 0., 50., 0., 50., 50., 0. , 200., 50., 0.,   0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
00392                             0., 0., 50., 50., 0., 50. , 200., 0., 50.  , 0., 50., 50., 50., 50., 50. , 200., 50., 50.,   0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
00393                             0., 0., 200., 50., 0., 200. , 200., 0., 200.  , 0., 50., 200., 50., 50., 200. , 200., 50., 200.,   0., 200., 200., 50., 200., 200. , 200., 200., 200. };
00394   int targetConn[64]={0,1,4,3,9,10,13,12, 1,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16,
00395                       9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25};
00396   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00397   targetMesh->setMeshDimension(3);
00398   targetMesh->allocateCells(12);
00399   for(int i=0;i<8;i++)
00400     targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
00401   targetMesh->finishInsertingCells();
00402   DataArrayDouble *myCoords=DataArrayDouble::New();
00403   myCoords->alloc(27,3);
00404   std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
00405   targetMesh->setCoords(myCoords);
00406   myCoords->decrRef();
00407   return targetMesh;
00408 }
00409 
00410 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMergeNode_1()
00411 {
00412   double targetCoords[36]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,-0.3, 0.2,-0.3, 0.2,-0.3, 0.2,0.2, 0.2,0.2, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7, 0.2,0.7 };
00413   int targetConn[18]={0,9,7,5, 4,6,2, 10,11,8, 9,14,15,7, 17,16,13,6};
00414   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00415   targetMesh->setMeshDimension(2);
00416   targetMesh->allocateCells(5);
00417   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00418   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00419   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00420   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00421   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00422   targetMesh->finishInsertingCells();
00423   DataArrayDouble *myCoords=DataArrayDouble::New();
00424   myCoords->alloc(18,2);
00425   std::copy(targetCoords,targetCoords+36,myCoords->getPointer());
00426   targetMesh->setCoords(myCoords);
00427   myCoords->decrRef();
00428   return targetMesh;
00429 }
00430 
00431 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMeshMergeNode_1()
00432 {
00433   double targetCoords[93]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0.  , 0., 50., 0., 50., 50., 0. , 200., 50., 0.,   0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
00434                             0., 0., 50., 50., 0., 50. , 200., 0., 50.  , 0., 50., 50., 50., 50., 50. , 200., 50., 50.,   0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
00435                             0., 0., 200., 50., 0., 200. , 200., 0., 200.  , 0., 50., 200., 50., 50., 200. , 200., 50., 200.,   0., 200., 200., 50., 200., 200. , 200., 200., 200., 50.,0.,0., 50.,0.,0., 50.,0.,0.,  200., 50., 200.};
00436   int targetConn[64]={0,29,4,3,9,10,13,12, 28,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16,
00437                       9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,30,26,25};
00438   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00439   targetMesh->setMeshDimension(3);
00440   targetMesh->allocateCells(12);
00441   for(int i=0;i<8;i++)
00442     targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
00443   targetMesh->finishInsertingCells();
00444   DataArrayDouble *myCoords=DataArrayDouble::New();
00445   myCoords->alloc(31,3);
00446   std::copy(targetCoords,targetCoords+93,myCoords->getPointer());
00447   targetMesh->setCoords(myCoords);
00448   myCoords->decrRef();
00449   return targetMesh;
00450 }
00451 
00452 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D)
00453 {
00454   double coords[180]={
00455     0.,0.,0., 1.,1.,0., 1.,1.25,0., 1.,0.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
00456     3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
00457     0.,0.,1., 1.,1.,1., 1.,1.25,1., 1.,0.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
00458     3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1.,
00459     0.,0.,2., 1.,1.,2., 1.,1.25,2., 1.,0.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
00460     3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2.,
00461     0.,0.,3., 1.,1.,3., 1.,1.25,3., 1.,0.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
00462     3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.};
00463 
00464   int conn[354]={
00465     // 0
00466     0,11,1,3,15,26,16,18,   1,2,4,7,13,6,-1,1,16,21,6,-1,6,21,28,13,-1,13,7,22,28,-1,7,4,19,22,-1,4,2,17,19,-1,2,1,16,17,-1,16,21,28,22,19,17,
00467     1,6,5,3,16,21,20,18,   13,10,9,6,28,25,24,21,
00468     11,8,7,4,2,1,-1,11,26,16,1,-1,1,16,17,2,-1,2,17,19,4,-1,4,19,22,7,-1,7,8,23,22,-1,8,11,26,23,-1,26,16,17,19,22,23,
00469     7,12,14,13,22,27,29,28,
00470     // 1
00471     15,26,16,18,30,41,31,33,   16,17,19,22,28,21,-1,16,31,36,21,-1,21,36,43,28,-1,28,22,37,43,-1,22,19,34,37,-1,19,17,32,34,-1,17,16,31,32,-1,31,36,43,37,34,32,
00472     16,21,20,18,31,36,35,33,   28,25,24,21,43,40,39,36,
00473     26,23,22,19,17,16,-1,26,41,31,16,-1,16,31,32,17,-1,17,32,34,19,-1,19,34,37,22,-1,22,23,38,37,-1,23,26,41,38,-1,41,31,32,34,37,38,
00474     22,27,29,28,37,42,44,43,
00475     // 2
00476     30,41,31,33,45,56,46,48,  31,32,34,37,43,36,-1,31,46,51,36,-1,36,51,58,43,-1,43,37,52,58,-1,37,34,49,52,-1,34,32,47,49,-1,32,31,46,47,-1,46,51,58,52,49,47,
00477     31,36,35,33,46,51,50,48,  43,40,39,36,58,55,54,51,
00478     41,38,37,34,32,31,-1,41,56,46,31,-1,31,46,47,32,-1,32,47,49,34,-1,34,49,52,37,-1,37,38,53,52,-1,38,41,56,53,-1,56,46,47,49,52,53,
00479     37,42,44,43,52,57,59,58
00480   };
00481   int conn2[28]={7,12,14,13, 11,8,7,4,2,1, 13,10,9,6, 1,6,5,3, 1,2,4,7,13,6, 0,11,1,3};
00482   //
00483   MEDCouplingUMesh *ret=MEDCouplingUMesh::New();
00484   ret->setMeshDimension(3);
00485   ret->allocateCells(18);
00486   //
00487   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn);
00488   ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+8);
00489   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+51);
00490   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+59);
00491   ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+67);
00492   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+110);
00493   //
00494   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+118);
00495   ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+126);
00496   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+169);
00497   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+177);
00498   ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+185);
00499   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+228);
00500   //
00501   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+236);
00502   ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+244);
00503   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+287);
00504   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+295);
00505   ret->insertNextCell(INTERP_KERNEL::NORM_POLYHED,43,conn+303);
00506   ret->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+346);
00507   //
00508   ret->finishInsertingCells();
00509   DataArrayDouble *myCoords=DataArrayDouble::New();
00510   myCoords->alloc(60,3);
00511   std::copy(coords,coords+180,myCoords->getPointer());
00512   ret->setCoords(myCoords);
00513   //
00514   mesh2D=MEDCouplingUMesh::New();
00515   mesh2D->setMeshDimension(2);
00516   mesh2D->allocateCells(6);
00517   mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2);
00518   mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+4);
00519   mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+10);
00520   mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+14);
00521   mesh2D->insertNextCell(INTERP_KERNEL::NORM_POLYGON,6,conn2+18);
00522   mesh2D->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+24);
00523   mesh2D->setCoords(myCoords);
00524   myCoords->decrRef();
00525   return ret;
00526 }
00527 
00528 void MEDCouplingBasicsTest::build3DExtrudedUMesh_2(MEDCouplingUMesh *&meshN, MEDCouplingUMesh *&meshTT, MEDCouplingUMesh *&meshTF)
00529 {
00530   const double coordsN[270]={
00531     0, 0, 0, 0.10803000450134277, 0, 0, 0.21606000900268554, 0, 0, 0.28808000564575198, 0, 0, 0.36010002136230468, 0, 0, 0.43212001800537109, 0, 0, 0,
00532     0.072020001411437995, 0, 0.10803000450134277, 0.072020001411437995, 0, 0.21606000900268554, 0.072020001411437995, 0, 0.28808000564575198, 0.072020001411437995,
00533     0, 0.36010002136230468, 0.072020001411437995, 0, 0.43212001800537109, 0.072020001411437995, 0, 0, 0.10803000450134277, 0, 0.10803000450134277,
00534     0.10803000450134277, 0, 0.21606000900268554, 0.10803000450134277, 0, 0.28808000564575198, 0.10803000450134277, 0, 0.36010002136230468, 0.10803000450134277, 0,
00535     0.43212001800537109, 0.10803000450134277, 0, 0, 0.14404000282287599, 0, 0.10803000450134277, 0.14404000282287599, 0, 0.21606000900268554, 0.14404000282287599, 0,
00536     0.28808000564575198, 0.14404000282287599, 0, 0.36010002136230468, 0.14404000282287599, 0, 0.43212001800537109, 0.14404000282287599, 0, 0, 0.21606000900268554, 0,
00537     0.10803000450134277, 0.21606000900268554, 0, 0.21606000900268554, 0.21606000900268554, 0, 0.28808000564575198, 0.21606000900268554, 0, 0.36010002136230468,
00538     0.21606000900268554, 0, 0.43212001800537109, 0.21606000900268554, 0, 0, 0, 2.1364999389648438, 0.10803000450134277, 0, 2.1364999389648438, 0.21606000900268554,
00539     0, 2.1364999389648438, 0.28808000564575198, 0, 2.1364999389648438, 0.36010002136230468, 0, 2.1364999389648438, 0.43212001800537109, 0, 2.1364999389648438, 0,
00540     0.072020001411437995, 2.1364999389648438, 0.10803000450134277, 0.072020001411437995, 2.1364999389648438, 0.21606000900268554, 0.072020001411437995,
00541     2.1364999389648438, 0.28808000564575198, 0.072020001411437995, 2.1364999389648438, 0.36010002136230468, 0.072020001411437995, 2.1364999389648438,
00542     0.43212001800537109, 0.072020001411437995, 2.1364999389648438, 0, 0.10803000450134277, 2.1364999389648438, 0.10803000450134277, 0.10803000450134277,
00543     2.1364999389648438, 0.21606000900268554, 0.10803000450134277, 2.1364999389648438, 0.28808000564575198, 0.10803000450134277, 2.1364999389648438,
00544     0.36010002136230468, 0.10803000450134277, 2.1364999389648438, 0.43212001800537109, 0.10803000450134277, 2.1364999389648438, 0, 0.14404000282287599,
00545     2.1364999389648438, 0.10803000450134277, 0.14404000282287599, 2.1364999389648438, 0.21606000900268554, 0.14404000282287599, 2.1364999389648438,
00546     0.28808000564575198, 0.14404000282287599, 2.1364999389648438, 0.36010002136230468, 0.14404000282287599, 2.1364999389648438, 0.43212001800537109,
00547     0.14404000282287599, 2.1364999389648438, 0, 0.21606000900268554, 2.1364999389648438, 0.10803000450134277, 0.21606000900268554, 2.1364999389648438,
00548     0.21606000900268554, 0.21606000900268554, 2.1364999389648438, 0.28808000564575198, 0.21606000900268554, 2.1364999389648438, 0.36010002136230468,
00549     0.21606000900268554, 2.1364999389648438, 0.43212001800537109, 0.21606000900268554, 2.1364999389648438, 0, 0, 4.2729998779296876, 0.10803000450134277, 0,
00550     4.2729998779296876, 0.21606000900268554, 0, 4.2729998779296876, 0.28808000564575198, 0, 4.2729998779296876, 0.36010002136230468, 0, 4.2729998779296876,
00551     0.43212001800537109, 0, 4.2729998779296876, 0, 0.072020001411437995, 4.2729998779296876, 0.10803000450134277, 0.072020001411437995, 4.2729998779296876, 
00552     0.21606000900268554, 0.072020001411437995, 4.2729998779296876, 0.28808000564575198, 0.072020001411437995, 4.2729998779296876, 0.36010002136230468, 
00553     0.072020001411437995, 4.2729998779296876, 0.43212001800537109, 0.072020001411437995, 4.2729998779296876, 0, 0.10803000450134277, 4.2729998779296876,
00554     0.10803000450134277, 0.10803000450134277, 4.2729998779296876, 0.21606000900268554, 0.10803000450134277, 4.2729998779296876, 0.28808000564575198,
00555     0.10803000450134277, 4.2729998779296876, 0.36010002136230468, 0.10803000450134277, 4.2729998779296876, 0.43212001800537109, 0.10803000450134277, 
00556     4.2729998779296876, 0, 0.14404000282287599, 4.2729998779296876, 0.10803000450134277, 0.14404000282287599, 4.2729998779296876, 0.21606000900268554,
00557     0.14404000282287599, 4.2729998779296876, 0.28808000564575198, 0.14404000282287599, 4.2729998779296876, 0.36010002136230468, 0.14404000282287599,
00558     4.2729998779296876, 0.43212001800537109, 0.14404000282287599, 4.2729998779296876, 0, 0.21606000900268554, 4.2729998779296876, 0.10803000450134277,
00559     0.21606000900268554, 4.2729998779296876, 0.21606000900268554, 0.21606000900268554, 4.2729998779296876, 0.28808000564575198, 0.21606000900268554,
00560     4.2729998779296876, 0.36010002136230468, 0.21606000900268554, 4.2729998779296876, 0.43212001800537109, 0.21606000900268554, 4.2729998779296876};
00561   const int connN[320]={
00562     0, 1, 7, 6, 30, 31, 37, 36, 1, 2, 8, 7, 31, 32, 38, 37, 2, 3, 9, 8, 32, 33, 39, 38, 3, 4, 10, 9, 33, 34, 40, 39, 4, 5, 11, 10, 34, 35, 41, 40, 6,
00563     7, 13, 12, 36, 37, 43, 42, 7, 8, 14, 13, 37, 38, 44, 43, 8, 9, 15, 14, 38, 39, 45, 44, 9, 10, 16, 15, 39, 40, 46, 45, 10, 11, 17, 16, 40, 41, 47,
00564     46, 12, 13, 19, 18, 42, 43, 49, 48, 13, 14, 20, 19, 43, 44, 50, 49, 14, 15, 21, 20, 44, 45, 51, 50, 15, 16, 22, 21, 45, 46, 52, 51, 16, 17, 23,
00565     22, 46, 47, 53, 52, 18, 19, 25, 24, 48, 49, 55, 54, 19, 20, 26, 25, 49, 50, 56, 55, 20, 21, 27, 26, 50, 51, 57, 56, 21, 22, 28, 27, 51, 52, 58,
00566     57, 22, 23, 29, 28, 52, 53, 59, 58, 30, 31, 37, 36, 60, 61, 67, 66, 31, 32, 38, 37, 61, 62, 68, 67, 32, 33, 39, 38, 62, 63, 69, 68, 33, 34, 40,
00567     39, 63, 64, 70, 69, 34, 35, 41, 40, 64, 65, 71, 70, 36, 37, 43, 42, 66, 67, 73, 72, 37, 38, 44, 43, 67, 68, 74, 73, 38, 39, 45, 44, 68, 69, 75,
00568     74, 39, 40, 46, 45, 69, 70, 76, 75, 40, 41, 47, 46, 70, 71, 77, 76, 42, 43, 49, 48, 72, 73, 79, 78, 43, 44, 50, 49, 73, 74, 80, 79, 44, 45, 51,
00569     50, 74, 75, 81, 80, 45, 46, 52, 51, 75, 76, 82, 81, 46, 47, 53, 52, 76, 77, 83, 82, 48, 49, 55, 54, 78, 79, 85, 84, 49, 50, 56, 55, 79, 80, 86,
00570     85, 50, 51, 57, 56, 80, 81, 87, 86, 51, 52, 58, 57, 81, 82, 88, 87, 52, 53, 59, 58, 82, 83, 89, 88};
00571   meshN=MEDCouplingUMesh::New();
00572   meshN->setName("meshExtrudedN");
00573   meshN->setMeshDimension(3);
00574   meshN->allocateCells(40);
00575   for(int i=0;i<40;i++)
00576     meshN->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connN+8*i);
00577   meshN->finishInsertingCells();
00578   DataArrayDouble *myCoords=DataArrayDouble::New();
00579   myCoords->alloc(90,3);
00580   std::copy(coordsN,coordsN+270,myCoords->getPointer());
00581   meshN->setCoords(myCoords);
00582   myCoords->decrRef();
00583   //
00584   meshTT=MEDCouplingUMesh::New();
00585   meshTT->setName("meshExtrudedTT");
00586   meshTT->setMeshDimension(3);
00587   meshTT->allocateCells(200);
00588   for(int i=0;i<200;i++)
00589     meshTT->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connITT[i+1]-connITT[i],connTT+connITT[i]);
00590   meshTT->finishInsertingCells();
00591   myCoords=DataArrayDouble::New();
00592   myCoords->alloc(1720,3);
00593   std::copy(coordsTT,coordsTT+5160,myCoords->getPointer());
00594   meshTT->setCoords(myCoords);
00595   myCoords->decrRef();
00596   //
00597   meshTF=MEDCouplingUMesh::New();
00598   meshTF->setName("meshExtrudedTF");
00599   meshTF->setMeshDimension(3);
00600   meshTF->allocateCells(340);
00601   for(int i=0;i<320;i++)
00602     meshTF->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,connTFH8+8*i);
00603   for(int i=0;i<20;i++)
00604     meshTF->insertNextCell(INTERP_KERNEL::NORM_POLYHED,connTFPOLH_I[i+1]-connTFPOLH_I[i],connTFPOLH+connTFPOLH_I[i]);
00605   meshTF->finishInsertingCells();
00606   myCoords=DataArrayDouble::New();
00607   myCoords->alloc(567,3);
00608   std::copy(coordsTF,coordsTF+1701,myCoords->getPointer());
00609   meshTF->setCoords(myCoords);
00610   myCoords->decrRef();
00611 }
00612 
00613 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshMerged_1()
00614 {
00615   double targetCoords[26]={
00616     -0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7,
00617     0.7,-0.3, 1.7,-0.3, 0.7,0.7, 1.7,0.7
00618   };
00619   int targetConn[24]={
00620     0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4,
00621     9,12,10,9,11,12
00622   };
00623   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00624   targetMesh->setName("merge");
00625   targetMesh->setMeshDimension(2);
00626   targetMesh->allocateCells(10);
00627   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00628   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00629   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00630   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00631   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00632   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+18);
00633   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+21);
00634   targetMesh->finishInsertingCells();
00635   DataArrayDouble *myCoords=DataArrayDouble::New();
00636   myCoords->alloc(13,2);
00637   std::copy(targetCoords,targetCoords+26,myCoords->getPointer());
00638   targetMesh->setCoords(myCoords);
00639   myCoords->decrRef();
00640   return targetMesh;
00641 }
00642 
00643 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveMesh(double dx, double dy)
00644 {
00645   // 1d mesh:
00646   //
00647   //       *
00648   //      /
00649   // *---*
00650   double targetCoords[3*2]=
00651     {
00652       0.+dx,0.+dy, 1.+dx,0.+dy, 2.+dx,1.+dy
00653     };
00654   int targetConn[2*2]={1,2, 0,1};
00655 
00656   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("2Dcurve 1D mesh",1);
00657   targetMesh->allocateCells(2);
00658   for(int i=0;i<2;i++)
00659     targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
00660   targetMesh->finishInsertingCells();
00661   DataArrayDouble *myCoords=DataArrayDouble::New();
00662   myCoords->alloc(3,2);
00663   std::copy(targetCoords,targetCoords+3*2,myCoords->getPointer());
00664   targetMesh->setCoords(myCoords);
00665   myCoords->decrRef();
00666   return targetMesh;
00667 }
00668 
00669 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMesh(double dx)
00670 {
00671   double targetCoords[4]=
00672     {
00673       0.+dx, 1.+dx, 3.+dx, 4.+dx
00674     };
00675   int targetConn[2*3]={1,2, 0,1, 2,3};
00676 
00677   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("1D mesh",1);
00678   targetMesh->allocateCells(3);
00679   for(int i=0;i<3;i++)
00680     targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
00681   targetMesh->finishInsertingCells();
00682   DataArrayDouble *myCoords=DataArrayDouble::New();
00683   myCoords->alloc(4,1);
00684   std::copy(targetCoords,targetCoords+4,myCoords->getPointer());
00685   targetMesh->setCoords(myCoords);
00686   myCoords->decrRef();
00687   return targetMesh;
00688 }
00689 
00690 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DSourceMesh_2()
00691 {
00692   MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1);
00693   ret->allocateCells(4);
00694   int conn[8]={0,1,2,3,1,2,3,4};
00695   for(int i=0;i<4;i++)
00696     ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
00697   ret->finishInsertingCells();
00698   double coords[5]={0.3,0.7,0.9,1.0,1.12};
00699   DataArrayDouble *myCoords=DataArrayDouble::New();
00700   myCoords->alloc(5,1);
00701   std::copy(coords,coords+5,myCoords->getPointer());
00702   ret->setCoords(myCoords);
00703   myCoords->decrRef();
00704   return ret;
00705 }
00706 
00707 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_2()
00708 {
00709   MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1);
00710   ret->allocateCells(2);
00711   int conn[4]={1,2,0,1};
00712   for(int i=0;i<2;i++)
00713     ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
00714   ret->finishInsertingCells();
00715   double coords[3]={0.5,0.75,1.2};
00716   DataArrayDouble *myCoords=DataArrayDouble::New();
00717   myCoords->alloc(3,1);
00718   std::copy(coords,coords+3,myCoords->getPointer());
00719   ret->setCoords(myCoords);
00720   myCoords->decrRef();
00721   return ret;
00722 }
00723 
00724 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveSourceMesh_2()
00725 {
00726   MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DSourceMesh",1);
00727   ret->allocateCells(4);
00728   int conn[8]={0,1,2,3,1,2,3,4};
00729   for(int i=0;i<4;i++)
00730     ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
00731   ret->finishInsertingCells();
00732   double coords[10]={0.3,0.3,0.7,0.7,0.9,0.9,1.0,1.0,1.12,1.12};
00733   DataArrayDouble *myCoords=DataArrayDouble::New();
00734   myCoords->alloc(5,2);
00735   std::copy(coords,coords+10,myCoords->getPointer());
00736   ret->setCoords(myCoords);
00737   myCoords->decrRef();
00738   return ret;
00739 }
00740 
00741 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_2()
00742 {
00743   MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DTargetMesh",1);
00744   ret->allocateCells(2);
00745   int conn[4]={1,2,0,1};
00746   for(int i=0;i<2;i++)
00747     ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2*i);
00748   ret->finishInsertingCells();
00749   double coords[6]={0.5,0.5,0.75,0.75,1.2,1.2};
00750   DataArrayDouble *myCoords=DataArrayDouble::New();
00751   myCoords->alloc(3,2);
00752   std::copy(coords,coords+6,myCoords->getPointer());
00753   ret->setCoords(myCoords);
00754   myCoords->decrRef();
00755   return ret;
00756 }
00757 
00758 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_3()
00759 {
00760   MEDCouplingUMesh *ret=MEDCouplingUMesh::New("1DMesh_3",1);
00761   ret->allocateCells(4);
00762   int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8};
00763   ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn);
00764   ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3);
00765   ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5);
00766   ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8);
00767   ret->finishInsertingCells();
00768   double coords[10]={0.5,1.,0.8,5.,5.21,0.5,1.1,0.7,5.,5.31};
00769   DataArrayDouble *myCoords=DataArrayDouble::New();
00770   myCoords->alloc(10,1);
00771   std::copy(coords,coords+10,myCoords->getPointer());
00772   ret->setCoords(myCoords);
00773   myCoords->decrRef();
00774   return ret;
00775 }
00776 
00777 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DCurveTargetMesh_3()
00778 {
00779   MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DCurveMesh_3",1);
00780   ret->allocateCells(4);
00781   int conn[10]={0,1,2, 3,4, 6,5,7 ,9,8};
00782   ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn);
00783   ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+3);
00784   ret->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+5);
00785   ret->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+8);
00786   ret->finishInsertingCells();
00787   double coords[20]={0.5,0.5,1.,1.,0.8,0.8,5.,5.,5.21,5.21,0.5,0.5,1.1,1.1,0.7,0.7,5.,5.,5.31,5.31};
00788   DataArrayDouble *myCoords=DataArrayDouble::New();
00789   myCoords->alloc(10,2);
00790   std::copy(coords,coords+20,myCoords->getPointer());
00791   ret->setCoords(myCoords);
00792   myCoords->decrRef();
00793   return ret;
00794 }
00795 
00796 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_3()
00797 {
00798   MEDCouplingUMesh *ret=MEDCouplingUMesh::New("2DMesh_3",2);
00799   ret->allocateCells(10);
00800   int conn[52]={
00801     0,1,2, 0,1,3,4, 0,1,3,5,4, 0,1,2,6,7,8, 0,1,3,4,6,9,2,10,
00802     0,2,1, 0,4,3,1, 0,4,5,3,1, 0,2,1,8,7,6, 0,4,3,1,10,2,9,6
00803   };
00804   ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
00805   ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+3);
00806   ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+7);
00807   ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+12);
00808   ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+18);
00809   ret->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn+26);
00810   ret->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+29);
00811   ret->insertNextCell(INTERP_KERNEL::NORM_POLYGON,5,conn+33);
00812   ret->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+38);
00813   ret->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+44);
00814   ret->finishInsertingCells();
00815   double coords[22]={0.,0.,1.,0.,0.5,1.,1.,1.,0.,1.,0.5,2.,0.5,0.,0.75,0.5,0.25,0.5,1.,0.5,0.,0.5};
00816   DataArrayDouble *myCoords=DataArrayDouble::New();
00817   myCoords->alloc(11,2);
00818   std::copy(coords,coords+22,myCoords->getPointer());
00819   ret->setCoords(myCoords);
00820   myCoords->decrRef();
00821   ret->checkCoherency();
00822   return ret;
00823 }
00824 
00828 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_4()
00829 {
00830   double targetCoords[20]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
00831   int targetConn[18]={0,4,5,1, 1,5,3, 5,6,2, 7,8,5,4, 8,9,6,5};
00832   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
00833   targetMesh->setMeshDimension(2);
00834   targetMesh->allocateCells(5);
00835   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00836   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00837   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00838   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00839   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00840   targetMesh->finishInsertingCells();
00841   DataArrayDouble *myCoords=DataArrayDouble::New();
00842   myCoords->alloc(10,2);
00843   std::copy(targetCoords,targetCoords+20,myCoords->getPointer());
00844   targetMesh->setCoords(myCoords);
00845   myCoords->decrRef();
00846   return targetMesh;
00847 }
00848 
00849 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_3()
00850 {
00851   return 0;
00852 }
00853 
00854 MEDCouplingMultiFields *MEDCouplingBasicsTest::buildMultiFields_1()
00855 {
00856   ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
00857   m1->setName("m1");
00858   ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
00859   m2->setName("m2");
00860   const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
00861   const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
00862   const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
00863   const double vals2[]={5.,6.,7.,8.,9.};
00864   const double vals4[]={15.,16.,17.,18.,19.};
00865   //
00866   ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
00867   ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
00868   ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
00869   ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
00870   ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
00871   //
00872   d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
00873   d0->setInfoOnComponent(0,"c1");
00874   d1->setInfoOnComponent(0,"c6");
00875   d1_1->setInfoOnComponent(0,"c9");
00876   d2->setInfoOnComponent(0,"c5");
00877   d4->setInfoOnComponent(0,"c7");
00878   //
00879   ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00880   f0->setMesh(m1);
00881   f0->setArray(d0);
00882   f0->setTime(0.2,5,6);
00883   f0->setName("f0");
00884   ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
00885   f1->setMesh(m1);
00886   std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
00887   f1->setArrays(d1s);
00888   f1->setStartTime(0.7,7,8);
00889   f1->setEndTime(1.2,9,10);
00890   f1->setName("f1");
00891   ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
00892   f2->setMesh(m2);
00893   f2->setArray(d2);
00894   f2->setTime(1.2,11,12);
00895   f2->setEndTime(1.5,13,14);
00896   f2->setName("f2");
00897   ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00898   f3->setMesh(m1);
00899   f3->setArray(d2);
00900   f3->setTime(1.7,15,16);
00901   f3->setName("f3");
00902   ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
00903   f4->setMesh(m2);
00904   f4->setArray(d4);
00905   f4->setName("f4");
00906   //
00907   std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
00908   fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
00909   ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
00910   //
00911   m1->decrRef();
00912   m2->decrRef();
00913   d0->decrRef();
00914   d1->decrRef();
00915   d1_1->decrRef();
00916   d2->decrRef();
00917   d4->decrRef();
00918   f0->decrRef();
00919   f1->decrRef();
00920   f2->decrRef();
00921   f3->decrRef();
00922   f4->decrRef();
00923   //
00924   return ret;
00925 }
00926 
00927 std::vector<MEDCouplingFieldDouble *> MEDCouplingBasicsTest::buildMultiFields_2()
00928 {
00929   ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
00930   m1->setName("m1");
00931   ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
00932   m2->setName("m2");
00933   const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
00934   const double vals1[]={0.,1.,2.,3.,4.};
00935   const double vals1_1[]={170.,171.,172.,173.,174.};
00936   const double vals2[]={5.,6.,7.,8.,9.};
00937   const double vals4[]={15.,16.,17.,18.,19.};
00938   //
00939   ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
00940   ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
00941   ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
00942   ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
00943   ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
00944   //
00945   d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
00946   d0->setInfoOnComponent(0,"c1");
00947   d1->setInfoOnComponent(0,"c6");
00948   d1_1->setInfoOnComponent(0,"c9");
00949   d2->setInfoOnComponent(0,"c5");
00950   d4->setInfoOnComponent(0,"c7");
00951   //
00952   ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00953   f0->setMesh(m1);
00954   f0->setArray(d0);
00955   f0->setTime(0.2,5,6);
00956   f0->setName("f0");
00957   ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
00958   f1->setMesh(m1);
00959   std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
00960   f1->setArrays(d1s);
00961   f1->setStartTime(0.7,7,8);
00962   f1->setEndTime(1.2,9,10);
00963   f1->setName("f1");
00964   ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
00965   f2->setMesh(m2);
00966   f2->setArray(d2);
00967   f2->setTime(1.2,11,12);
00968   f2->setEndTime(1.5,13,14);
00969   f2->setName("f2");
00970   ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00971   f3->setMesh(m1);
00972   f3->setArray(d2);
00973   f3->setTime(1.7,15,16);
00974   f3->setName("f3");
00975   ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
00976   f4->setMesh(m2);
00977   f4->setArray(d4);
00978   f4->setName("f4");
00979   //
00980   std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
00981   fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
00982   m1->decrRef();
00983   m2->decrRef();
00984   d0->decrRef();
00985   d1->decrRef();
00986   d1_1->decrRef();
00987   d2->decrRef();
00988   d4->decrRef();
00989   //
00990   return fs;
00991 }
00992 
00993 MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMultiTypes_1()
00994 {
00995   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi1DMesh",1);
00996   DataArrayDouble *coo=buildCoordsForMultiTypes_1();
00997   const int conn[5]={0,2, 0,2,1};
00998   mesh->allocateCells(2);
00999   mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
01000   mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+2);
01001   mesh->finishInsertingCells();
01002   mesh->setCoords(coo);
01003   coo->decrRef();
01004   return mesh;
01005 }
01006 
01007 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DMultiTypes_1()
01008 {
01009   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi2DMesh",2);
01010   DataArrayDouble *coo=buildCoordsForMultiTypes_1();
01011   const int conn[21]={3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15};
01012   mesh->allocateCells(4);
01013   mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
01014   mesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+3);
01015   mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+9);
01016   mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+13);
01017   mesh->finishInsertingCells();
01018   mesh->setCoords(coo);
01019   coo->decrRef();
01020   return mesh;
01021 }
01022 
01023 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DMultiTypes_1()
01024 {
01025   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi3DMesh",3);
01026   DataArrayDouble *coo=buildCoordsForMultiTypes_1();
01027   const int conn[81]={0,16,17,18,
01028                       0,16,17,18,19,20,21,22,23,24,
01029                       0,11,10,9,25,
01030                       0,11,10,9,25,15,14,13,12,26,27,28,29,
01031                       0,30,31,32,33,34,
01032                       0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
01033                       0,9,10,11,44,45,46,47,
01034                       0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 };
01035   mesh->allocateCells(8);
01036   mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
01037   mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn+4);
01038   mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+14);
01039   mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA13,13,conn+19);
01040   mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+32);
01041   mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA15,15,conn+38);
01042   mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+53);
01043   mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20,conn+61);
01044   mesh->finishInsertingCells();
01045   mesh->setCoords(coo);
01046   coo->decrRef();
01047   return mesh;
01048 }
01049 
01050 DataArrayDouble *MEDCouplingBasicsTest::buildCoordsForMultiTypes_1()
01051 {
01052   DataArrayDouble *coords=DataArrayDouble::New();
01053   coords->alloc(56,3);
01054   coords->setInfoOnComponent(0,"X (cm)");
01055   coords->setInfoOnComponent(1,"Y (cm)");
01056   coords->setInfoOnComponent(2,"Z (cm)");
01057   const double data[168]={
01058     0.0, 0.0, 0.0, //#0
01059     0.5, 0.5, 0.5, //#1
01060     1.0, 1.0, 1.0, //#2
01061     1.0, 1.0, 0.0, //#3
01062     2.0, 2.5, 0.0, //#4
01063     6.0, 1.5, 0.0, //#5
01064     1.0, 2.0, 0.0, //#6
01065     4.5, 2.5, 0.0, //#7
01066     4.0, 0.5, 0.0, //#8
01067     0.0, 4.0, 0.0, //#9
01068     4.0, 4.0, 0.0, //#10
01069     4.0, 0.0, 0.0, //#11
01070     0.0, 2.0, 0.0, //#12
01071     2.0, 4.0, 0.0, //#13
01072     4.0, 2.0, 0.0, //#14
01073     2.0, 0.0, 0.0, //#15
01074     0.0, 6.0, 0.0, //#16
01075     3.0, 3.0, 0.0, //#17
01076     1.3, 3.0, 3.0, //#18
01077     0.0, 3.0, 0.0, //#19
01078     1.5, 4.5, 0.0, //#20
01079     1.5, 1.5, 0.0, //#21
01080     0.65, 1.5, 1.5, //#22
01081     0.65, 4.5, 1.5, //#23
01082     2.15, 3.0, 1.5, //#24
01083     2.0, 2.0, 2.0, //#25
01084     3.0, 1.0, 1.0, //#26
01085     3.0, 3.0, 1.0, //#27
01086     1.0, 3.0, 1.0, //#28
01087     1.0, 1.0, 1.0, //#29
01088     0.0, 3.0, 0.0, //#30
01089     2.0, 0.0, 0.0, //#31
01090     0.0, 0.0, 6.0, //#32
01091     0.0, 3.0, 6.0, //#33
01092     3.0, 0.0, 6.0, //#34
01093     0.0, 1.5, 0.0, //#35
01094     1.5, 1.5, 0.0, //#36
01095     1.5, 0.0, 0.0, //#37
01096     0.0, 1.5, 6.0, //#38
01097     1.5, 1.5, 6.0, //#39
01098     1.5, 0.0, 6.0, //#40
01099     0.0, 0.0, 3.0, //#41
01100     0.0, 3.0, 3.0, //#42
01101     3.0, 0.0, 3.0, //#43
01102     0.0, 0.0, 4.0, //#44
01103     0.0, 4.0, 4.0, //#45
01104     4.0, 4.0, 4.0, //#46
01105     4.0, 0.0, 4.0, //#47
01106     0.0, 2.0, 4.0, //#48
01107     2.0, 4.0, 4.0, //#49
01108     4.0, 2.0, 4.0, //#50
01109     2.0, 0.0, 4.0, //#51
01110     0.0, 0.0, 2.0, //#52
01111     0.0, 4.0, 2.0, //#53
01112     4.0, 4.0, 2.0, //#54
01113     4.0, 0.0, 2.0  //#55
01114   };
01115   std::copy(data,data+168,coords->getPointer());
01116   return coords;
01117 }
01118 
01119 MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1()
01120 {
01121   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Hexa8Only",3);
01122   DataArrayDouble *coo=DataArrayDouble::New();
01123   const double coords[81]={0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0};
01124   coo->alloc(27,3);
01125   std::copy(coords,coords+81,coo->getPointer());
01126   const int conn[64]={3,12,13,4,0,9,10,1,
01127                       4,13,14,5,1,10,11,2,
01128                       6,15,16,7,3,12,13,4,
01129                       7,16,17,8,4,13,14,5,
01130                       12,21,22,13,9,18,19,10,
01131                       13,22,23,14,10,19,20,11,
01132                       15,24,25,16,12,21,22,13,
01133                       16,25,26,17,13,22,23,14};
01134   mesh->allocateCells(8);
01135   for(int i=0;i<8;i++)
01136     mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
01137   mesh->finishInsertingCells();
01138   mesh->setCoords(coo);
01139   coo->decrRef();
01140   return mesh;
01141 }
01142 
01143 MEDCouplingUMesh *MEDCouplingBasicsTest::buildPointe_1(MEDCouplingUMesh *& m1)
01144 {
01145   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Pointe.med",3);
01146   MEDCouplingUMesh *mesh2=MEDCouplingUMesh::New("Pointe.med",2);
01147   const double coords[57]={0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0};
01148   const int conn[74]={0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13};
01149   DataArrayDouble *coo=DataArrayDouble::New();
01150   coo->alloc(19,3);
01151   std::copy(coords,coords+57,coo->getPointer());
01152   mesh->setCoords(coo);
01153   mesh2->setCoords(coo);
01154   coo->decrRef();
01155   mesh->allocateCells(16);
01156   for(int i=0;i<12;i++)
01157     mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+4*i);
01158   mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+48);
01159   mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+53);
01160   mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+58);
01161   mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+66);
01162   mesh->finishInsertingCells();
01163   //[1,34,29,23,41,32]
01164   const int conn2[20]={0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9};
01165   mesh2->allocateCells(6);
01166   for(int i=0;i<4;i++)
01167     mesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn2+3*i);
01168   mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+12);
01169   mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+16);
01170   mesh2->finishInsertingCells();
01171   m1=mesh2;
01172   //
01173   return mesh;
01174 }
01175 
01176 double MEDCouplingBasicsTest::sumAll(const std::vector< std::map<int,double> >& matrix)
01177 {
01178   double ret=0.;
01179   for(std::vector< std::map<int,double> >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++)
01180     for(std::map<int,double>::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++)
01181       ret+=(*iter2).second;
01182   return ret;
01183 }
01184 
01185 MEDCouplingUMesh *MEDCouplingBasicsTest::build2D1DSourceMesh()
01186 {
01187   double sourceCoords[18]={-17., 3.,  -17., 8.,   -5., 8.,
01188                             -5., 3.,   -9., 0.,  -13., 3.,
01189                             -9., 8.,   -7., 0.,   -7., 8.
01190   };
01191   int sourceConn[16]={0,1, 1,2, 2,3, 3,0, 3,4, 4,5, 4,6, 7,8};
01192   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
01193   sourceMesh->setMeshDimension(1);
01194   sourceMesh->allocateCells(8);
01195   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn);
01196   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+2);
01197   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+4);
01198   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+6);
01199   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+8);
01200   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+10);
01201   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+12);
01202   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn+14);
01203   sourceMesh->finishInsertingCells();
01204   DataArrayDouble *myCoords=DataArrayDouble::New();
01205   myCoords->alloc(9,2);
01206   std::copy(sourceCoords,sourceCoords+18,myCoords->getPointer());
01207   sourceMesh->setCoords(myCoords);
01208   myCoords->decrRef();
01209   return sourceMesh;
01210 }
01211 
01212 MEDCouplingUMesh *MEDCouplingBasicsTest::build2D1DTargetMesh()
01213 {
01214   double targetCoords[10]={-17., 0., -17.,6., -9.,6., -9.,0., -5., 3.};
01215   int targetConn[7]={0,1,2,3, 2,3,4};
01216   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
01217   targetMesh->setMeshDimension(2);
01218   targetMesh->allocateCells(2);
01219   targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
01220   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,targetConn + 4);
01221   targetMesh->finishInsertingCells();
01222   DataArrayDouble *myCoords=DataArrayDouble::New();
01223   myCoords->alloc(5,2);
01224   std::copy(targetCoords,targetCoords+10,myCoords->getPointer());
01225   targetMesh->setCoords(myCoords);
01226   myCoords->decrRef();
01227   return targetMesh;
01228 }
01229 
01230 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DSegSourceMesh(const double shiftX,
01231                                                                 const double inclinationX)
01232 {
01233   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
01234   sourceMesh->setMeshDimension(1);
01235 
01236   const int nbY = 4;
01237   const int nbYP1 = nbY + 1;
01238   sourceMesh->allocateCells(nbY);
01239 
01240   int sourceConn[2];
01241   for (int iY = 0; iY < nbY; ++iY)
01242     {
01243       sourceConn[0] = iY    ;
01244       sourceConn[1] = iY + 1;
01245       sourceMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,sourceConn);
01246     }
01247   sourceMesh->finishInsertingCells();
01248 
01249   std::vector<double> sourceCoords;
01250   for (int iY = 0; iY < nbYP1; ++iY)
01251     {
01252       sourceCoords.push_back(iY * inclinationX + shiftX);
01253       sourceCoords.push_back(iY * 4.);
01254     }
01255   DataArrayDouble *myCoords=DataArrayDouble::New();
01256   myCoords->alloc(nbYP1,2);
01257   std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
01258   sourceMesh->setCoords(myCoords);
01259   myCoords->decrRef();
01260 
01261   return sourceMesh;
01262 }
01263 
01264 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DQuadTargetMesh(const double inclinationX)
01265 {
01266   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
01267   targetMesh->setMeshDimension(2);
01268 
01269   const int nbX = 5;
01270   const int nbY = 4;
01271   const int nbXP1 = nbX + 1;
01272   const int nbYP1 = nbY + 1;
01273   targetMesh->allocateCells(nbX * nbY);
01274 
01275   int targetConn[4];
01276   for (int iX = 0; iX < nbX; ++iX)
01277     {
01278       for (int iY = 0; iY < nbY; ++iY)
01279         {
01280           targetConn[0] = iY     +  iX      * nbYP1;
01281           targetConn[1] = iY + 1 +  iX      * nbYP1;
01282           targetConn[2] = iY + 1 + (iX + 1) * nbYP1;
01283           targetConn[3] = iY     + (iX + 1) * nbYP1;
01284           targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
01285         }
01286     }
01287   targetMesh->finishInsertingCells();
01288 
01289   std::vector<double> targetCoords;
01290   for (int iX = 0; iX < nbXP1; ++iX)
01291     {
01292       for (int iY = 0; iY < nbYP1; ++iY)
01293         {
01294           targetCoords.push_back(iX * 3. + iY * inclinationX);
01295           targetCoords.push_back(iY * 4.);
01296         }
01297     }
01298   DataArrayDouble *myCoords=DataArrayDouble::New();
01299   myCoords->alloc(nbXP1 * nbYP1, 2);
01300   std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
01301   targetMesh->setCoords(myCoords);
01302   myCoords->decrRef();
01303 
01304   return targetMesh;
01305 }
01306 
01307 MEDCouplingUMesh* MEDCouplingBasicsTest::build2D1DTriTargetMesh(const double inclinationX)
01308 {
01309   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
01310   targetMesh->setMeshDimension(2);
01311 
01312   const int nbX = 5;
01313   const int nbY = 4;
01314   const int nbXP1 = nbX + 1;
01315   const int nbYP1 = nbY + 1;
01316   targetMesh->allocateCells(nbX * nbY * 2);
01317 
01318   int targetConn[3];
01319   for (int iX = 0; iX < nbX; ++iX)
01320     {
01321       for (int iY = 0; iY < nbY; ++iY)
01322         {
01323           targetConn[0] = iY     +  iX      * nbYP1;
01324           targetConn[1] = iY + 1 +  iX      * nbYP1;
01325           targetConn[2] = iY + 1 + (iX + 1) * nbYP1;
01326           targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
01327           targetConn[0] = iY     +  iX      * nbYP1;
01328           targetConn[1] = iY + 1 + (iX + 1) * nbYP1;
01329           targetConn[2] = iY     + (iX + 1) * nbYP1;
01330           targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
01331         }
01332     }
01333   targetMesh->finishInsertingCells();
01334 
01335   std::vector<double> targetCoords;
01336   for (int iX = 0; iX < nbXP1; ++iX)
01337     {
01338       for (int iY = 0; iY < nbYP1; ++iY)
01339         {
01340           targetCoords.push_back(iX * 3. + iY * inclinationX);
01341           targetCoords.push_back(iY * 4.);
01342         }
01343     }
01344   DataArrayDouble *myCoords=DataArrayDouble::New();
01345   myCoords->alloc(nbXP1 * nbYP1, 2);
01346   std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
01347   targetMesh->setCoords(myCoords);
01348   myCoords->decrRef();
01349 
01350   return targetMesh;
01351 }
01352 
01353 MEDCouplingUMesh *MEDCouplingBasicsTest::build3D2DSourceMesh()
01354 {
01355   double sourceCoords[63]={-12., 6., 10., -12.,10.,  6., -16.,10. , 10.,
01356                            -20., 0.,  0., -12., 0.,  0., -12., 0. , -4., -20.,0.,-4.,
01357                            -20., 0., 10., -12., 0., 10., -20.,10. , 10.,
01358                            -25., 5., -5.,   5., 5., -5.,   5., 5. , 25., -25.,5.,25.,
01359                            -20., 0., 16., -18., 0., 16., -20., 2.5, 16.,
01360                            -25., 0., -5.,   5., 0., -5.,   5., 0. , 25., -25.,0.,25.
01361   };
01362   int sourceConn[25]={0,1,2, 3,4,5,6, 7,8,9, 10,11,12,13, 14,15,16, 3,4,8,7, 17,18,19,20};
01363   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
01364   sourceMesh->setMeshDimension(2);
01365   sourceMesh->allocateCells(7);
01366   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn);
01367   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+3);
01368   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn+7);
01369   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+10);
01370   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3 ,3,sourceConn+14);
01371   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+17);
01372   sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn+21);
01373   sourceMesh->finishInsertingCells();
01374   DataArrayDouble *myCoords=DataArrayDouble::New();
01375   myCoords->alloc(21,3);
01376   std::copy(sourceCoords,sourceCoords+63,myCoords->getPointer());
01377   sourceMesh->setCoords(myCoords);
01378   myCoords->decrRef();
01379   return sourceMesh;
01380 }
01381 
01382 MEDCouplingUMesh *MEDCouplingBasicsTest::build3D2DTargetMesh()
01383 {
01384   double targetCoords[45]={-20., 0., 0., -20.,10., 0., -12.,10., 0.,
01385                            -12., 0., 0., -20., 0.,10., -20.,10.,10.,
01386                            -12.,10.,10., -12., 0.,10., -20., 0.,18.,
01387                            -20.,-5.,10., -20.,-5.,-4., -12.,-5.,-4.,
01388                            -12.,-5.,10., -20., 0.,-4., -12., 0.,-4.
01389   };
01390   int targetConn[20]={4,5,7,8, 0,3,2,1,4,7,6,5, 4,13,14,7,9,10,11,12};
01391   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
01392   targetMesh->setMeshDimension(3);
01393   targetMesh->allocateCells(3);
01394   targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
01395   targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn + 4);
01396   targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn + 12);
01397   targetMesh->finishInsertingCells();
01398   DataArrayDouble *myCoords=DataArrayDouble::New();
01399   myCoords->alloc(15,3);
01400   std::copy(targetCoords,targetCoords+45,myCoords->getPointer());
01401   targetMesh->setCoords(myCoords);
01402   myCoords->decrRef();
01403   return targetMesh;
01404 }
01405 
01406 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DQuadSourceMesh(const double shiftX,
01407                                                                  const double inclinationX)
01408 {
01409   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
01410   sourceMesh->setMeshDimension(2);
01411 
01412   const int nbY = 4;
01413   const int nbZ = 5;
01414   const int nbYP1 = nbY + 1;
01415   const int nbZP1 = nbZ + 1;
01416   sourceMesh->allocateCells(nbY * nbZ);
01417 
01418   int sourceConn[4];
01419   for (int iY = 0; iY < nbY; ++iY)
01420     {
01421       for (int iZ = 0; iZ < nbZ; ++iZ)
01422         {
01423           sourceConn[0] = iZ     +  iY      * nbZP1;
01424           sourceConn[1] = iZ + 1 +  iY      * nbZP1;
01425           sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
01426           sourceConn[3] = iZ     + (iY + 1) * nbZP1;
01427           sourceMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,sourceConn);
01428         }
01429     }
01430   sourceMesh->finishInsertingCells();
01431 
01432   std::vector<double> sourceCoords;
01433   for (int iY = 0; iY < nbYP1; ++iY)
01434     {
01435       for (int iZ = 0; iZ < nbZP1; ++iZ)
01436         {
01437             sourceCoords.push_back(iY * inclinationX + shiftX);
01438             sourceCoords.push_back(iY * 4.);
01439             sourceCoords.push_back(iZ * 3.);
01440         }
01441 
01442     }
01443   DataArrayDouble *myCoords=DataArrayDouble::New();
01444   myCoords->alloc(nbYP1 * nbZP1,3);
01445   std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
01446   sourceMesh->setCoords(myCoords);
01447   myCoords->decrRef();
01448 
01449   return sourceMesh;
01450 }
01451 
01452 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTriSourceMesh(const double shiftX,
01453                                                                 const double inclinationX)
01454 {
01455   MEDCouplingUMesh *sourceMesh=MEDCouplingUMesh::New();
01456   sourceMesh->setMeshDimension(2);
01457 
01458   const int nbY = 4;
01459   const int nbZ = 5;
01460   const int nbYP1 = nbY + 1;
01461   const int nbZP1 = nbZ + 1;
01462   sourceMesh->allocateCells(nbY * nbZ * 2);
01463 
01464   int sourceConn[3];
01465   for (int iY = 0; iY < nbY; ++iY)
01466     {
01467       for (int iZ = 0; iZ < nbZ; ++iZ)
01468         {
01469         sourceConn[0] = iZ     +  iY      * nbZP1;
01470         sourceConn[1] = iZ + 1 +  iY      * nbZP1;
01471         sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
01472         sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
01473         sourceConn[0] = iZ     +  iY      * nbZP1;
01474         sourceConn[1] = iZ     + (iY + 1) * nbZP1;
01475         sourceConn[2] = iZ + 1 + (iY + 1) * nbZP1;
01476         sourceMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,sourceConn);
01477         }
01478     }
01479   sourceMesh->finishInsertingCells();
01480 
01481   std::vector<double> sourceCoords;
01482   for (int iY = 0; iY < nbYP1; ++iY)
01483     {
01484       for (int iZ = 0; iZ < nbZP1; ++iZ)
01485         {
01486             sourceCoords.push_back(iY * inclinationX + shiftX);
01487             sourceCoords.push_back(iY * 4.);
01488             sourceCoords.push_back(iZ * 3.);
01489         }
01490 
01491     }
01492   DataArrayDouble *myCoords=DataArrayDouble::New();
01493   myCoords->alloc(nbYP1 * nbZP1,3);
01494   std::copy(sourceCoords.begin(),sourceCoords.end(),myCoords->getPointer());
01495   sourceMesh->setCoords(myCoords);
01496   myCoords->decrRef();
01497 
01498   return sourceMesh;
01499 }
01500 
01501 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DHexaTargetMesh(const double inclinationX)
01502 {
01503   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
01504   targetMesh->setMeshDimension(3);
01505 
01506   const int nbX = 5;
01507   const int nbY = 4;
01508   const int nbZ = 5;
01509   const int nbXP1 = nbX + 1;
01510   const int nbYP1 = nbY + 1;
01511   const int nbZP1 = nbZ + 1;
01512   targetMesh->allocateCells(nbX * nbY * nbZ);
01513 
01514   int targetConn[8];
01515   for (int iX = 0; iX < nbX; ++iX)
01516     {
01517       for (int iY = 0; iY < nbY; ++iY)
01518         {
01519           for (int iZ = 0; iZ < nbZ; ++iZ)
01520             {
01521               targetConn[0] = iZ     + ( iY      +  iX      * nbYP1) * nbZP1;
01522               targetConn[1] = iZ + 1 + ( iY      +  iX      * nbYP1) * nbZP1;
01523               targetConn[2] = iZ + 1 + ((iY + 1) +  iX      * nbYP1) * nbZP1;
01524               targetConn[3] = iZ     + ((iY + 1) +  iX      * nbYP1) * nbZP1;
01525               targetConn[4] = iZ     + ( iY      + (iX + 1) * nbYP1) * nbZP1;
01526               targetConn[5] = iZ + 1 + ( iY      + (iX + 1) * nbYP1) * nbZP1;
01527               targetConn[6] = iZ + 1 + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
01528               targetConn[7] = iZ     + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
01529               targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn);
01530             }
01531         }
01532     }
01533   targetMesh->finishInsertingCells();
01534 
01535   std::vector<double> targetCoords;
01536   for (int iX = 0; iX < nbXP1; ++iX)
01537     {
01538       for (int iY = 0; iY < nbYP1; ++iY)
01539         {
01540           for (int iZ = 0; iZ < nbZP1; ++iZ)
01541             {
01542                 targetCoords.push_back(iX * 3. + iY * inclinationX);
01543                 targetCoords.push_back(iY * 4.);
01544                 targetCoords.push_back(iZ * 3.);
01545             }
01546         }
01547     }
01548   DataArrayDouble *myCoords=DataArrayDouble::New();
01549   myCoords->alloc(nbXP1 * nbYP1 * nbZP1, 3);
01550   std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
01551   targetMesh->setCoords(myCoords);
01552   myCoords->decrRef();
01553 
01554   return targetMesh;
01555 }
01556 
01557 MEDCouplingUMesh* MEDCouplingBasicsTest::build3D2DTetraTargetMesh(const double inclinationX)
01558 {
01559   MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
01560   targetMesh->setMeshDimension(3);
01561 
01562   const int nbX = 5;
01563   const int nbY = 4;
01564   const int nbZ = 5;
01565   const int nbXP1 = nbX + 1;
01566   const int nbYP1 = nbY + 1;
01567   const int nbZP1 = nbZ + 1;
01568   targetMesh->allocateCells(nbX * nbY * nbZ * 5);
01569 
01570   int targetConn[4];
01571   for (int iX = 0; iX < nbX; ++iX)
01572     {
01573       for (int iY = 0; iY < nbY; ++iY)
01574         {
01575           for (int iZ = 0; iZ < nbZ; ++iZ)
01576             {
01577               targetConn[0] = iZ     + ( iY      +  iX      * nbYP1) * nbZP1;
01578               targetConn[1] = iZ + 1 + ( iY      +  iX      * nbYP1) * nbZP1;
01579               targetConn[2] = iZ + 1 + ( iY      + (iX + 1) * nbYP1) * nbZP1;
01580               targetConn[3] = iZ + 1 + ((iY + 1) +  iX      * nbYP1) * nbZP1;
01581               targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
01582               targetConn[0] = iZ     + ( iY      +  iX      * nbYP1) * nbZP1;
01583               targetConn[1] = iZ     + ( iY      + (iX + 1) * nbYP1) * nbZP1;
01584               targetConn[2] = iZ + 1 + ( iY      + (iX + 1) * nbYP1) * nbZP1;
01585               targetConn[3] = iZ     + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
01586               targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
01587               targetConn[0] = iZ     + ( iY      +  iX      * nbYP1) * nbZP1;
01588               targetConn[1] = iZ     + ((iY + 1) +  iX      * nbYP1) * nbZP1;
01589               targetConn[2] = iZ     + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
01590               targetConn[3] = iZ + 1 + ((iY + 1) +  iX      * nbYP1) * nbZP1;
01591               targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
01592               targetConn[0] = iZ + 1 + ( iY      + (iX + 1) * nbYP1) * nbZP1;
01593               targetConn[1] = iZ + 1 + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
01594               targetConn[2] = iZ     + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
01595               targetConn[3] = iZ + 1 + ((iY + 1) +  iX      * nbYP1) * nbZP1;
01596               targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
01597               targetConn[0] = iZ     + ( iY      +  iX      * nbYP1) * nbZP1;
01598               targetConn[1] = iZ + 1 + ((iY + 1) +  iX      * nbYP1) * nbZP1;
01599               targetConn[2] = iZ + 1 + ( iY      + (iX + 1) * nbYP1) * nbZP1;
01600               targetConn[3] = iZ     + ((iY + 1) + (iX + 1) * nbYP1) * nbZP1;
01601               targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn);
01602             }
01603         }
01604     }
01605   targetMesh->finishInsertingCells();
01606 
01607   std::vector<double> targetCoords;
01608   for (int iX = 0; iX < nbXP1; ++iX)
01609     {
01610       for (int iY = 0; iY < nbYP1; ++iY)
01611         {
01612           for (int iZ = 0; iZ < nbZP1; ++iZ)
01613             {
01614                 targetCoords.push_back(iX * 3. + iY * inclinationX);
01615                 targetCoords.push_back(iY * 4.);
01616                 targetCoords.push_back(iZ * 3.);
01617             }
01618         }
01619     }
01620   DataArrayDouble *myCoords=DataArrayDouble::New();
01621   myCoords->alloc(nbXP1 * nbYP1 * nbZP1, 3);
01622   std::copy(targetCoords.begin(),targetCoords.end(),myCoords->getPointer());
01623   targetMesh->setCoords(myCoords);
01624   myCoords->decrRef();
01625 
01626   return targetMesh;
01627 }
01628 
01629 int MEDCouplingBasicsTest::countNonZero(const std::vector< std::map<int,double> >& matrix)
01630 {
01631   int ret=0.;
01632   for(std::vector< std::map<int,double> >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++)
01633     for(std::map<int,double>::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++)
01634       if (!INTERP_KERNEL::epsilonEqual((*iter2).second, 0.)) ret +=1;
01635   return ret;
01636 }
01637 
01638 void MEDCouplingBasicsTest::test2D1DMeshesIntersection(MEDCouplingUMesh *sourceMesh,
01639                                                        MEDCouplingUMesh *targetMesh,
01640                                                        const double correctLength,
01641                                                        const int correctDuplicateFacesNbr,
01642                                                        const int correctTotalIntersectFacesNbr)
01643 {
01644   MEDCouplingNormalizedUnstructuredMesh<2,2> sourceWrapper(sourceMesh);
01645   MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
01646   INTERP_KERNEL::Interpolation2D1D myInterpolator;
01647   myInterpolator.setPrecision(1e-12);
01648   const double prec = 1.0e-5;
01649   IntersectionMatrix matrix;
01650   myInterpolator.setIntersectionType(INTERP_KERNEL::Geometric2D);
01651   myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
01652 
01653   std::cout.precision(16);
01654 
01655   const double length = sumAll(matrix);
01656   LOG(1, "length =  " << surf <<"  correctLength = " << correctLength );
01657   CPPUNIT_ASSERT_DOUBLES_EQUAL(correctLength, length, prec * std::max(correctLength, length));
01658 
01659   INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
01660   int duplicateFacesNbr = duplicateFaces.size();
01661   LOG(1, "duplicateFacesNbr =  " << duplicateFacesNbr <<"  correctDuplicateFacesNbr = " <<  correctDuplicateFacesNbr);
01662   CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr);
01663 
01664   if (correctTotalIntersectFacesNbr >= 0)
01665     {
01666       int totalIntersectFacesNbr = countNonZero(matrix);
01667       LOG(1, "totalIntersectFacesNbr =  " << totalIntersectFacesNbr <<"  correctTotalIntersectFacesNbr = " << correctTotalIntersectFacesNbr );
01668       CPPUNIT_ASSERT_EQUAL(correctTotalIntersectFacesNbr, totalIntersectFacesNbr);
01669     }
01670   //clean up
01671   sourceMesh->decrRef();
01672   targetMesh->decrRef();
01673 }
01674 
01675 void MEDCouplingBasicsTest::test3D2DMeshesIntersection(MEDCouplingUMesh *sourceMesh,
01676                                                        MEDCouplingUMesh *targetMesh,
01677                                                        const double correctSurf,
01678                                                        const int correctDuplicateFacesNbr,
01679                                                        const int correctTotalIntersectFacesNbr)
01680 {
01681   MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
01682   MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
01683   INTERP_KERNEL::Interpolation3D2D myInterpolator;
01684   myInterpolator.setPrecision(1e-12);
01685   const double prec = 1.0e-5;
01686   IntersectionMatrix matrix;
01687   INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
01688   for ( size_t i = 0; i < sizeof(sp)/sizeof(sp[0]); ++i )
01689   {
01690     myInterpolator.setSplittingPolicy( sp[i] );
01691     matrix.clear();
01692     myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,matrix,"P0P0");
01693 
01694     std::cout.precision(16);
01695 
01696     const double surf = sumAll(matrix);
01697     LOG(1, "surf =  " << surf <<"  correctSurf = " << correctSurf );
01698     CPPUNIT_ASSERT_DOUBLES_EQUAL(correctSurf, surf, prec * std::max(correctSurf, surf));
01699 
01700     INTERP_KERNEL::Interpolation3D2D::DuplicateFacesType duplicateFaces = myInterpolator.retrieveDuplicateFaces();
01701     int duplicateFacesNbr = duplicateFaces.size();
01702     LOG(1, "duplicateFacesNbr =  " << duplicateFacesNbr <<"  correctDuplicateFacesNbr = " <<  correctDuplicateFacesNbr);
01703     CPPUNIT_ASSERT_EQUAL(correctDuplicateFacesNbr, duplicateFacesNbr);
01704 
01705     if (correctTotalIntersectFacesNbr >= 0)
01706       {
01707         int totalIntersectFacesNbr = countNonZero(matrix);
01708         LOG(1, "totalIntersectFacesNbr =  " << totalIntersectFacesNbr <<"  correctTotalIntersectFacesNbr = " << correctTotalIntersectFacesNbr );
01709         CPPUNIT_ASSERT_EQUAL(correctTotalIntersectFacesNbr, totalIntersectFacesNbr);
01710       }
01711   }
01712   //clean up
01713   sourceMesh->decrRef();
01714   targetMesh->decrRef();
01715 }