From 66916be7a176d6ea837ccafaadc406d3fd111639 Mon Sep 17 00:00:00 2001 From: bph Date: Wed, 5 Oct 2011 09:12:36 +0000 Subject: [PATCH] Prestation INTERP_KERNEL D. POIZAT --- .../UnitTetra3D2DIntersectionTest.cxx | 180 ++++++++++++++++++ .../UnitTetra3D2DIntersectionTest.hxx | 51 +++++ 2 files changed, 231 insertions(+) create mode 100644 src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx create mode 100644 src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx diff --git a/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx new file mode 100644 index 000000000..feed74d61 --- /dev/null +++ b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.cxx @@ -0,0 +1,180 @@ +// 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 +// + +// File : UnitTetraIntersectionBaryTest.cxx +// Created : Thu Dec 11 15:54:41 2008 +// Author : Edward AGAPOV (eap) +// +#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..b3925b4c5 --- /dev/null +++ b/src/INTERP_KERNELTest/UnitTetra3D2DIntersectionTest.hxx @@ -0,0 +1,51 @@ +// 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 +// + +// File : UnitTetraIntersectionBaryTests.hxx +// Created : Thu Nov 6 17:11:27 2008 +// Author : Edward AGAPOV (eap) +// +#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