]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Cross dimension intersectors.
authorageay <ageay>
Fri, 26 Aug 2011 16:27:17 +0000 (16:27 +0000)
committerageay <ageay>
Fri, 26 Aug 2011 16:27:17 +0000 (16:27 +0000)
src/INTERP_KERNELTest/Makefile.am
src/INTERP_KERNELTest/MeshTestToolkit.hxx
src/INTERP_KERNELTest/TestInterpKernel.cxx
src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx [new file with mode: 0644]
src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx [new file with mode: 0644]

index c82d8e389e8a3a799d39a5b9461e5e5d3ef1e04d..17b3730c19e09e024ab88f7108b4cfaadfd2ae9f 100644 (file)
@@ -56,6 +56,8 @@ libInterpKernelTest_la_SOURCES=              \
        TransformedTriangleIntersectTest.cxx \
        TransformedTriangleTest.hxx          \
        TransformedTriangleTest.cxx          \
+       UnitTetra3D2DIntersectionTest.hxx    \
+       UnitTetra3D2DIntersectionTest.cxx    \
        UnitTetraIntersectionBaryTest.hxx    \
        UnitTetraIntersectionBaryTest.cxx    \
        TestInterpKernelUtils.hxx            \
index e6db9bcda7a6f51623ebc7ed833ac8ed5c90d74f..61d0db78a64091fe812fb373a90d22df5d1afb6b 100644 (file)
@@ -39,7 +39,7 @@ namespace INTERP_KERNEL
 
 namespace MEDMEM {
   class MESH;
-};
+}
 
 namespace INTERP_TEST
 {
index 25689c8c4891be8d3b10edd9bc49a62ccb203507..45a2772c6fc1bbc47e1c6c6e15b239fa97022185 100644 (file)
@@ -25,6 +25,7 @@
 #include "TransformedTriangleIntersectTest.hxx"
 #include "TransformedTriangleTest.hxx"
 #include "UnitTetraIntersectionBaryTest.hxx"
+#include "UnitTetra3D2DIntersectionTest.hxx"
 
 #ifdef DISABLE_MICROMED
 #include "HexaTests.hxx"
@@ -46,6 +47,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION( SingleElementPlanarTests );
 CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleIntersectTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( TransformedTriangleTest );
 CPPUNIT_TEST_SUITE_REGISTRATION( UnitTetraIntersectionBaryTest );
+CPPUNIT_TEST_SUITE_REGISTRATION( UnitTetra3D2DIntersectionTest );
 
 #ifdef DISABLE_MICROMED
 CPPUNIT_TEST_SUITE_REGISTRATION( HexaTests );
diff --git a/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx
new file mode 100644 (file)
index 0000000..91b0b1b
--- /dev/null
@@ -0,0 +1,176 @@
+// Copyright (C) 2007-2011  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "UnitTetra3D2DIntersectionTest.hxx"
+
+#include "TetraAffineTransform.hxx"
+#include "InterpolationUtils.hxx"
+#include "SplitterTetra.txx"
+
+#include <iostream>
+
+using namespace INTERP_KERNEL;
+
+namespace INTERP_TEST
+{
+  struct __MESH_DUMMY
+  {
+    typedef int MyConnType;
+    static const int MY_SPACEDIM=3;
+  };
+
+  static SplitterTetra<__MESH_DUMMY>* buildSplitterTetra()
+  {
+    const int conn[4] = { 0,1,2,3 };
+
+    const double targetCoords[] = { -20., 0.,10.,
+                                    -20.,10.,10.,
+                                    -12., 0.,10.,
+                                    -20., 0.,18. };
+
+    const double* tetraCoords[]={ targetCoords, targetCoords+3, targetCoords+6, targetCoords+9 };
+
+    __MESH_DUMMY dummyMesh;
+    SplitterTetra<__MESH_DUMMY>* targetTetra = new SplitterTetra<__MESH_DUMMY>( dummyMesh, tetraCoords, conn );
+    return targetTetra;
+  }
+
+  void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_1()
+  {
+    const int conn[4] = { 0,1,2 };
+
+    const double sourceCoords[] = { -20., 0., 10.,
+                                    -12., 0., 10.,
+                                    -20.,10., 10. };
+
+    SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
+    const double dimCaracteristic = 1.;
+    const double precision = 1.e-12;
+    std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
+    std::set<TriangleFaceKey> listOfTetraFacesColinear;
+
+    const double* sourceTriCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
+    double surface = targetTetra->intersectSourceFace(NORM_TRI3,
+                                                      3,
+                                                      conn,
+                                                      sourceTriCoords,
+                                                      dimCaracteristic,
+                                                      precision,
+                                                      listOfTetraFacesTreated,
+                                                      listOfTetraFacesColinear);
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
+
+    CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
+    std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
+    TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
+    correctListOfTetraFacesTreated.insert(key1);
+    TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
+    correctListOfTetraFacesTreated.insert(key2);
+    TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
+    correctListOfTetraFacesTreated.insert(key3);
+    TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
+    correctListOfTetraFacesTreated.insert(key4);
+    CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
+
+    CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
+    std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
+    correctListOfTetraFacesColinear.insert(key1);
+    CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
+
+  }
+
+  void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_2()
+  {
+    const int conn[4] = { 0,1,2,3 };
+
+    const double sourceCoords[] = { -20., 0., 10.,
+                                    -12., 0., 10.,
+                                    -12.,10., 10.,
+                                    -20.,10., 10. };
+
+    SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
+    const double dimCaracteristic = 1.;
+    const double precision = 1.e-12;
+    std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
+    std::set<TriangleFaceKey> listOfTetraFacesColinear;
+
+    const double* sourceQuadCoords[] = { sourceCoords, sourceCoords+3, sourceCoords+6, sourceCoords+9 };
+    double surface = targetTetra->intersectSourceFace(NORM_QUAD4,
+                                                      4,
+                                                      conn,
+                                                      sourceQuadCoords,
+                                                      dimCaracteristic,
+                                                      precision,
+                                                      listOfTetraFacesTreated,
+                                                      listOfTetraFacesColinear);
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(40.,surface,precision);
+
+    CPPUNIT_ASSERT_EQUAL(4,(int)listOfTetraFacesTreated.size());
+    std::multiset<TriangleFaceKey> correctListOfTetraFacesTreated;
+    TriangleFaceKey key1 = TriangleFaceKey(0, 1, 2);
+    correctListOfTetraFacesTreated.insert(key1);
+    TriangleFaceKey key2 = TriangleFaceKey(0, 1, 3);
+    correctListOfTetraFacesTreated.insert(key2);
+    TriangleFaceKey key3 = TriangleFaceKey(0, 2, 3);
+    correctListOfTetraFacesTreated.insert(key3);
+    TriangleFaceKey key4 = TriangleFaceKey(1, 2, 3);
+    correctListOfTetraFacesTreated.insert(key4);
+    CPPUNIT_ASSERT(correctListOfTetraFacesTreated == listOfTetraFacesTreated);
+
+    CPPUNIT_ASSERT_EQUAL(1,(int)listOfTetraFacesColinear.size());
+    std::set<TriangleFaceKey> correctListOfTetraFacesColinear;
+    correctListOfTetraFacesColinear.insert(key1);
+    CPPUNIT_ASSERT(correctListOfTetraFacesColinear == listOfTetraFacesColinear);
+
+ }
+
+  void UnitTetra3D2DIntersectionTest::test_UnitTetra3D2DIntersection_3()
+  {
+    const int conn[4] = { 0,1,2 };
+
+    const double sourceCoords[] = { -20., 0., 16.,
+                                    -18., 0., 16.,
+                                    -20.,2.5, 16. };
+
+    SplitterTetra<__MESH_DUMMY>* targetTetra = buildSplitterTetra();
+    const double dimCaracteristic = 1.;
+    const double precision = 1.e-12;
+    std::multiset<TriangleFaceKey> listOfTetraFacesTreated;
+    std::set<TriangleFaceKey> listOfTetraFacesColinear;
+
+    const double* sourceTri2Coords[] = { sourceCoords, sourceCoords+3, sourceCoords+6 };
+    double surface = targetTetra->intersectSourceFace(NORM_TRI3,
+                                                      3,
+                                                      conn,
+                                                      sourceTri2Coords,
+                                                      dimCaracteristic,
+                                                      precision,
+                                                      listOfTetraFacesTreated,
+                                                      listOfTetraFacesColinear);
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5,surface,precision);
+
+    CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesTreated.size());
+
+    CPPUNIT_ASSERT_EQUAL(0,(int)listOfTetraFacesColinear.size());
+ }
+
+}
diff --git a/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx
new file mode 100644 (file)
index 0000000..d1fc468
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (C) 2007-2011  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __UNITTETRA3D2DINTERSECTIONTEST_HXX__
+#define __UNITTETRA3D2DINTERSECTIONTEST_HXX__
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "InterpKernelTestExport.hxx"
+
+namespace INTERP_TEST
+{
+  /**
+   * \brief Test suite testing UnitTetra3D2DIntersection class.
+   *
+   */
+  class INTERPKERNELTEST_EXPORT UnitTetra3D2DIntersectionTest : public CppUnit::TestFixture
+  {
+    CPPUNIT_TEST_SUITE( UnitTetra3D2DIntersectionTest );
+    CPPUNIT_TEST( test_UnitTetra3D2DIntersection_1 );
+    CPPUNIT_TEST( test_UnitTetra3D2DIntersection_2 );
+    CPPUNIT_TEST( test_UnitTetra3D2DIntersection_3 );
+    CPPUNIT_TEST_SUITE_END();
+  public:
+    void test_UnitTetra3D2DIntersection_1();
+    void test_UnitTetra3D2DIntersection_2();
+    void test_UnitTetra3D2DIntersection_3();
+  };
+}
+
+#endif