]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Thu, 5 Nov 2009 08:54:25 +0000 (08:54 +0000)
committerageay <ageay>
Thu, 5 Nov 2009 08:54:25 +0000 (08:54 +0000)
src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx
src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx

index c36f797c5766c454afd91b968dae9a81b6c7c1ff..722c83d460383329d6c238aaff9efafcc938a962 100644 (file)
@@ -2612,6 +2612,33 @@ void MEDCouplingBasicsTest::test3DInterpP1P0Bary_1()
   targetMesh->decrRef();
 }
 
+void MEDCouplingBasicsTest::test3DTo1DInterpP0P0PL_1()
+{
+  MEDCouplingUMesh *sourceMesh=build3DTargetMesh_1();
+  MEDCouplingUMesh *targetMesh=build1DTargetMesh_1();
+  //
+  MEDCouplingNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh);
+  MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
+  INTERP_KERNEL::Interpolation3D myInterpolator;
+  vector<map<int,double> > res;
+  myInterpolator.setPrecision(1e-12);
+  myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
+  myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
+  CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][4],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][1],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][5],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][2],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][6],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][3],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][7],1e-12);
+  CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,sumAll(res),1e-12);
+  //
+  sourceMesh->decrRef();
+  targetMesh->decrRef();
+}
+
 MEDCouplingUMesh *MEDCouplingBasicsTest::build3DSourceMesh_2()
 {
   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,
@@ -2660,6 +2687,27 @@ MEDCouplingUMesh *MEDCouplingBasicsTest::build3DTargetMesh_2()
   return targetMesh;
 }
 
+MEDCouplingUMesh *MEDCouplingBasicsTest::build1DTargetMesh_1()
+{
+  double targetCoords[36]={
+    25.,25.,0., 25.,25.,50., 25.,25.,200., 75.,25.,0., 75.,25.,50., 75.,25.,200.,
+    25.,125.,0., 25.,125.,50., 25.,125.,200., 125.,125.,0., 125.,125.,50., 125.,125.,200.
+  };
+  int targetConn[16]={0,1, 1,2, 3,4, 4,5, 6,7, 7,8, 9,10, 10,11};
+
+  MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New("my name of mesh 1D",1);
+  targetMesh->allocateCells(8);
+  for(int i=0;i<8;i++)
+    targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn+2*i);
+  targetMesh->finishInsertingCells();
+  DataArrayDouble *myCoords=DataArrayDouble::New();
+  myCoords->alloc(12,3);
+  std::copy(targetCoords,targetCoords+36,myCoords->getPointer());
+  targetMesh->setCoords(myCoords);
+  myCoords->decrRef();
+  return targetMesh;
+}
+
 MEDCouplingUMesh *MEDCouplingBasicsTest::build2DSourceMesh_1()
 {
   double sourceCoords[8]={-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7};
index ee20e215ba96a7f1ae1c3708d8239af71c4be91b..2bf2f30260e1f3bf2c7cbcd2dbc91a682f0be0b0 100644 (file)
@@ -93,6 +93,7 @@ namespace ParaMEDMEM
     CPPUNIT_TEST( test2DInterpP1P0Bary_1 );
     CPPUNIT_TEST( test3DSurfInterpP1P0Bary_1 );
     CPPUNIT_TEST( test3DInterpP1P0Bary_1 );
+    CPPUNIT_TEST( test3DTo1DInterpP0P0PL_1 );
     CPPUNIT_TEST_SUITE_END();
   public:
     void testArray();
@@ -157,9 +158,11 @@ namespace ParaMEDMEM
     void test2DInterpP1P0Bary_1();
     void test3DSurfInterpP1P0Bary_1();
     void test3DInterpP1P0Bary_1();
+    void test3DTo1DInterpP0P0PL_1();
   private:
     MEDCouplingUMesh *build3DSourceMesh_2();
     MEDCouplingUMesh *build3DTargetMesh_2();
+    MEDCouplingUMesh *build1DTargetMesh_1();
     MEDCouplingUMesh *build2DSourceMesh_1();
     MEDCouplingUMesh *build2DTargetMesh_1();
     MEDCouplingUMesh *build2DTargetMeshPerm_1();