]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
0021051: [CEA 432] P2 field evaluation
authoreap <eap@opencascade.com>
Wed, 19 Jan 2011 17:22:04 +0000 (17:22 +0000)
committereap <eap@opencascade.com>
Wed, 19 Jan 2011 17:22:04 +0000 (17:22 +0000)
+    CPPUNIT_TEST( test_PointLocatorInSimplex );

src/INTERP_KERNELTest/PointLocatorTest.cxx
src/INTERP_KERNELTest/PointLocatorTest.hxx

index 7262908c30cfe1b2d75d629a69ceb6cd4e27c2e1..8cdc16274134159f10278df695a57acb4d0a6f97 100644 (file)
@@ -99,5 +99,117 @@ namespace INTERP_TEST
 
   }
 
+  /**
+   * Test that the results are correct in three
+   * cases :
+   * a non matching search
+   * a standard case
+   * a bbox overlapping the bboxes of the tree
+   */
+  void PointLocatorTest::test_PointLocatorInSimplex()
+  {
+    MEDMEM::MESH* mesh2D= MEDMeshMaker(2,2,MED_EN::MED_QUAD4);
+    // mesh is a quadrangle (0.0-1.0 x 0.0-1.0 )
+    // 3 -- 6 -- 9
+    // |    |    |
+    // 2 -- 5 -- 8
+    // |    |    |
+    // 1 -- 4 -- 7
+    MEDMEM::PointLocatorInSimplex pl(*mesh2D) ;
+    std::list<int> elems;
+    std::list<int>::iterator elem;
+    {
+      double x[2]={0.0,0.25};
+      elems = pl.locate(x);
+      elem = elems.begin();
+      CPPUNIT_ASSERT_EQUAL(3,(int)elems.size());
+      CPPUNIT_ASSERT_EQUAL(1,*elem++);
+      CPPUNIT_ASSERT_EQUAL(2,*elem++);
+      CPPUNIT_ASSERT_EQUAL(5,*elem++);
+    }
+    {
+      double x[2]={0.25,0.0};
+      elems = pl.locate(x);
+      elem = elems.begin();
+      CPPUNIT_ASSERT_EQUAL(3,(int)elems.size());
+      CPPUNIT_ASSERT_EQUAL(1,*elem++);
+      CPPUNIT_ASSERT_EQUAL(2,*elem++);
+      CPPUNIT_ASSERT_EQUAL(4,*elem++);
+    }
+    {
+      double x[2]={0.25,1.0};
+      elems = pl.locate(x);
+      elem = elems.begin();
+      CPPUNIT_ASSERT_EQUAL(3,(int)elems.size());
+      CPPUNIT_ASSERT_EQUAL(2,*elem++);
+      CPPUNIT_ASSERT_EQUAL(3,*elem++);
+      CPPUNIT_ASSERT_EQUAL(6,*elem++);
+    }
+    {
+      double x[2]={0.4,0.75};
+      elems = pl.locate(x);
+      elem = elems.begin();
+      CPPUNIT_ASSERT_EQUAL(3,(int)elems.size());
+      CPPUNIT_ASSERT_EQUAL(3,*elem++);
+      CPPUNIT_ASSERT_EQUAL(6,*elem++);
+      CPPUNIT_ASSERT_EQUAL(5,*elem++);
+    }
+    {
+      double x[2]={-1.0,0.0};
+      elems = pl.locate(x);
+      CPPUNIT_ASSERT_EQUAL(0,(int)elems.size());
+      delete mesh2D;
+    }
+    MEDMEM::MESH* mesh3D= MEDMeshMaker(3,2,MED_EN::MED_HEXA8);
+    // ^Z
+    // |
+    // 3 -- 6 -- 9
+    // |    |    |
+    // 2 -- 5 -- 8     12 --15 --18
+    // |    |    |     |    |    | 
+    // 1 -- 4 -- 7->Y  11 --14 --17    21 --24 --27
+    //  \              |    |    |     |    |    | 
+    //   \ X           10 --13 --16    20 --23 --26
+    //    v                            |    |    | 
+    //                                 19 --22 --25
+    
+    MEDMEM::PointLocatorInSimplex pl3(*mesh3D);
+    {
+      double x[3]={0.0,0.0,0.0};
+      elems = pl3.locate(x);
+      elem = elems.begin();
+      CPPUNIT_ASSERT_EQUAL(4,(int)elems.size());
+      CPPUNIT_ASSERT_EQUAL(1,*elem++);
+      CPPUNIT_ASSERT_EQUAL(10,*elem++);
+      CPPUNIT_ASSERT_EQUAL(13,*elem++);
+      CPPUNIT_ASSERT_EQUAL(2,*elem++);
+    }
+    {
+      double x[3]={0.0,0.4,0.3};
+      elems = pl3.locate(x);
+      elem = elems.begin();
+      CPPUNIT_ASSERT_EQUAL(4,(int)elems.size());
+      CPPUNIT_ASSERT_EQUAL(1,*elem++);
+      CPPUNIT_ASSERT_EQUAL(10,*elem++);
+      CPPUNIT_ASSERT_EQUAL(4,*elem++);
+      CPPUNIT_ASSERT_EQUAL(5,*elem++);
+    }
+    {
+      double x[3]={0.5,0.5,0.5};
+      elems = pl3.locate(x);
+      elem = elems.begin();
+      CPPUNIT_ASSERT_EQUAL(4,(int)elems.size());
+      CPPUNIT_ASSERT_EQUAL(1,*elem++);
+      CPPUNIT_ASSERT_EQUAL(10,*elem++);
+      CPPUNIT_ASSERT_EQUAL(13,*elem++);
+      CPPUNIT_ASSERT_EQUAL(14,*elem++);
+    }
+    {
+      double x[3]={-1.0,0.0,0.0};
+      elems = pl3.locate(x);
+      CPPUNIT_ASSERT_EQUAL(0,(int)elems.size());
+    }
+    delete mesh3D;
+  }
 
 }
index 1607b0049dc18619d0032e8e0dc64cc335807251..3c621b60a9fbf0fbbbf3479d5c701f31830ae964 100644 (file)
@@ -37,6 +37,7 @@ namespace INTERP_TEST
 
     CPPUNIT_TEST_SUITE( PointLocatorTest );
     CPPUNIT_TEST( test_PointLocator );
+    CPPUNIT_TEST( test_PointLocatorInSimplex );
     CPPUNIT_TEST_SUITE_END();
 
    
@@ -47,6 +48,7 @@ namespace INTERP_TEST
 
     // tests
     void test_PointLocator();
+    void test_PointLocatorInSimplex();
 
   };