From 8e01ac0619deb700a667af1e8e6c7a5036668cf0 Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 26 Aug 2011 16:27:17 +0000 Subject: [PATCH] Cross dimension intersectors. --- src/INTERP_KERNELTest/Makefile.am | 2 + src/INTERP_KERNELTest/MeshTestToolkit.hxx | 2 +- src/INTERP_KERNELTest/TestInterpKernel.cxx | 2 + .../UnitTetra3D2DIntersectionTest.cxx | 176 ++++++++++++++++++ .../UnitTetra3D2DIntersectionTest.hxx | 47 +++++ 5 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx create mode 100644 src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx diff --git a/src/INTERP_KERNELTest/Makefile.am b/src/INTERP_KERNELTest/Makefile.am index c82d8e389..17b3730c1 100644 --- a/src/INTERP_KERNELTest/Makefile.am +++ b/src/INTERP_KERNELTest/Makefile.am @@ -56,6 +56,8 @@ libInterpKernelTest_la_SOURCES= \ TransformedTriangleIntersectTest.cxx \ TransformedTriangleTest.hxx \ TransformedTriangleTest.cxx \ + UnitTetra3D2DIntersectionTest.hxx \ + UnitTetra3D2DIntersectionTest.cxx \ UnitTetraIntersectionBaryTest.hxx \ UnitTetraIntersectionBaryTest.cxx \ TestInterpKernelUtils.hxx \ diff --git a/src/INTERP_KERNELTest/MeshTestToolkit.hxx b/src/INTERP_KERNELTest/MeshTestToolkit.hxx index e6db9bcda..61d0db78a 100644 --- a/src/INTERP_KERNELTest/MeshTestToolkit.hxx +++ b/src/INTERP_KERNELTest/MeshTestToolkit.hxx @@ -39,7 +39,7 @@ namespace INTERP_KERNEL namespace MEDMEM { class MESH; -}; +} namespace INTERP_TEST { diff --git a/src/INTERP_KERNELTest/TestInterpKernel.cxx b/src/INTERP_KERNELTest/TestInterpKernel.cxx index 25689c8c4..45a2772c6 100644 --- a/src/INTERP_KERNELTest/TestInterpKernel.cxx +++ b/src/INTERP_KERNELTest/TestInterpKernel.cxx @@ -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 index 000000000..91b0b1b43 --- /dev/null +++ b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx @@ -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 + +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 listOfTetraFacesTreated; + std::set 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 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 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 listOfTetraFacesTreated; + std::set 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 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 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 listOfTetraFacesTreated; + std::set 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 index 000000000..d1fc4689e --- /dev/null +++ b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx @@ -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 + +#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 -- 2.39.2