Salome HOME
Debug on GENERAL_24 and GENERAL_48
[tools/medcoupling.git] / src / MEDCoupling / Test / MEDCouplingRemapperTest.cxx
index e348d8e51584605c360bf4a7aed9b6953396d425..662ad77a6a7be1a83e097530d1008a353d352d20 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -16,6 +16,7 @@
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+// Author : Anthony Geay (CEA/DEN)
 
 #include "MEDCouplingRemapperTest.hxx"
 #include "MEDCouplingUMesh.hxx"
@@ -1271,3 +1272,47 @@ void MEDCouplingRemapperTest::testPartialTransfer1()
   sourceMesh->decrRef();
   targetMesh->decrRef();
 }
+
+void MEDCouplingRemapperTest::testBugNonRegression1()
+{
+  // source
+  DataArrayDouble *coordsSrc(DataArrayDouble::New());
+  const double coordsSrcData[18]={-6.25,3.6084391824351605,264.85199999999998,-6.25,3.6084391824351605,289.05200000000002,-6.2499999999999991,-3.6084391824351618,264.85199999999998,-6.2499999999999991,-3.6084391824351618,289.05200000000002,-1.7763568394002505e-15,4.4408920985006262e-15,264.85199999999998,-1.7763568394002505e-15,4.4408920985006262e-15,289.05200000000002};
+  coordsSrc->useArray(coordsSrcData,false,CPP_DEALLOC,6,3);
+  DataArrayInt *connSrc(DataArrayInt::New()),*connISrc(DataArrayInt::New());
+  const int connSrcData[7]={16,2,0,4,3,1,5};
+  connSrc->useArray(connSrcData,false,CPP_DEALLOC,7,1);
+  const int connISrcData[2]={0,7};
+  connISrc->useArray(connISrcData,false,CPP_DEALLOC,2,1);
+  MEDCouplingUMesh *srcMesh(MEDCouplingUMesh::New("source",3));
+  srcMesh->setCoords(coordsSrc);
+  srcMesh->setConnectivity(connSrc,connISrc,true);
+  coordsSrc->decrRef(); connSrc->decrRef(); connISrc->decrRef();
+  // target
+  DataArrayDouble *coordsTrg(DataArrayDouble::New());
+const double coordsTrgData[36]={-2,1.1547005383792521,264.85199999999998,-2,0.57735026918962618,264.85199999999998,-2.5,0.2886751345948132,264.85199999999998,-2.5,1.443375672974065,264.85199999999998,-3.0000000000000004,1.1547005383792526,264.85199999999998,-3.0000000000000004,0.57735026918962662,264.85199999999998,-2,1.1547005383792521,289.05200000000002,-2,0.57735026918962618,289.05200000000002,-2.5,0.2886751345948132,289.05200000000002,-2.5,1.443375672974065,289.05200000000002,-3.0000000000000004,1.1547005383792526,289.05200000000002,-3.0000000000000004,0.57735026918962662,289.05200000000002};
+ coordsTrg->useArray(coordsTrgData,false,CPP_DEALLOC,12,3);
+ DataArrayInt *connTrg=DataArrayInt::New();
+ const int connTrgData[44]={31,0,1,2,5,4,3,-1,7,6,9,10,11,8,-1,3,9,6,0,-1,4,10,9,3,-1,5,11,10,4,-1,2,8,11,5,-1,1,7,8,2,-1,0,6,7,1};
+ connTrg->useArray(connTrgData,false,CPP_DEALLOC,44,1);
+ DataArrayInt *connITrg=DataArrayInt::New();
+ const int connITrgData[2]={0,44};
+ connITrg->useArray(connITrgData,false,CPP_DEALLOC,2,1);
+ MEDCouplingUMesh *trgMesh=MEDCouplingUMesh::New("target",3);
+ trgMesh->setCoords(coordsTrg);
+ trgMesh->setConnectivity(connTrg,connITrg,true);
+ coordsTrg->decrRef(); connTrg->decrRef(); connITrg->decrRef();
+ // Go !
+ const double valExpected(20.957814771583468);
+ MEDCouplingRemapper remapper;
+ remapper.setPrecision(1e-12);
+ remapper.setIntersectionType(INTERP_KERNEL::Triangulation);
+ CPPUNIT_ASSERT_EQUAL(1,remapper.prepare(srcMesh,trgMesh,"P0P0"));
+ std::vector<std::map<int,double> > matrx(remapper.getCrudeMatrix());
+ CPPUNIT_ASSERT_EQUAL(1,(int)matrx.size());
+ CPPUNIT_ASSERT_EQUAL(1,(int)matrx[0].size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valExpected,matrx[0][0],1e-13);
+ //
+ srcMesh->decrRef(); trgMesh->decrRef();
+}
+